New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在miniImageNet数据集上运行RENet等报错 #63
Comments
Please ensure that you have pull the latest commit ee25973, we have fix this problem in this version. |
在我的版本中已经修改为了 |
感谢您的回答! batch:([tensor([[[[ 0.4896, 0.9282, 0.9423, ..., -1.3355, -1.6043, -1.3638], trainer.py:375
|
你好,我按照下面的步骤尝试训练renet,但没有报错,或许可以供你参考: git clone https://github.com/RL-VIG/LibFewShot.git LibFewShot_ee25973
cd LibFewShot_ee25973
# 修改renet.config 和 run_trainer.py |
十分感谢,未找到renet.config,请问是config/classifiers/RENet.yaml吗? |
是config/renet.yaml,刚刚写错了,抱歉。 |
非常感谢,经过多次尝试,使用Conv64F可以正常使用,但是使用resnet18无法跑通。感谢帮助 |
换Backbone的话需要对应修改分类头参数,分类头参数可以推导或者参考原文,可以附上更详细的报错信息供我们提供解决方案。 |
(torchLFS) [inspur@localhost LibFewShot-main]$ python run_trainer.py
[11/14/22 10:04:36] INFO {'data_root': '/home/inspur/MAX_SPACE/Jiyu/LibFewShot-main/dataset_floder/miniImgFSL', 'image_size': 84, 'use_memory': False, 'augment': trainer.py:372
False, 'augment_times': 1, 'augment_times_query': 1, 'workers': 2, 'dataloader_num': 1, 'device_ids': 0, 'n_gpu': 1, 'seed': 2147483647,
'deterministic': True, 'port': 53758, 'log_name': None, 'log_level': 'info', 'log_interval': 100, 'log_paramerter': False, 'result_root':
'./results', 'save_interval': 10, 'save_part': ['emb_func'], 'tag': None, 'epoch': 5, 'test_epoch': 5, 'parallel_part': ['emb_func'],
'pretrain_path': None, 'resume': False, 'way_num': 5, 'shot_num': 1, 'query_num': 15, 'test_way': 5, 'test_shot': 1, 'test_query': 15,
'episode_size': 1, 'train_episode': 100, 'test_episode': 100, 'batch_size': 128, 'val_per_epoch': 1, 'optimizer': {'name': 'Adam',
'kwargs': {'lr': 0.01}, 'other': None}, 'lr_scheduler': {'name': 'StepLR', 'kwargs': {'gamma': 1.0, 'step_size': 20}}, 'warmup': 0,
'includes': ['headers/data.yaml', 'headers/device.yaml', 'headers/misc.yaml', 'headers/model.yaml', 'headers/optimizer.yaml',
'classifiers/RENet.yaml', 'backbones/resnet18.yaml'], 'classifier': {'name': 'RENet', 'kwargs': {'feat_dim': 512, 'lambda_epi': 0.25,
'temperature': 0.2, 'temperature_attn': 5.0, 'num_classes': 2}}, 'backbone': {'name': 'resnet18', 'kwargs': {'is_feature': False,
'avg_pool': True, 'is_flatten': True}}, 'tb_scale': 1.0, 'rank': 0}
[11/14/22 10:04:37] INFO RENet( trainer.py:372
(emb_func): ResNet(
(conv1): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(layer1): Sequential(
(0): BasicBlock(
(conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(1): BasicBlock(
(conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(layer2): Sequential(
(0): BasicBlock(
(conv1): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(downsample): Sequential(
(0): Conv2d(64, 128, kernel_size=(1, 1), stride=(2, 2), bias=False)
(1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(1): BasicBlock(
(conv1): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(layer3): Sequential(
(0): BasicBlock(
(conv1): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(downsample): Sequential(
(0): Conv2d(128, 256, kernel_size=(1, 1), stride=(2, 2), bias=False)
(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(1): BasicBlock(
(conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(layer4): Sequential(
(0): BasicBlock(
(conv1): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(downsample): Sequential(
(0): Conv2d(256, 512, kernel_size=(1, 1), stride=(2, 2), bias=False)
(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(1): BasicBlock(
(conv1): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))
)
(fc): Linear(in_features=512, out_features=2, bias=True)
(scr_layer): SCRLayer(
(model): Sequential(
(0): SelfCorrelationComputation(
(unfold): Unfold(kernel_size=(5, 5), dilation=1, padding=2, stride=1)
(relu): ReLU()
)
(1): SCR(
(conv1x1_in): Sequential(
(0): Conv2d(512, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace=True)
)
(conv1): Sequential(
(0): Conv3d(64, 64, kernel_size=(1, 3, 3), stride=(1, 1, 1), bias=False)
(1): BatchNorm3d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace=True)
)
(conv2): Sequential(
(0): Conv3d(64, 64, kernel_size=(1, 3, 3), stride=(1, 1, 1), bias=False)
(1): BatchNorm3d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace=True)
)
(conv1x1_out): Sequential(
(0): Conv2d(64, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
)
)
)
(cca_layer): CCALayer(
(cca_module): CCA(
(conv): Sequential(
(0): SepConv4d(
(proj): Sequential(
(0): Conv2d(1, 16, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(conv1): Sequential(
(0): Conv3d(1, 1, kernel_size=(1, 3, 3), stride=(1, 1, 1), padding=(0, 1, 1), bias=False)
(1): BatchNorm3d(1, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(conv2): Sequential(
(0): Conv3d(1, 1, kernel_size=(3, 3, 1), stride=(1, 1, 1), padding=(1, 1, 0), bias=False)
(1): BatchNorm3d(1, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(relu): ReLU(inplace=True)
)
(1): ReLU(inplace=True)
(2): SepConv4d(
(proj): Sequential(
(0): Conv2d(16, 1, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(1, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(conv1): Sequential(
(0): Conv3d(16, 16, kernel_size=(1, 3, 3), stride=(1, 1, 1), padding=(0, 1, 1), bias=False)
(1): BatchNorm3d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(conv2): Sequential(
(0): Conv3d(16, 16, kernel_size=(3, 3, 1), stride=(1, 1, 1), padding=(1, 1, 0), bias=False)
(1): BatchNorm3d(16, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
)
(relu): ReLU(inplace=True)
)
)
)
(cca_1x1): Sequential(
(0): Conv2d(512, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)
(1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
)
)
(loss_func): CrossEntropyLoss()
)
INFO Trainable params in the model: 11348186 trainer.py:372
[11/14/22 10:04:40] INFO load 38400 train image with 64 label. trainer.py:372
INFO load 9600 val image with 16 label. trainer.py:372
INFO load 12000 test image with 20 label. trainer.py:372
INFO Adam ( trainer.py:372
Parameter Group 0
amsgrad: False
betas: (0.9, 0.999)
eps: 1e-08
initial_lr: 0.01
lr: 0.01
weight_decay: 0
)
INFO ============ Train on the train set ============ trainer.py:372
INFO learning rate: [0.01] trainer.py:372
Traceback (most recent call last):
File "run_trainer.py", line 24, in
main(0, config)
File "run_trainer.py", line 14, in main
trainer.train_loop(rank)
File "/home/inspur/MAX_SPACE/Jiyu/LibFewShot-main/core/trainer.py", line 83, in train_loop
train_acc = self._train(epoch_idx)
File "/home/inspur/MAX_SPACE/Jiyu/LibFewShot-main/core/trainer.py", line 170, in _train
[elem for each_batch in batch for elem in each_batch]
File "/home/inspur/anaconda3/envs/torchLFS/lib/python3.7/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/inspur/MAX_SPACE/Jiyu/LibFewShot-main/core/model/abstract_model.py", line 30, in forward
return self.set_forward_loss(x)
File "/home/inspur/MAX_SPACE/Jiyu/LibFewShot-main/core/model/finetuning/renet.py", line 415, in set_forward_loss
) = batch # RENet uses both episode and general dataloaders
ValueError: not enough values to unpack (expected 4, got 2)
The text was updated successfully, but these errors were encountered: