Stack : expects each tensor to be equal size but got:[3,78,224,224] and [3,106,224,224]

username: amy2
cooked: <p>I have this script and I want to remove all  data transformation<br>
this is the original one</p>
<pre><code class="lang-auto">def get_train_utils(opt, model_parameters):
    assert opt.train_crop in ['random', 'corner', 'center']
  
    spatial_transform = []
        
#-----------                ----------------#    
    if opt.train_crop == 'random':
        spatial_transform.append(
            RandomResizedCrop(
                opt.sample_size, (opt.train_crop_min_scale, 1.0),
                (opt.train_crop_min_ratio, 1.0 / opt.train_crop_min_ratio)))
    elif opt.train_crop == 'corner':
        scales = [1.0]
        scale_step = 1 / (2**(1 / 4))
        for _ in range(1, 5):
            scales.append(scales[-1] * scale_step)
        spatial_transform.append(MultiScaleCornerCrop(opt.sample_size, scales))
    if opt.train_crop == 'center':
        spatial_transform.append(Resize(opt.sample_size))
        spatial_transform.append(CenterCrop(opt.sample_size))
        normalize = get_normalize_method(opt.mean, opt.std, opt.no_mean_norm,
                                     opt.no_std_norm)
    if not opt.no_hflip:
        spatial_transform.append(RandomHorizontalFlip())
    if opt.colorjitter:
        spatial_transform.append(ColorJitter())
    spatial_transform.append(ToTensor())
   if opt.input_type == 'flow':
        spatial_transform.append(PickFirstChannels(n=2))
    spatial_transform.append(ScaleValue(opt.value_scale))
    spatial_transform.append(normalize)
    
    spatial_transform = Compose(spatial_transform)

    assert opt.train_t_crop in ['random', 'center']
    temporal_transform = []
    if opt.sample_t_stride &gt; 1:
        temporal_transform.append(TemporalSubsampling(opt.sample_t_stride))
    if opt.train_t_crop == 'random':
        temporal_transform.append(TemporalRandomCrop(opt.sample_duration))
    elif opt.train_t_crop == 'center':
        temporal_transform.append(TemporalCenterCrop(opt.sample_duration))
#-------                           ----------#

    temporal_transform = TemporalCompose(temporal_transform)

    train_data = get_training_data(opt.video_path, opt.annotation_path,
                                   opt.dataset, opt.input_type, opt.file_type,
                                   spatial_transform, temporal_transform= None )
</code></pre>
<p>I made this modifications and got</p>
<pre><code class="lang-auto">    spatial_transform = []
    normalize = get_normalize_method(opt.mean, opt.std, opt.no_mean_norm,
                                 opt.no_std_norm)
    spatial_transform.append(Resize(opt.sample_size))
    spatial_transform.append(CenterCrop(opt.sample_size))
    spatial_transform.append(ToTensor())
   spatial_transform.append(ScaleValue(opt.value_scale))
    spatial_transform.append(normalize)
    spatial_transform = Compose(spatial_transform)
</code></pre>
<p>when trying it I got the above error<br>
I think it’s related to the normalize method<br>
I didn’t know where to placed it ?<br>
Ps: there is a separate spatial_transform.py and temporal_transform.py<br>
Any suggestions please</p>