tensorflow中常用的几种权重矩阵初始化的方式
tensorflow
一个面向所有人的开源机器学习框架
项目地址:https://gitcode.com/gh_mirrors/te/tensorflow

·
这里总结几种权重矩阵的初始化方式:
1:截断的正态分布:
def init_matrix(shape):
return tf.truncated_normal(shape, mean=0, stddev=0.1)
2.xavier_initializer()法:这个初始化器是用来保持每一层的梯度大小都差不多相同
tensorflow
一个面向所有人的开源机器学习框架
项目地址:https://gitcode.com/gh_mirrors/te/tensorflow
W = tf.get_variable("W", shape=[784, 100],
initializer=tf.contrib.layers.xavier_initializer())
3.cs231n推荐:
w=np.random.randn(in,out)/np.sqrt(2.0/in)#in,out为输入输出的神经元个数
使用:
W1_init = np.random.randn(784, 100).astype(np.float32) * np.sqrt(2.0/(784))
b1_init = np.zeros([100]).astype(np.float32)
W2_init = np.random.randn(100, 100).astype(np.float32) * np.sqrt(2.0/(100))
b2_init = np.zeros([100]).astype(np.float32)
W3_init = np.random.randn(100, 10).astype(np.float32) * np.sqrt(2.0/(100))
b3_init = np.zeros([10]).astype(np.float32)
W_inits = [W1_init, b1_init, W2_init, b2_init, W3_init, b3_init]
推荐内容




一个面向所有人的开源机器学习框架
最近提交(Master分支:2 个月前 )
4f64a3d5
Instead, check for this case in `ResolveUsers` and `ResolveOperand`, by querying whether the `fused_expression_root` is part of the `HloFusionAdaptor`.
This prevents us from stepping into nested fusions.
PiperOrigin-RevId: 724311958
2 个月前
aa7e952e
Fix a bug in handling negative strides, and add a test case that exposes it.
We can have negative strides that are not just -1, e.g. with a combining
reshape.
PiperOrigin-RevId: 724293790
2 个月前
更多推荐
相关推荐
查看更多
tensorflow

一个面向所有人的开源机器学习框架
tensorflow

TensorFlow for R
TensorFlow

Project containig related material for my TensorFlow articles
热门开源项目
活动日历
查看更多
直播时间 2025-04-09 14:34:18

樱花限定季|G-Star校园行&华中师范大学专场
直播时间 2025-04-07 14:51:20

樱花限定季|G-Star校园行&华中农业大学专场
直播时间 2025-03-26 14:30:09

开源工业物联实战!
直播时间 2025-03-25 14:30:17

Heygem.ai数字人超4000颗星火燎原!
直播时间 2025-03-13 18:32:35

全栈自研企业级AI平台:Java核心技术×私有化部署实战
所有评论(0)