I have a class of single layer (below) of neural network (Neural_Made) going from one layer to another layer. I want to construct my whole network using this class as a building block. For that I used another class Made to build my whole network. But I am unable to figure out how to do it. Please provide a solution for the query.
class Neural_Made(nn.Linear):
def __init__(self,n,m,exclusive):
super(Neural_Made,self).__init__(n*m*m*m*m,n*m*m*m*m)
self.n=n
self.m=m
self.exclusive=exclusive #exclusive is a boolean
self.in_size=n*m*m*m*m
self.register_buffer('Mask1',torch.ones([self.in_size]*2))
if self.exclusive:
self.Mask1=1-torch.triu(self.Mask1)
else:
self.Mask1=torch.tril(self.Mask1)
nn.init.xavier_uniform_(self.weight.data)
def forward(self,x):
return nn.functional.linear(x,self.Mask1*self.weight,self.bias)
class Made(nn.Module): #This is the main class which is using the above network
def __init__(self,n,m):
super(Made,self).__init__()
self.n=n
self.m=m
Neural_Made(self.n,self.m,exclusive=True)
def forward(self,x):