我正在尝试实现CTC LSTM网络,而我的ctc_batch_cost仅返回nan。我不知道如何解决此问题,因此将不胜感激。
我的交易记录图
tf.reset_default_graph()
graph = tf.Graph()
with graph.as_default():
input_dataset = tf.data.Dataset.from_generator(lambda: train_input, tf.float32).padded_batch(batch_size, padded_shapes=([None, num_features]))
input_sequence_len = tf.data.Dataset.from_tensor_slices(seq_lens).batch(batch_size)
output_targets = tf.data.Dataset.from_generator(lambda: labels, tf.int32).padded_batch(batch_size, padded_shapes = ([None]) , padding_values = -1)
output_sequence_len = tf.data.Dataset.from_tensor_slices(out_lens).batch(batch_size)
dataset = tf.data.Dataset.zip((input_dataset, output_targets, input_sequence_len, output_sequence_len))
dataset = dataset.prefetch(10)
iterator=tf.data.Iterator.from_structure(dataset.output_types,dataset.output_shapes)
training_init_op=iterator.make_initializer(dataset)
next_element=iterator.get_next()
train_input_val, target_inputs, seq_len, out_len = next_element
train_inputs = tf.keras.layers.CuDNNLSTM(num_units, return_sequences = True)(train_input_val)
train_inputs = tf.keras.layers.CuDNNLSTM(num_units , return_sequences = True)(train_inputs)
#train_inputs = train_inputs[:, 2:, :] This was suggested at the keras site but it gives me an error
loss = tf.keras.backend.ctc_batch_cost(target_inputs,train_inputs, seq_len, out_len)
cost = tf.reduce_mean(loss)
optimizer = tf.train.MomentumOptimizer(initial_learning_rate, 0.9).minimize(cost)
我的输入数据集是特征尺寸为16的mfcc的22807数组
谢谢您的帮助