我有一个input_node
,形状为(None, 80, 3)
,意思是(sample_length, resolution, channel)
。但是,该张量缺少批次的第四个维度。有没有办法将input_node
重塑为(None, None, 80, 3)
?
我无法使用tf.expand_dims
处理批处理:
wave_input = tf.placeholder(dtype=tf.float32, shape=[None], name='wave_input')
encoded_dict = problem.preprocess_example({'waveforms': wave_input, 'targets': [0]}, mode, hparams)
# This is where a dynamic shape would be required
encoded_dict['inputs'] = tf.expand_dims(encoded_dict['inputs'], 0)
encoded_dict['targets'] = tf.expand_dims(encoded_dict['targets'], 0)
# Get input/output nodes
inferred = model.infer(encoded_dict)
tf.identity(encoded_dict['inputs'], name=input_name)
tf.identity(inferred['outputs'], name=output_name)