![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
机器学习
西红柿
这个作者很懒,什么都没留下…
展开
-
新的激活函数swish
Swish激活函数是Google公司在2017年10月提出的新的激活函数。Swish函数的定义为f(x)=x⋅sigmoid(βx),其中β是一个常数或可训练的参数。import tensorflow as tfimport numpy as npx1=np.array([[1,2,3,4,5],[1,2,3,4,5]])x2=np.array([[1,2,3,4,5],[1,2,3,4,...原创 2019-10-15 21:23:17 · 1773 阅读 · 0 评论 -
我的tensorflow学习日常
在tensorflow中numpy与tensor的互相转化在进行tensorflow运算时,我们常常需要进行tensor与numpy的转换。我们用tensor=tf.convert_to_tensor(numpy)实现numpy转换到tensor用sess.run()转换tensor到numpyimport tensorflow as tfimport numpy as npa=np...原创 2019-10-15 21:08:55 · 113 阅读 · 0 评论 -
机器学习之python基础篇面向对象
“”"@theme 类的调用@time 2018/12/06@author lz@content 类的调用“”"class Cat:def eat(self):#哪一个对象调用的方法,self就是哪一个对象的引用print(“吃饭”)print("%s 爱吃鱼 “%self.name)def drink(self):print(“喝水”)print(”%s 爱喝水"%...原创 2018-12-07 09:13:00 · 249 阅读 · 0 评论 -
机器学习之python基础
“”"@Theme class@Author lz@Time 2018/12/9@content str“”"class Cat:def init(self,name):self.name=nameprint("%s 来了"%self.name)def del(self):print("%s 去了"%self.name)def str(self):#_str...原创 2018-12-09 15:53:33 · 122 阅读 · 0 评论 -
机器学习之python基础
“”"@Theme 类@author lz@Time 2018/12/09@content 封装“”"class Person:def init(self,name,weight):self.name=nameself.weight=weightdef str(self):return(“我的名字叫 %s 我的体重是 %.2f 公斤 “%(self.name...原创 2018-12-09 21:28:49 · 94 阅读 · 0 评论 -
机器学习之python基础
“”"@Theme 类@author lz@Time 2018/12/10@content 访问私有属性的方法“”"class Woman:def init(self,name,age):self.name=name;#定义私有属性self.__age=age;def secret(self):print("%s 的年龄是 %d"%(self.name,sel...原创 2018-12-10 20:19:51 · 169 阅读 · 0 评论 -
机器学习之python爬虫爬去百度贴吧一个页面
“”"@theme 爬虫@time 2018/12/16@author lz@content 爬取python吧的页面@step1导入2发出请求3转码4保存“”"coding : UTF-8#1导入网络模块from urllib import requesturl=“http://tieba.baidu.com/f?kw=python&ie=utf-8&a...原创 2018-12-16 21:31:10 · 159 阅读 · 0 评论 -
机器学习之python常用库matplotlib
import matplotlib.pyplot as pltimport numpy as npplt.plot([1,4,9],[5,5,5])plt.show()“”"@Theme matplotlib@author lz@Time 2018/12/10@content figure“”"import matplotlib.pyplot as ...原创 2018-12-11 14:30:00 · 187 阅读 · 0 评论 -
机器学习之python中的pandas
“”"@theme numpy@time 2019.01.03@author lz@content 解非齐次方程组“”"import numpy as npfrom scipy.linalg import solvea=np.array([[1,1],[2,3]])print(a)b=np.array([[3],[4]])print(b)m=s...原创 2019-01-03 20:06:50 · 171 阅读 · 0 评论 -
机器学习之python基础篇pandas
“”"@theme pandas@time 2018/12/17@author lz@content 测试pd.isnull方法和pd.notfull方法@function pd.isnull过滤缺失值得项pd.notnull过滤出不是缺失值得项“”"import pandas as pdfrom pandas import Seriesscores...原创 2018-12-18 22:48:52 · 147 阅读 · 0 评论 -
机器学习之python基础库pandas完成读取Excel文件,并进行增删改查的操作
“”"@theme pandas@author lz@time 2019/01/03@content 读取xls文件,并修改io:excel文件,如果命名为中文,在python2.7中,需要使用decode()来解码成unicode字符串,例如: pd.read_excel(‘示例’.decode('utf-8))sheet_name:返回指定的sheet,如果将shee...原创 2019-01-03 22:27:21 · 1890 阅读 · 0 评论 -
机器学习之python基础库pandas
“”"@theme pandas@time 2018/12/24@author lz@content 去重,值计数,成员资格“”"import pandas as pd#去重唯一值ser01=pd.Series([‘a’,‘b’,‘c’,‘d’,‘a’,‘b’,‘c’])print(ser01)print(ser01.dtype)print(ser01.uniq...原创 2018-12-24 22:45:06 · 127 阅读 · 0 评论 -
机器学习之pyhton基础库pandas
“”"@theme pandas@time 2018/12/24@author lz@content 层次索引series以及Dataframe“”"import pandas as pd#双层索引data=pd.Series([100,200,300],index=[[“苹果”,“香蕉”,“李子”],[“2000”,“3000”,“4000”]])prin...原创 2018-12-24 23:34:06 · 86 阅读 · 0 评论 -
机器学习之python基础库numpy
“”"@theme numpy@time 2018/12/14@author lz@content no.unique去重“”"import numpy as nparr1=np.array([“java”,“java”,“C语言”,“C++”,“C#”,“Pyhton”])print("-"*10,“原始数据”,"-"*10)for i in arr1:原创 2018-12-14 12:09:12 · 161 阅读 · 0 评论 -
机器学习之python基础库numpy
“”"@Theme numpy@author lz@Time 2018/12/12@content 创建数组“”"import numpy as np#用列表创建一维数组print(np.array([1,2,3]))#用元组创建一维数组print(np.array((1,2,3)))#创建多维元组,利用列表print(np.array([[1,2,3],[4...原创 2018-12-13 12:13:22 · 95 阅读 · 0 评论 -
机器学习之python基础篇
“”"@theme 类@time 2018/12/8@author lz@content _del_方法“”"class Cat:def init(self,name):self.name=name;print(“我的 %s 名字是”% self.name)print(1)#在对象结束前,会自动调用_del_方法def del(self):print(...原创 2018-12-08 22:42:02 · 89 阅读 · 0 评论 -
机器学习之Python基础3
age=int(input(“请输入年龄”))python_score=int(input(“请输入分数”))if age>18 and python_score>50:print(“可以去网吧”)else:print(“不可以”)原创 2018-11-25 20:07:06 · 101 阅读 · 0 评论 -
机器学习python基础篇4多分支语句
day=input(“请输入节日”)if day==“情人节”:print(“玫瑰”)elif day==“平安夜”:print(“吃苹果”)elif day==“生日”:print(“吃蛋糕”)else :print(“吃饭”)...原创 2018-11-25 20:25:36 · 161 阅读 · 0 评论 -
机器学习之python基础5
“”"火车进站携带刀子,要写if必须成对出现“”"knife_length=30;has_ticket=True;if has_ticket:print(“上车”)if knife_length>20:print(“长度超过 %d 不能上车”%(knife_length-20))else:print(“下车”)...原创 2018-11-25 22:44:16 · 94 阅读 · 0 评论 -
机器学习之路之python基础9
“”"在程序开发过程中,如果对某些代码的实行不能确定可以增加语句来捕获异常,以下是完整的异常代码“”"try:num=int(input(“请输入一个整数”))result=8/num;print(result)except ZeroDivisionError:#except 错误类型1就是用来捕获错误类型1这种异常的print(“0不能做除数”)except ValueErr...原创 2018-12-04 15:49:59 · 184 阅读 · 0 评论 -
机器学习之python基础篇6
“”"@theme list的取值,增加,删除@time 2018/11/26@author lz“”"name_list=[“zhangsan”,“lisi”,“maliu”];#定义列表name_list[0]=“张三”#修改列表的值name_list.pop()#在末尾删除一个元素name_list.append(“李四”)#在末尾增加一个元素temp_lis...原创 2018-11-26 21:41:59 · 166 阅读 · 0 评论 -
机器学习之基础篇
“”"@theme tuple@time 2018/11/26@author lz“”"s1=(12,23,12,23,12,12)s2=(“lisi”,14,34)print(s1.index(12))print(s1[0])#取值print(s1+s2)#元祖连接print(s1[1:3])#切片print(len(s1))#len函数求长度print(m...原创 2018-11-27 10:15:33 · 121 阅读 · 1 评论 -
机器学习之python基础10
“”"操作文件的步骤:1打开文件2读写文件3关闭文件用到1个函数open3个方法read,write,close先写open,close在写read和write“”"file=open(“readme.txt”)#默认是以只读文件的形式并且返回对象,resdme中不能含有中文否则报错text=file.read()print(text)print("*"*50)file.clo...原创 2018-12-04 21:10:17 · 95 阅读 · 0 评论 -
机器学习之python基础篇11
“”"@theme file@time 2018/12/4@author lz@content 读取大文件,需要一行行读取文件的数据,“”"file=open(“readme.txt”)while True:text=file.readline();if not text:breakfile.close()...原创 2018-12-04 21:54:08 · 66 阅读 · 0 评论 -
机器学习之python基础课8
“”"字典的含义:字典可以用来存储多个数据,通常用来描述一个物体的相关信息,字典可以使用健值存储信息。健是索引,值是数据。健和值之间使用:隔开。“”"xiaoming={“name”:“小明”,“age”:18}print(xiaoming[“name”])#取值xiaoming[“age”]=17#修改值如果有,修改值xiaoming[“gender”]=“男”#修改值如果没有,就...原创 2018-11-27 21:22:44 · 128 阅读 · 0 评论 -
机器学习之python基础12
str1=“abababcdefababghijkjkjkjk”print(str1.split(“ab”,2))#从左向右依次分割字符串,可以指定分割次数print(str1.rsplit(“a”))#从右向左依次分割字符串,可以指定分割次数print(str1.splitlines())#以换行符为分隔,组合成列表print(str1.partition(“e”))#从右往左以第一个指...原创 2018-12-05 10:45:10 · 74 阅读 · 0 评论 -
机器学习之python基础13
“”"@theme 字符串格式化输出@author lz@time 2018/12/05@content format的用法“”"str2=“my name is {name},age is {old}”#以字典的形式赋值,然后格式化输出print(str2.format_map({“name”:“lian”,“old”:“11”}))#以变量的形式赋值,然后...原创 2018-12-05 12:50:56 · 91 阅读 · 0 评论 -
机器学习之python基础15
“”"@theme 类@time 2018/12/7@author lz@content 初始方法,同时设置初始值“”"class Cat:def init(self,new_name):print(1)#self.属性名=属性的值self.name=new_namedef eat(self): print(2)tom=Cat(“Tom”)pri...原创 2018-12-07 22:19:08 · 86 阅读 · 0 评论 -
机器学习之路的Python基础篇2
@theme print格式化输出@author lz@time 2018/11/25apple_price=float(input(“请输入价格”))#因为input中输入的是系统默认为字符串apple_number=float(input(“苹果的数量”))#因为input中输入的是系统默认为字符串money=apple_number*apple_price;...原创 2018-11-25 17:14:59 · 91 阅读 · 0 评论