Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Github TRN Pytorch模型-运行时错误:维度超出范围(预期在[-1,0]范围内,但得到1)_Github_Pytorch_Pre Trained Model_Torchvision - Fatal编程技术网

Github TRN Pytorch模型-运行时错误:维度超出范围(预期在[-1,0]范围内,但得到1)

Github TRN Pytorch模型-运行时错误:维度超出范围(预期在[-1,0]范围内,但得到1),github,pytorch,pre-trained-model,torchvision,Github,Pytorch,Pre Trained Model,Torchvision,我在colab中使用,pytorch版本是0.4.1。在训练模型时,我得到一个运行时错误:维度超出范围(预计在[-1,0]范围内,但得到1) 这是培训代码 !python3 main.py something RGB \ --arch BNInception --num_segments 3 \ --consensus_type TRN --batch-size 2 我犯了这个错误 storing name:

我在colab中使用,pytorch版本是0.4.1。在训练模型时,我得到一个运行时错误:维度超出范围(预计在[-1,0]范围内,但得到1)

这是培训代码

!python3 main.py something RGB \
                     --arch BNInception --num_segments 3 \
                     --consensus_type TRN --batch-size 2
我犯了这个错误

storing name: TRN_something_RGB_BNInception_TRN_segment3

    Initializing TSN with base model: BNInception.
    TSN Configurations:
        input_modality:     RGB
        num_segments:       3
        new_length:         1
        consensus_module:   TRN
        dropout_ratio:      0.8
        img_feature_dim:    256

/content/drive/My Drive/TRN-pytorch/models.py:87: UserWarning: nn.init.normal is now deprecated in favor of nn.init.normal_.
  normal(self.new_fc.weight, 0, std)
/content/drive/My Drive/TRN-pytorch/models.py:88: UserWarning: nn.init.constant is now deprecated in favor of nn.init.constant_.
  constant(self.new_fc.bias, 0)
video number:4
/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py:208: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
  "please use transforms.Resize instead.")
video number:1
group: first_conv_weight has 1 params, lr_mult: 1, decay_mult: 1
group: first_conv_bias has 1 params, lr_mult: 2, decay_mult: 0
group: normal_weight has 71 params, lr_mult: 1, decay_mult: 1
group: normal_bias has 71 params, lr_mult: 2, decay_mult: 0
group: BN scale/shift has 2 params, lr_mult: 1, decay_mult: 0
Freezing BatchNorm2D except the first one.
Traceback (most recent call last):
  File "main.py", line 324, in <module>
    main()
  File "main.py", line 128, in main
    train(train_loader, model, criterion, optimizer, epoch, log_training)
  File "main.py", line 175, in train
    prec1, prec5 = accuracy(output.data, target, topk=(1,5))
  File "main.py", line 301, in accuracy
    batch_size = target.size(1)
RuntimeError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
存储名称:TRN\u something\u RGB\u bn起始\u TRN\u段3
正在使用基本模型初始化TSN:BNInception。
TSN配置:
输入/输出模式:RGB
分段数:3
新长度:1
共识单元:TRN
辍学率:0.8
图像特征尺寸:256
/content/drive/My drive/TRN pytorch/models.py:87:UserWarning:nn.init.normal现在被弃用,取而代之的是nn.init.normal。
正常(自身新重量,0,标准)
/content/drive/My drive/TRN pytorch/models.py:88:UserWarning:nn.init.constant现在被弃用,取而代之的是nn.init.constant。
常数(自新偏差,0)
视频号码:4
/usr/local/lib/python3.6/dist-packages/torchvision/transforms/transforms.py:208:UserWarning:transforms.Scale-transform不推荐使用,请改用transforms.Resize。
“请使用变换。改为调整大小。”)
视频编号:1
组:第一个转换权重有1个参数,lr\u mult:1,decation\u mult:1
组:第一个转换偏差有1个参数,lr mult:2,衰减mult:0
组:正常体重有71个参数,左重:1,衰减:1
组:正常偏差有71个参数,lr\u倍数:2,衰减倍数:0
组:BN刻度/移位有2个参数,lrμm:1,衰减μm:0
除第一个外,其他的都是2D。
回溯(最近一次呼叫最后一次):
文件“main.py”,第324行,在
main()
文件“main.py”,第128行,在main中
列车(列车装载机、模型、标准、优化器、历元、日志培训)
列车中第175行的文件“main.py”
prec1,prec5=精度(输出数据,目标,topk=(1,5))
文件“main.py”,第301行,精确
批次大小=目标大小(1)
RuntimeError:维度超出范围(预期范围为[-1,0],但得到1)
main.py文件是

帮我解决这个问题