Assert data_tensor.size(0) == target_tensor.size(0) TypeError: 'int' object is not callable

Hello,

l would like to get my dataset into Pytroch to train a resnet.

My actual data are in numpy

import numpy as np
import torch.utils.data as data_utils
data_train=np.random.random((1000,1,32,32))
labels_train=np.random.randint(10,size=1000)
train = data_utils.TensorDataset(data_train, labels_train)

l get the following error

torch/utils/data/dataset.py", line 34, in __init__
    assert data_tensor.size(0) == target_tensor.size(0)
TypeError: 'int' object is not callable

even if
data_train.shape[0] == labels_train.shape[0] have the same dimension

What is wrong with my code ?
TypeError: ‘int’ object is not callable

It’s called TensorDataset. So you should wrap data_train and labels_train in tensors before constructing the dataset. NumPy arrays’ .size is an int. PyTorch tensors’ .size is a method.