赞
踩
用来添加一个索引
- >>>seasons = ['Spring', 'Summer', 'Fall', 'Winter']
- >>> list(enumerate(seasons))
- [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]
- >>> list(enumerate(seasons, start=1)) # 下标从 1 开始
- [(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]
比如循环
- >>>seq = ['one', 'two', 'three']
- >>> for i, element in enumerate(seq):
- ... print i, element
- ...
- 0 one
- 1 two
- 2 three
深度学习批量学习
step就是索引
- for epoch in range(3):
- for step, (batch_x, batch_y) in enumerate(loader):
- # 训练
- print('Epoch: ', epoch, '| Step: ', step, '| batch x: ',
- batch_x.numpy(), '| batch y: ', batch_y.numpy())
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。