ValueError:如果初始值设定项是常量,请不要指定形状

时间:2017-10-30 18:23:42

标签: tensorflow theano tensorflow-gpu

我已经将theano模型中的权重和偏差读作numpy数组:

w1 = np.zeros((3,3,3,100))
w1 = tf.convert_to_tensor(w1,tf.float32)
w = tf.get_variable('get_variable', dtype=tf.float32, initializer=w1)

net['left'] = tf.contrib.layers.convolution2d(
        inputs=input_l,
        num_outputs=100,
        kernel_size=kernel_size,
        weights_initializer=w,
        padding='SAME',
        data_format='NCHW',
    )

当我收到以下错误时,我必须更改 w

ValueError: If initializer is a constant, do not specify shape.

编辑:

这对我有用:

layer1 = tf.nn.conv2d(t_in_left, w, strides=[1,1,1,1], padding='SAME')

0 个答案:

没有答案