TensorFlow函数(二)tf.get_variable() 和 tf.Variable()

tf.Variable(<initial - value>,name=<optional - name>)

此函数用于定义图变量。生成一个初始值为initial - value的变量。

tf.get_variable(name,shape,dtype,initializer)

此函数用于定义图变量。获取已经存在的变量,如果不存在,就新建一个

参数:

  • name:名称
  • shape:数据形状。
  • dtype:数据类型。常用的tf.float32,tf.float64等数值类型
  • initializer:初始化值。可以使用各种初始化方法

推荐使用:tf.get_variable()

方便共享变量,必须和reusetf.variable_scope()配合使用

猜你喜欢

转载自www.cnblogs.com/reaptomorrow-flydream/p/9486774.html