我尝试用动态形状创建一个tf.Variable.以下概述了该问题.
这样做有效.
init_bias = tf.random_uniform(shape=[self.config.hidden_layer_size, tf.shape(self.question_inputs)[0]])
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试这样做时:
init_bias = tf.Variable(init_bias)
Run Code Online (Sandbox Code Playgroud)
它抛出错误ValueError:initial_value必须具有指定的形状:Tensor("random_uniform:0",shape =(?,?),dtype = float32)
刚来上下文(问题输入是动态批处理的占位符):
self.question_inputs = tf.placeholder(tf.int32, shape=[None, self.config.qmax])
Run Code Online (Sandbox Code Playgroud)
似乎将动态值置于随机均匀中给出shape =(?,?),这给出了tf.Variable的错误.
谢谢,感谢任何帮助!
tensorflow ×1