本文整理汇总了Python中models.crnn.state_dict方法的典型用法代码示例。如果您正苦于以下问题:Python crnn.state_dict方法的具体用法?Python crnn.state_dict怎么用?Python crnn.state_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.crnn
的用法示例。
在下文中一共展示了crnn.state_dict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: training
# 需要导入模块: from models import crnn [as 别名]
# 或者: from models.crnn import state_dict [as 别名]
def training(start):
for total_steps in range(start, params.niter):
train_iter = iter(train_loader)
i = 0
print(len(train_loader))
while i < len(train_loader):
for p in crnn.parameters():
p.requires_grad = True
crnn.train()
cost = trainBatch(crnn, criterion, optimizer, train_iter)
loss_avg.add(cost)
i += 1
if i % params.displayInterval == 0:
print('[%d/%d][%d/%d] Loss: %f' %
(total_steps, params.niter, i, len(train_loader), loss_avg.val()))
loss_avg.reset()
if i % params.valInterval == 0:
val(crnn, test_dataset, criterion)
if (total_steps + 1) % params.saveInterval == 0:
# if i % params.valInterval == 0:
print('save model ..........')
ti = time.strftime('%Y-%m-%d', time.localtime(time.time()))
torch.save(crnn.state_dict(),
'{0}/crnn_Rec_done_{1}_{2}.pth'.format(params.experiment, total_steps, ti))
print('save model done')