运行finetune_and_eval()报错
Created by: ENGWayne
在AIstudio中fork项目,PaddlePaddle 1.7.0,原本项目显示: run_states = task.finetune_and_eval() [2020-03-24 21:09:35,320] [ INFO] - Strategy with scheduler: {'warmup': 0.0, 'linear_decay': {'start_point': 1.0, 'end_learning_rate': 0.0}, 'noam_decay': False, 'discriminative': {'blocks': 0, 'factor': 2.6}, 'gradual_unfreeze': 0, 'slanted_triangle': {'cut_fraction': 0.0, 'ratio': 32}}, regularization: {'L2': 0.001, 'L2SP': 0.0, 'weight_decay': 0.0} and clip: {'GlobalNorm': 0.0, 'Norm': 0.0} [2020-03-24 21:09:42,049] [ INFO] - Try loading checkpoint from cv_finetune_turtorial_demo/ckpt.meta [2020-03-24 21:09:42,050] [ INFO] - PaddleHub model checkpoint not found, start from scratch... [2020-03-24 21:09:42,105] [ INFO] - PaddleHub finetune start [2020-03-24 21:09:44,825] [ TRAIN] - step 10 / 563: loss=0.26938 acc=0.91250 [step/sec: 3.69] [2020-03-24 21:09:47,168] [ TRAIN] - step 20 / 563: loss=0.06502 acc=0.97500 [step/sec: 4.27] [2020-03-24 21:09:49,544] [ TRAIN] - step 30 / 563: loss=0.15980 acc=0.95000 [step/sec: 4.21] [2020-03-24 21:09:51,972] [ TRAIN] - step 40 / 563: loss=0.06811 acc=0.98125 [step/sec: 4.12] [2020-03-24 21:09:54,439] [ TRAIN] - step 50 / 563: loss=0.10210 acc=0.95000 [step/sec: 4.06] [2020-03-24 21:09:54,440] [ INFO] - Evaluation on dev dataset start 2020-03-24 21:09:54,892-WARNING: paddle.fluid.layers.py_reader() may be deprecated in the near future. Please use paddle.fluid.io.DataLoader.from_generator() instead. share_vars_from is set, scope is ignored. [2020-03-24 21:10:13,792] [ EVAL] - [dev dataset evaluation result] loss=0.05826 acc=0.98214 [step/sec: 3.74] [2020-03-24 21:10:13,793] [ EVAL] - best model saved to cv_finetune_turtorial_demo/best_model [best acc=0.98214]
自己fork后运行则显示:
Error Message Summary:
InvalidArgumentError: The number of LearningRate shall not be 0, but received 0. Maybe the Input variable LearningRate has not been initialized. You may need to confirm if you put exe.run(startup_program) after optimizer.minimize function. [Hint: Expected framework::product(lr_dims) != 0, but received framework::product(lr_dims):0 == 0:0.] at (/paddle/paddle/fluid/operators/optimizers/adam_op.cc:77) [operator < adam > error]
原配置策略:
config = hub.RunConfig( use_cuda=True, #是否使用GPU训练,默认为False; num_epoch=1, #Fine-tune的轮数; checkpoint_dir="cv_finetune_turtorial_demo",#模型checkpoint保存路径, 若用户没有指定,程序会自动生成; batch_size=32, #训练的批大小,如果使用GPU,请根据实际情况调整batch_size; eval_interval=50, #模型评估的间隔,默认每100个step评估一次验证集; strategy=hub.finetune.strategy.DefaultFinetuneStrategy()) #Fine-tune优化策略;
调整后的配置策略如下: config = hub.RunConfig( use_cuda=True, #是否使用GPU训练,默认为False; num_epoch=10, #Fine-tune的轮数; checkpoint_dir="cv_finetune_turtorial_demo",#模型checkpoint保存路径, 若用户没有指定,程序会自动生成; batch_size=128, #训练的批大小,如果使用GPU,请根据实际情况调整batch_size; eval_interval=50, #模型评估的间隔,默认每100个step评估一次验证集; strategy=hub.finetune.strategy.DefaultFinetuneStrategy()) #Fine-tune优化策略;