Actually, I plan to do a machine translation project with this seq2seq module. Before that, I just did a simple test and got a very bad result. I don't know where goes wrong. Pls help me...
Here's the process:
#1. traning set
def generate_sequence(length, n_unique):
return [randint(1, n_unique-1) for _ in range(length)]
x = np.array(generate_sequence(100000,100)).reshape(10000,10)
y = np.array(generate_sequence(50000,100)).reshape(10000,5)
x_encoder_input_data = to_categorical(x)
y_decoder_target_data = to_categorical(y)
#x_encoder_input_data.shape = (10000, 10, 100)
#10000 training data, x_input_length=10,x_input_dim=100
#y_decoder_target_data.shape = (10000, 5, 100)
for seq_index in range(6):
predictions = model.predict(x_encoder_input_data[seq_index:seq_index+1])
predicted_list=[]
for prediction_vector in predictions:
for pred in prediction_vector:
next_token = np.argmax(pred)
predicted_list.append(next_token)
print('-')
print('Input sentence:', X[seq_index])
print('Decoded sentence:', predicted_list)
print('Target sentence:', y[seq_index])
Actually, I plan to do a machine translation project with this seq2seq module. Before that, I just did a simple test and got a very bad result. I don't know where goes wrong. Pls help me... Here's the process:
#1. traning set
#2. building&training model
#3. the partial losses
#4. predicting
#5. the predicting results: