train-model.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:FaceDetection 作者: youssefhb 项目源码 文件源码
def resume_training_from_snapshot(weights_file,callbacks_list,initialEpoch=0):

    model = create_model()
    sgd = SGD(lr=0.01, decay=0.0004, momentum=0.9, nesterov=True)

    # learning schedule callback
    lrate = LearningRateScheduler(step_decay)

    print "Loads weights from a snapshot"
    # Loads parameters from a snapshot
    model.load_weights(weights_file)

    print "compliling the model"
    model.compile(optimizer=sgd,loss=class_mode+'_crossentropy',metrics=['accuracy'])

    model.summary()

    train_generator,validation_generator = generateData()


    # initial_epoch: Epoch at which to start training (useful for resuming a previous training run)
    # teps_per_epoch: Total number of steps (batches of samples) to yield from generator 
    # before declaring one epoch finished and starting the next epoch. 
    # It should typically be equal to the number of unique samples of your dataset divided by the batch size.
    history = model.fit_generator(train_generator,
                        steps_per_epoch=614,
                        validation_data=validation_generator,
                        validation_steps=20,
                        epochs=1000,callbacks=callbacks_list,
                        verbose=1,initial_epoch=initialEpoch)

    saveModel(model)






# =================================================
#                       M A I N
# =================================================
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号