0
点赞
收藏
分享

微信扫一扫

用一个自定义的数组初始化tensorflow variable

罗子僧 2022-08-01 阅读 114


import tensorflow as tf
tf.enable_eager_execution()

value = [0, 1, 2, 3, 4, 5, 6, 7]
init = tf.constant_initializer(value)
x = tf.get_variable('x', shape=[8], initializer=init)
print(x)

打印结果:

<tf.Variable ‘x:0’ shape=(8,) dtype=float32, numpy=array([0., 1., 2., 3., 4., 5., 6., 7.], dtype=float32)>


举报

相关推荐

0 条评论