- 博客(27)
- 收藏
- 关注
原创 tf.variable_scope 和 tf.name_scope
这两个函数在大部分情况下是等价的,唯一的区别是在使用tf.get_variable函数时。tf.get_variable函数不受tf.name_scope的影响。# tf.variable_scopewith tf.variable_scope('foo'): a = tf.get_variable('bar',[1]) print(a.name)#结果为foo/bar:0# tf.name_scopewith tf.name_scope('a'): a=tf.Varia
2022-01-06 23:37:50
903
原创 Python中“if __name__==‘__main__‘:”理解与总结
if name==‘main’ 的作用:代码的规范性该语句像是一个标志,象征着Java等语言中的程序主入口,告诉其他程序员,代码入口在此。锁定语句当我们把模块A中的代码在模块B中进行import A时,只要B模块代码运行到该import语句,模块A的代码会被执行。如果在模块A中,我们有部分的代码不想在被导入到B时直接被运行,但在直接运行A时可直接运行,可以将这些语句加在A模块的:if name==‘main’: 下。参考:https://www.cnblogs.com/chenhu
2022-01-05 22:03:54
882
原创 GridSearchCV
来源:https://blog.youkuaiyun.com/woaixuexihhh/article/details/84702233from sklearn.model_selection import GridSearchCVparam_grid = {'svc__C': [1, 5, 10], 'svc__gamma': [0.0001, 0.0005, 0.001]}grid = GridSearchCV(model, param_grid)print(Xtrain.sh
2022-01-04 14:47:09
1171
转载 将Pandas的DataFrame转化成ndarray类型
https://blog.youkuaiyun.com/jinguangliu/article/details/78538748as_matrix()方法可以指定获取的列;values属性将使用所有的列转换为ndarray对象,等同与无参数的as_matrix();array()接受将DataFrame对象作为参数创建ndarray对象。...
2021-06-16 12:40:32
1582
原创 如何判断数据是否符合正态分布
网址:https://blog.youkuaiyun.com/weixin_45743162/article/details/1135206491、Q-Q图2、直方图3、shapiro检验
2021-05-27 20:56:28
1397
原创 2021-04-23
求互信息1、sklearn.metrics.mutual_info_score2、自定义函数def hxx(x, y): size = x.shape[-1] px = np.histogram(x, 256, (0, 255))[0] / size py = np.histogram(y, 256, (0, 255))[0] / size hx = - np.sum(px * np.log(px + 1e-8)) hy = - np.sum(py * np.l
2021-04-23 23:03:45
82
原创 MSE、RMSE、MAE、R2_score
原文链接:https://blog.youkuaiyun.com/wade1203/article/details/98477034
2020-06-05 10:13:12
806
原创 mathtype空心字母的输入
https://www.mathtype.cn/jiqiao/shuru-kongxinzi-huatizi.html1、样式----自定义----文本下拉菜单中找到Eulid Math Two----确定2、选中要更改的字母,样式----文本
2020-03-22 17:00:01
12176
3
原创 openyxl
https://blog.youkuaiyun.com/ykz_zzz/article/details/102670453在xlsx中写入数据
2020-02-09 11:32:30
228
原创 三种不同的随机种子
来源:https://blog.youkuaiyun.com/duanlianvip/article/details/95493362
2020-01-13 09:50:31
647
原创 数据三维可视化
from mpl_toolkits.mplot3d import Axes3Dfig = plt.figure()ax = plt.axes(projection='3d')ax.scatter3D(reduced_gen[:, 0], reduced_gen[:, 1], reduced_gen[:, 2], cmap='Greens')ax.scatter3D(reduced_orig...
2019-12-30 15:17:16
921
原创 调参工具:Hyperopt
机器学习模型调参方法有三种:1、网格搜索(全面但耗时)2、随机搜索(快速但不全面)3、贝叶斯优化https://github.com/hyperopt/hyperopt-sklearn github官方文档https://www.jianshu.com/p/35eed1567463https://blog.youkuaiyun.com/zehui6202/article/details/80...
2019-12-25 21:05:13
308
原创 scikit-learn中的score
它提供了一个缺省的评估法则来解决问题,简要的说,它用你训练好的模型在测试集上进行评分(0~1)。1分代表最好,也有可能会得到负值。clf.fit(X_train,Y_train)print(clf.score(X_test,Y_test))...
2019-12-24 10:58:11
1098
原创 matplotlib 作图
1. 加载:import numpy as np from matplotlib import pyplot as plt 2. 需显示中文字体,要加上:# fname为下载的字体库:SimHei.ttf 字体的存放路径# SimHei.ttf文件要放在当前执行的代码文件中from matplotlib.font_manager import FontPropertiesfont ......
2019-12-05 16:59:55
271
原创 SVM、SVR学习文章
https://blog.youkuaiyun.com/qq_16633405/article/details/70243030(介绍SVR、SVM的基本知识)https://scikit-learn.org/stable/auto_examples/svm/plot_rbf_parameters.html#sphx-glr-auto-examples-svm-plot-rbf-parameters-py...
2019-12-05 10:40:20
861
原创 sklearn中的数据集的划分
方法:KFold,GroupKFold,StratifiedKFold,LeaveOneGroupOut,LeavePGroupsOut,LeaveOneOut,LeavePOut,ShuffleSplit,GroupShuffleSplit,StratifiedShuffleSplit,PredefinedSplit,TimeSeriesSplit具体使用见:https://www.bbsma...
2019-12-05 09:25:58
256
原创 numpy.logspace函数
logspac用于创建等比数列通用公式:>>> creat_rray = np.logspace(A,B,C,base=D)>>> creat_rrayarray([ 1., 2., 4., 8., 16., 32., 64., 128., 256., 512.])A: 生成数组的起始值为D的A次方B:生成数...
2019-12-04 21:39:28
1737
2
转载 fit、fit_transform()和transform()
参考:https://blog.youkuaiyun.com/weixin_38278334/article/details/82971752https://blog.youkuaiyun.com/appleyuchi/article/details/73503282(代码可以看了学习,文字看本页的即可)概述:fit和transform没有任何关系,仅仅是数据处理的两个不同环节,之所以出来fit_transfor...
2019-12-03 09:29:40
259
转载 归一化
摘自维基百科:https://en.wikipedia.org/wiki/Feature_scaling为什么要进行归一化Since the range of values of raw data varies widely, in some machine learning algorithms, objective functions will not work properly wi...
2019-12-02 19:57:46
261
原创 调用其他文件下的函数或类
1. B.py和A.py在同一个文件夹下(B.py调用A.py)- 调用函数:A.py:def add(x,y): print('和为:%d'%(x+y)) B.py 调用函数:import A A.add(1,2) 或者:from A import addadd(1,2)**- 调用类:**A.py:class A: def __init...
2019-11-26 10:43:20
620
原创 hstack,vstack
np.vstack:按垂直方向(行顺序)堆叠数组构成一个新的数组np.hstack:按水平方向(列顺序)堆叠数组构成一个新的数组具体用法参考:https://www.jianshu.com/p/2469e0e2a1cf若两个数组只有一列,需要将他们按列堆叠时,只能使用hstackx_train_plus = np.vstack((x_train, predict_x)) #x_train...
2019-11-25 16:30:51
223
原创 将numpy数组保存为excel文件
import numpy as npimport pandas as pd# 准备数据data = np.arange(1,101).reshape((10,10))data_df = pd.DataFrame(data) #关键1,将ndarray格式转换为DataFrame# 更改表的索引data_df.columns = ['A','B','C','D','E','F',...
2019-11-25 15:39:32
33127
6
原创 在tensorboard中生成损失函数的折线图
需要在tensorboard中显示的数据下加:tf.summary.scalar('disc_cost',disc_cost)若写有多条 tf.summary.scalar() 代码,则将他们汇总起来:merged = tf.summary.merge_all()在with tf.Session() as sess: 中运行:with tf.Session() as s...
2019-11-22 20:09:17
2504
转载 TensorFlow-ckpt-模型的保存和调用
1、保存模型import tensorflow as tfimport numpy as npW = tf.Variable([[1, 2, 3], [3, 4, 5]], dtype=tf.float32, name='weights')b = tf.Variable([[1, 2, 3]], dtype=tf.float32, name='biases')init = tf.glob...
2019-11-22 16:24:45
3869
转载 归一化
转自:https://www.cnblogs.com/zhange000/articles/10748906.html数据归一化(Normalization,又称Min-Max Scaling):数据(x)按照最小值中心化后,再按极差(最大值 - 最小值)缩放,数据移动了最小值个单位,并且会被收敛到[0,1]之间的过程。归一化之后的数据服从正态分布,公式如下:x = (x - min(x))...
2019-11-21 21:42:59
1614
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人