本文整理汇总了Python中keras.models.Sequential.shape方法的典型用法代码示例。如果您正苦于以下问题:Python Sequential.shape方法的具体用法?Python Sequential.shape怎么用?Python Sequential.shape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras.models.Sequential
的用法示例。
在下文中一共展示了Sequential.shape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: chunks
# 需要导入模块: from keras.models import Sequential [as 别名]
# 或者: from keras.models.Sequential import shape [as 别名]
#leave out possible long anomalies
X_train = X_train[:int(len(X_train)*0.97)]
Y_train = Y_train[:int(len(Y_train)*0.97)]
batches_X,batches_Y = chunks(X_train,Y_train, 30000)
print('Building model...')
model = Sequential()
model.add(Embedding(max_features_X, embedding_size, mask_zero=True))
for l in range(nb_layers):
model.add(LSTM(embedding_size, hidden_size, return_sequences=True))
model.add(TimeDistributedDense(hidden_size,max_features_Y))
model.add(Activation('time_distributed_softmax'))
if os.path.exists(fdir+'/weights.hdf5'):
model.load_weights(fdir+'/weights.hdf5')
print (model.shape())
rmsprop=RMSprop(lr=0.0002, rho=0.99, epsilon=1e-8, clipnorm=5)
model.compile(loss='categorical_crossentropy', optimizer='rmsprop')
if (mode =='train'):
#save all checkpoints
checkpointer = ModelCheckpoint(filepath=fdir+"/weights.hdf5", verbose=1, save_best_only=False)
history = LossHistory()
sample = Sample()
print("Training...")
for e in range(nb_epoch):
print("epoch %d" % e)
#for X_batch,Y_batch in zip(batches_X,batches_Y):
for i, batch in enumerate(batches_X):