Creating a fully connected model

A simple model may end in overfitting, so let's include dropout in the model. Dropout will help avoid overfitting. In the following code, we are creating our model:

class FullyConnectedModel(nn.Module):

def __init__(self,in_size,out_size,training=True):
super().__init__()
self.fc = nn.Linear(in_size,out_size)

def forward(self,inp):
out = F.dropout(inp, training=self.training)
out = self.fc(out)
return out

# The size of the output from the selected convolution feature
fc_in_size = 131072

fc = FullyConnectedModel(fc_in_size,classes)
if is_cuda:
fc = fc.cuda()

Once the model is created, we can train the model.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.254.192