clovaai / voxceleb_trainer

In defence of metric learning for speaker recognition
MIT License
1.03k stars 272 forks source link

View size is not compatible with input tensor's size #84

Closed surasakBoonkla closed 3 years ago

surasakBoonkla commented 3 years ago

When I ran the train script, I got this error.

File "/opt/voxceleb_trainer-master/utils.py", line 18, in accuracy correct_k = correct[:k].view(-1).contiguous().float().sum(0, keepdim=True) RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

How to use reshape() to fix this problem?

joonson commented 3 years ago

Can you share your Python and Pytorch versions, and the training arguments?

surasakBoonkla commented 3 years ago

I used Python 3.6.9 and print(torch.version) >>> 1.7.0

The training command was

python3 ./trainSpeakerNet.py --model ResNetSE34L --log_input True --encoder_type SAP --trainfunc angleproto --save_path exps/exp2 --nPerSpeaker 2 --batch_size 200

Some outputs were

Embedding size is 512, encoder SAP. Initialised AngleProto Initialised Adam optimizer Initialised step LR scheduler config None max_frames 200 eval_frames 300 batch_size 200 max_seg_per_spk 100 nDataLoaderThread 5 augment False test_interval 10 max_epoch 500 trainfunc angleproto optimizer adam scheduler steplr lr 0.001 lr_decay 0.95 weight_decay 0 hard_prob 0.5 hard_rank 10 margin 1 scale 15 nPerSpeaker 2 nClasses 4391 initial_model save_path exps/exp2 train_list train_list_4391.txt test_list veri_test.txt train_path ../data/voxceleb2 test_path ../data/voxceleb1 musan_path ../data/musan_split rir_path ../data/RIRS_NOISES/simulated_rirs n_mels 40 log_input True model ResNetSE34L encoder_type SAP nOut 512 eval False

surasakBoonkla commented 3 years ago

I fixed the problem by adding .contiguous() in utils.py ... correct = pred.eq(target.view(1, -1).expand_as(pred)).contiguous() ...

joonson commented 3 years ago

I cannot reproduce the error, even without the suggested changes. My torch version is 1.7.0.