Closed YimanZhanguk closed 1 year ago
您好,在跑这个代码的时候,因为rnn_cell.linear被移除,所以我手动加了一段linear(),但是却有报错……代码如下: def linear(input, output_size, scope=None): print('linear') input_tensor = tf.convert_totensor(input) shape = input_tensor.get_shape().as_list() if len(shape) != 2: raise ValueError("Linear is expecting 2D arguments: %s" % str(shape)) if not shape[1]: raise ValueError("Linear expects shape[1] of arguments: %s" % str(shape)) input_size = shape[1]
# Now the computation. with tf.variable_scope(scope or "SimpleLinear"): matrix = tf.get_variable("Matrix", [output_size, input_size], dtype=input_tensor.dtype) bias_term = tf.get_variable("Bias", [output_size], dtype=input_tensor.dtype) return tf.matmul(input_, tf.transpose(matrix)) + bias_term
报错: in linear(input_, output_size, scope) 4 shape = input_tensor.get_shape().as_list() 5 if len(shape) != 2: ----> 6 raise ValueError("Linear is expecting 2D arguments: %s" % str(shape)) 7 if not shape[1]: 8 raise ValueError("Linear expects shape[1] of arguments: %s" % str(shape))
ValueError: Linear is expecting 2D arguments: [2, None, 512]
.....请问这个linear是哪里不对吗……和原本的rnn_cell._linear 应该是一样的呀………………
= =不好意思啊我解决了………………谢谢了…………………………
您好,我现在也在跑这个程序,出了点问题,我可以加您微信问您一下吗?如果您有空的话希望能加我~微信:15001289758 谢谢!!!!
您好,在跑这个代码的时候,因为rnn_cell.linear被移除,所以我手动加了一段linear(),但是却有报错……代码如下: def linear(input, output_size, scope=None):
print('linear') input_tensor = tf.convert_totensor(input) shape = input_tensor.get_shape().as_list()
if len(shape) != 2:
raise ValueError("Linear is expecting 2D arguments: %s" % str(shape))
if not shape[1]:
raise ValueError("Linear expects shape[1] of arguments: %s" % str(shape))
input_size = shape[1]
报错: in linear(input_, output_size, scope)
4 shape = input_tensor.get_shape().as_list()
5 if len(shape) != 2:
----> 6 raise ValueError("Linear is expecting 2D arguments: %s" % str(shape))
7 if not shape[1]:
8 raise ValueError("Linear expects shape[1] of arguments: %s" % str(shape))
ValueError: Linear is expecting 2D arguments: [2, None, 512]
.....请问这个linear是哪里不对吗……和原本的rnn_cell._linear 应该是一样的呀………………