
TensorFlow
zwhfyy
无
展开
-
python print 打印不使用省略号
import tensorflow as tfimport osimport numpy as npnp.set_printoptions(threshold=np.inf) # threshold 指定超过多少使用省略号,np.inf代表无限大原创 2020-07-28 01:08:31 · 11317 阅读 · 0 评论 -
八股功能扩展
自制数据集,解决本领域应用 数据增强,扩充数据集 断点续训,存取模型 参数提取,把参数存入文本 acc/loss可视化,查看训练效果 应用程序给图识别物体自制数据集代码import tensorflow as tffrom PIL import Imageimport numpy as npimport ostrain_path = './mnist_image_label/mnist_train_jpg_60000/'train_txt = './mnist_image.原创 2020-07-28 01:07:07 · 251 阅读 · 0 评论 -
六步法搭建神经网络
tf.keras搭建网络八股六步法:import 导入模块train,test 训练集和测试集是什么(训练集输入特征x_train和训练集的标签y_train) (测试集输入特征x_test和测试集的标签y_test)model = tf.keras.models.Sequential 在Sequntial()中搭建网络结构,逐层描述每层网络,走一遍前向传播model.c...原创 2020-07-26 23:50:00 · 493 阅读 · 0 评论 -
损失函数
交叉熵损失函数CE(Cross Entropy):表征两个概率分布之间的距离 H(y_,y)= - Σy_ * lnyeg.二分类已知答案y_=(1,0) 预测 y1=(0.6,0.4) y2=(0.8,0.2)哪个更接近标准答案?H1((1,0),(0.6,0.4))=-(1*ln0.6+0*0.4) ≈ -(-0.511+0) = 0.511H2((1,0),(0.8,0.2))=-(1*ln0.8+0*0.2) ≈ -(-0.223+0) = 0.223因为H1>H2,所以y2预原创 2020-07-26 08:39:46 · 370 阅读 · 0 评论 -
TensorFlow笔记
求导import tensorflow as tfwith tf.GradientTape() as tape: x = tf.Variable(tf.constant(3.0)) #x可训练,可更新 y = tf.pow(x, 2) #函数名称grad = tape.gradient(y, x) #对 x的平方求导 = 2xprint(grad) #答案是6原创 2020-07-23 00:30:11 · 185 阅读 · 0 评论