当前位置: 首页>>代码示例>>Python>>正文


Python Sequential.shape方法代码示例

本文整理汇总了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):
开发者ID:DISCOSUMO,项目名称:postencoder,代码行数:33,代码来源:encoder.py


注:本文中的keras.models.Sequential.shape方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。