pytorch __init__() got an unexpected keyword argument 'train' I'm using this code in colab. the function below gives me an error when intanciar.
import os
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.utils.data as data
import torchvision
from torchvision import transforms
def load_images(image_size=32, batch_size=64, root=&quot;&quot;):
        transform = transforms.Compose([
        transforms.Resize(32),
        transforms.ToTensor(),
        transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

        train_set = torchvision.datasets.ImageFolder(root=root,  train=True,transform=transform)
        train_loader = torch.utils.data.DataLoader(train_set, batch_size=batch_size, shuffle=True, num_workers=2)

        return train_loader

data = load_images (28.64, &quot;/ content / data /&quot;)

error
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-85-a809f71788e0&gt; in &lt;module&gt;()
----&gt; 1 datotes=load_images(28,64,&quot;/content/datitos/&quot;)

&lt;ipython-input-84-0b4989f589a9&gt; in load_images(image_size, batch_size, root)
     15     transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
     16 
---&gt; 17     train_set = torchvision.datasets.ImageFolder(root=root,  train=True,transform=transform)
     18     train_loader = torch.utils.data.DataLoader(train_set, batch_size=batch_size, shuffle=True, num_workers=2)
     19 

TypeError: __init__() got an unexpected keyword argument 'train'
The error implies that it couldn't recognize the train parameter, in the ImageFolder class.
ImageFolder() does not have a parameter train, remove that it will fix the error. Instead of...
train_set = torchvision.datasets.ImageFolder(root=root,  train=True,transform=transform)

...you should have...
train_set = torchvision.datasets.ImageFolder(root=root, transform=transform).

For more check the documentation.