对于一个可迭代的(iterable)/可遍历的对象(如列表、字符串),enumerate将其组成一个索引序列,利用它可以同时获得索引和值
list1 = [“这”, “是”, “一个”, “测试”]
for index, item in enumerate(list1):
print index, item
0 这
1 是
2 一个
3 测试
str.strip的作用是去掉字符串首尾的空格
5e-4相当于5乘以10的-4次
@rishabhiitbhu so fold=0 means fold number 0? Could you please explain how does it work? I am new to this. So fold=0 means we training on first 20% of data? Thanks again, sorry for silly questions.
fold=0是什么意思?
Yup, fold=0, total_folds=5, is passed to provider which uses sklearn’s StratifiedKFold class to divide the data in 5 folds, takes four folds in training data and 1 fold for validation i.e., training: 80% validation: 20%. When you have such doubts just run the code, use some print functions, see what’s going in what’s coming out, matrix shapes etc, that’s how I learn too 😃
为什么Dataset指向data,因为Dataset实现了getitem方法
对于DataLoader来说,既没有指定batch_sampler也没有指定sampler,则使用使用Pytorch已经实现好的BatchSampler,而sampler根据shuffle分为两种情况
optimizer.zero_grad()每一个epoch清零一次梯度
自己实现的Dataset类需要覆盖两个方法,一个是getitem另一个是len,这里的len将被sampler使用,用来产生indices,保证gettiem方法不越界
np.nanmean() 忽略nan项取平均
python csv操作教程 https://www.youtube.com/watch?v=s1XiCh-mGCA
如果pros的shape是[4, 512, 512]
for pro in pros:
那么 pro的shape是[512, 512]
python填坑记录
最新推荐文章于 2022-04-14 23:44:33 发布