Currently I’m having this probelm (using simple neural network) , please let me know what am I missing.
import torch
import torch.nn as nn
import torch.nn.functional as f
from torch.autograd import Variable
import numpy as np
import torchvision.datasets as dset
import torchvision.transforms as transforms
import torchvision
import livelossplot
import matplotlib.pyplot as plt
from fastai.vision import *class mymodel(nn.Module):
“”" Architecture of the Generator, uses res-blocks “”"def __init__(self,pretrained=False): super(mymodel, self).__init__() self.body=nn.Sequential( nn.Conv2d(3, 4, kernel_size=5, stride=4*252), nn.ReLU(), ) self.fc=nn.Linear(256,4) def forward(self, x): x=self.body(x) x=x.view(-1,1) x.squeeze_(1) x=self.fc(x) x.unsqueeze_(-1) print(x.shape) return x
np.random.seed(42)
data = ImageDataBunch.from_folder(path, train=“.”, valid_pct=0.2,
ds_tfms=get_transforms(), size=256, num_workers=4).normalize(imagenet_stats)learn = Learner(data, mymodel(),metrics=accuracy)
learn.fit_one_cycle(1)