tensorflow 函数学习

tf.get_variable('x')

获取变量x的值,如果变量名为x的变量没有的话就创建,有的话就引用
详情:https://blog.csdn.net/weixin_36670529/article/details/97646462

tf.variable_scope()

变量的作用域管理器

tf.variable_scope()的意义,在大项目中,变量很多,第114行有一个v的变量,第339行又出现了v的变量,后面写代码都晕了,搞不清楚。怎么办?搞一个变量管理器,即使变量名一样,但是变量作用域不一样,引用的时候就不会出现穿插问题了,方便代码的维护

详情看:https://blog.csdn.net/tian_jiangnan/article/details/105047745

np.random.permutation()

随机排列序列。如np.random.permutation(5) [ 2 , 4 , 1 , 0 , 3 ]

np.arange()
函数返回一个有终点和起点的固定步长的排列,如[1,2,3,4,5],起点是1,终点是6,步长为1。
详情看:https://blog.csdn.net/qq_41550480/article/details/89390579

np.unique()
该函数是去除数组中的重复数字,并进行排序之后输出。

使用sklearn库函数来切分训练集和测试集

from sklearn.model_selection import train_test_split
train_set, test_set = train_test_split(housing, test_size = 0.2, random_state=42)

sk-learn中提StratifiedShuffleSplit()提供分层抽样功能,确保每个标签对应的样本的比例
详情看:https://blog.csdn.net/wtzhu_13/article/details/93903868

split.split
详情看:https://blog.csdn.net/dss_dssssd/article/details/82818601

loc函数:通过行索引 “Index” 中的具体值来取行数据(如取"Index"为"A"的行)
iloc函数:通过行号来取行数据(如取第二行的数据)

astype(np.int8)
类型转换

data.info() 查看数据详情,可以查看数据缺失情况和数据类型

sgd_clf.decision_function([some_digit])
通过decision_function可以获得一种"分值",这个分值的几何意义就是当前点到超平面(hyperplane)的距离

fit_transform 和transform的区别:
一般训练集用fit_transform,测试集用transform
详情:https://blog.csdn.net/quiet_girl/article/details/72517053

np.r_是按列连接两个矩阵,就是把两矩阵上下相加,要求列数相等。
np.c_是按行连接两个矩阵,就是把两矩阵左右相加,要求行数相等。

predict返回的是一个预测的值,predict_proba返回的是对于预测为各个类别的概率。

numpy.apply_along_axis(func, axis, arr, *args, **kwargs)
将arr数组的每一个元素经过func函数变换形成的一个新数组
详情:https://blog.csdn.net/starmoth/article/details/83832458

n_jobs:用来设定CPU运行情况,n_jobs=-1便是使用全部的CPU。

GridSearchCV
详情:https://blog.csdn.net/weixin_41988628/article/details/83098130

reshape
reshape(-1) 变成数组/行向量
reshape(-1,1) 不知道多少行,1列
详情:https://www.zhihu.com/question/52684594

求范数

x_norm=np.linalg.norm(x, ord=None, axis=None, keepdims=False)

https://blog.csdn.net/hqh131360239/article/details/79061535

画图

plt.axis(“off”) 关闭坐标轴
详情: [https://www.cnblogs.com/shuaishuaidefeizhu/p/14034415.html](https://www.cnblogs.com/shuaishuaidefeizhu/p/14034415.html)

ax = fig.add_subplot(349) 参数349的意思是:将画布分割成3行4列,图像画在从左到右从上到下的第9块 [https://blog.csdn.net/rootkiss/article/details/88191336](https://blog.csdn.net/rootkiss/article/details/88191336)
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值