【发布时间】:2020-11-16 09:19:12
【问题描述】:
我有一个形状为 (3, None, 80, 10) 的张量,我想将其重塑为 (3*None, 80, 10)。我尝试使用以下代码行,但没有得到所需的形状 (3*None, 80, 10),我得到了一个形状为 (None, None, None) 的张量:
shape = [tf.shape(node_embed_tmp)[k] for k in range(4)]
Y = tf.reshape(node_embed_tmp, [shape[0]*shape[1], shape[2], shape[3]])
任何建议,请!
编辑:
我也试过下面的代码:
shape = [tf.shape(node_embed_tmp)[k] for k in range(4)]
Y=tf.reshape(node_embed_tmp, [-1, shape[2], shape[3]])
但我得到了(None, None, None) 的形状和以下错误:ValueError: Input size (depth of inputs) must be accessible via shape inference, but saw value None.
【问题讨论】:
-
你在看 model.summary() 吗?尝试用实际数据调用模型
-
3*None没有任何意义。你为什么要那个?你的意思是(3,80,10)? -
我是 Tensorflow 的新手,我正在寻找通过以下代码行在上述张量上使用 LSTM
lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(embedding_u_size) # init_state = cell.zero_state(None, dtype=tf.float32) node_type_embed, _ = tf.nn.dynamic_rnn(lstm_cell, Y, time_major= True, dtype=tf.float32),我认为在这种情况下我不能使用 model.summary() 它是不是 keras 层。 -
@Ragnar 3维表示某个类别的数据,None维表示每个类别的batch_size
-
我想你想要的是
(None, 80, 10, 3)
标签: python tensorflow tensor