我有
shape=tf.shape(net) s1=tf.cast(shape[2],tf.int32) s2=tf.cast(shape[2]/2,tf.int32) a0=tf.random_normal([s1,s2],mean=0.,stdev=1.) b0 = tf.get_variable(some_name, initializer=a0)
ValueError: initial_value must have a shape specified:
对于线b0=…,我添加了形状信息:
b0 = tf.get_variable(some_name, initializer=a0,shape=[s1,s2])
现在我得到了错误:
If initializer is a constant, do not specify shape.
shape = net.get_shape().as_list()
现在,我得到了错误:
ValueError: None values not supported.
我经历了: How to understand static shape and dynamic shape in TensorFlow?
您需要指定 validate_shape=False 在争论中 tf.get_variable ,例如
validate_shape=False
tf.get_variable
init = tf.random_normal((s1, s2)) tf.get_variable(name, initializer=init, validate_shape=False)