如何使用Keras或Tensorflow在MLP中使用不同长度的输入和输出数据?

时间:2019-03-22 08:42:52

标签: python tensorflow machine-learning keras neural-network

我想知道如何将不同长度的数据输入到多层感知器并获得不同长度的输出数据。假设我想按以下所示的方式分别(而不是成批)拟合数据。你有什么想法?

transfer

input_sentence:

model = Sequential()
model.add(Dense(units=len(input_sentence), activation='relu', input_dim=1))
model.add(Dense(units=len(output_sentence), activation='softmax'))

model.compile(loss='sparse_categorical_crossentropy',
              optimizer='sgd',
              metrics=['accuracy'])

model.fit(input_sentence, output_sentence, epochs=10)

output_sentence:

['1','2','3','4']

input_sentence:

['15','21','32','45']

output_sentence:

['2','3','4']

0 个答案:

没有答案