CNTK中的sequence.pad_sequences(keras)等效项是什么

时间:2018-07-10 04:19:21

标签: python deep-learning lstm cntk

所以我用Keras建立了一个LSTM分类模型。

这是我的模特的片段:

x_train = sequence.pad_sequences(procprinters, maxlen = 18, padding='post', truncating='post')
x_test = sequence.pad_sequences(procprinters, maxlen = 18,  padding='post', truncating='post')



x_train = array(x_train)
print(x_train.shape)
procclass = array(printerclassifcation)

permutations = np.random.permutation(procclass.shape[0])
x_train = x_train[permutations]
y_train = procclass[permutations]



print('Build model...')
model = Sequential()
model.add(Embedding(37, 128))
model.add(LSTM(128, dropout=0.1))
model.add(Dense(1, activation='sigmoid'))

model.compile(loss = 'binary_crossentropy', optimizer = 'adam', metrics=['acc'])
model.fit(x_train,y_train, validation_split = 0.2, batch_size=5, epoch

上面的代码本质上在我的X_train and y_train的前面加了0,长度为18。然后将其传递给模型进行训练。 现在,我希望对CNTK进行同样的处理。我无法在线阅读文档。有人可以帮我弄清楚我的脚垫吗?

x_train
y_train

当我使用Keras时。任何帮助或指导表示赞赏!

0 个答案:

没有答案