In order to print the initial loss of my network (before training), I want to feed the entire data set into my network like this:
loss_train = np.zeros(epochs+1) accu_train = np.zeros(epochs+1) # initial loss output = model(batches_train.dataset.data) # batches_train is dataloader targets = batches_train.dataset.targets loss_train = criterion(output, targets).detach()
The problem is that this gives the original dataset without the transformations that were specified in the creation of the dataloader. For example, if I specified the
transforms.ToTensor() operation for the dataloader, my code will complain that the model( ) does not accept np.arrays as input.
Is there a cheap way to fix this? I could easily just iterate over all the batches, but I was wondering whether one can do without a for-loop.