上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 29 下一页
摘要: 激活函数 激活函数函数代码Sigmoidtf.nn.sigmoid(x)ReLUtf.nn.relu(x)LeakyReLUtf.nn.leaky_relu(x, alpha)Tanhtf.nn.tanh(x) Sigmoid Sigmoid图像 logistic函数,因为其形状为S型,又称Sigm 阅读全文
posted @ 2020-09-04 16:30 kuanleung 阅读(47) 评论(0) 推荐(0)
摘要: 误差loss, E \Epsilon E 误差计算 E = g ( f θ ( x ) , y ) \Epsilon = g(f_\theta(x),y) E=g(fθ​(x),y) f θ ( x ) f_\theta(x) fθ​(x)为当前模型下y的预测值 g ( . ) g(.) g(.)为 阅读全文
posted @ 2020-09-04 15:29 kuanleung 阅读(29) 评论(0) 推荐(0)
摘要: 多层神经网络实现 多层神经网络 张量方式实现 初始化各层调用梯度记录器(自动求导)搭建各层 import tensorflow as tf from tensorflow.keras import layers x = tf.random.normal([3,784])#模拟2个样本,50个特征 w 阅读全文
posted @ 2020-09-04 14:10 kuanleung 阅读(19) 评论(0) 推荐(0)
摘要: 全连接的层实现 功能函数代码层实现方式layers.Dense(units, activation)获取 Dense 类的权值矩阵fc.kernel获取 Dense 类的偏置向量fc.bias返回待优化参数列表fc.trainable_variables 层实现 layers.Dense(units 阅读全文
posted @ 2020-09-04 13:14 kuanleung 阅读(44) 评论(0) 推荐(0)
摘要: 全连接层的张量实现 单层神经网络的实现 定义好权值张量𝑾和偏置张量𝒃批量矩阵相乘函数 tf.matmul()即可完成网络层的计算偏置向量𝒃与计算完𝑿@𝑾的相加将结果传入激活函数 import tensorflow as tf x = tf.random.normal([2,567])#模拟 阅读全文
posted @ 2020-09-04 11:25 kuanleung 阅读(29) 评论(0) 推荐(0)
摘要: 神经网络基础 感知机 公式表达: z = W T x + b , a = σ ( z ) = σ ( W T x + b ) z= W^Tx + b , a = \sigma (z) = \sigma (W^Tx + b) z=WTx+b,a=σ(z)=σ(WTx+b) 通过a与Y的误差调整W与b 阅读全文
posted @ 2020-09-04 11:06 kuanleung 阅读(15) 评论(0) 推荐(0)
摘要: 经典数据集操作 功能函数代码加载数据集datasets.Dataset_name.load_data()构建 Dataset 对象tf.data.Dataset_name.from_tensor_slices((x, y))随机打散Dataset_name.shuffle(buffer_size)批 阅读全文
posted @ 2020-09-04 09:16 kuanleung 阅读(48) 评论(0) 推荐(0)
摘要: 高级操作函数 功能函数代码根据索引号抽样tf.gather(x,index,axis)根据索引号采集多个样本tf.gather_nd(x,index)掩码采样tf.boolean_mask(x, mask, axis)条件取样tf.where(cond,a,b)刷新张量tf.scatter_nd(i 阅读全文
posted @ 2020-09-03 20:14 kuanleung 阅读(27) 评论(0) 推荐(0)
摘要: 填充与复制 功能函数代码填充tf.pad(x,padding)复制tf.tile(x,multiples)限幅tf.maximum(x, a),tf.minimum(x, a) 填充 tf.pad(x,padding)padding 以列表形式传入paddings 是包含了多个[Left Paddi 阅读全文
posted @ 2020-09-03 13:54 kuanleung 阅读(34) 评论(0) 推荐(0)
摘要: 张量比较 功能函数代码输出转换为概率tf.nn.softmax(x, axis)张量是否相等tf.equal(a, b)或 tf.math.equal(a,b)大于tf.math.greater小于tf.math.less大于等于tf.math.greater_equal小于等于tf.math.le 阅读全文
posted @ 2020-09-03 12:36 kuanleung 阅读(39) 评论(0) 推荐(0)
上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 29 下一页