waleedka / hiddenlayer

Neural network graphs and training metrics for PyTorch, Tensorflow, and Keras.
MIT License
1.79k stars 266 forks source link

passing model args problem #40

Closed jecampagne closed 5 years ago

jecampagne commented 5 years ago

Hi! I have a network using convolutionnal and fully connected layers (nothing very new indeed :) ) in torch

img_channels = 5 img_H = 64 img_W = 64 n_batchs = 1 model = Net(img_channels) imgs = torch.zeros([n_batchs, img_channels,img_H ,img_W]) reds = torch.zeros([n_batchs,1])

When I call it model(imgs,reds) I get the correct layer tensor sahpe input shape: torch.Size([1, 5, 64, 64]) conv0 shape: torch.Size([1, 64, 64, 64]) conv0p shape: torch.Size([1, 64, 32, 32])

i0:START <<<<<<< Inception x_s1_0 : torch.Size([1, 48, 32, 32]) Inception x_s2_0 : torch.Size([1, 64, 32, 32]) Inception x_s1_2 : torch.Size([1, 48, 32, 32]) Inception x_pool0 : torch.Size([1, 48, 32, 32]) Inception x_s1_1 : torch.Size([1, 48, 32, 32]) Inception x_s2_1 : torch.Size([1, 64, 32, 32]) Inception x_s2_2 : torch.Size([1, 64, 32, 32]) Inception output : torch.Size([1, 240, 32, 32]) i1:START <<<<<<< Inception x_s1_0 : torch.Size([1, 64, 32, 32]) Inception x_s2_0 : torch.Size([1, 92, 32, 32]) Inception x_s1_2 : torch.Size([1, 64, 32, 32]) Inception x_pool0 : torch.Size([1, 64, 32, 32]) Inception x_s1_1 : torch.Size([1, 64, 32, 32]) Inception x_s2_1 : torch.Size([1, 92, 32, 32]) Inception x_s2_2 : torch.Size([1, 92, 32, 32]) Inception output : torch.Size([1, 340, 32, 32]) i1p shape: torch.Size([1, 340, 16, 16]) i2:START <<<<<<< Inception x_s1_0 : torch.Size([1, 92, 16, 16]) Inception x_s2_0 : torch.Size([1, 128, 16, 16]) Inception x_s1_2 : torch.Size([1, 92, 16, 16]) Inception x_pool0 : torch.Size([1, 92, 16, 16]) Inception x_s1_1 : torch.Size([1, 92, 16, 16]) Inception x_s2_1 : torch.Size([1, 128, 16, 16]) Inception x_s2_2 : torch.Size([1, 128, 16, 16]) Inception output : torch.Size([1, 476, 16, 16]) i3:START <<<<<<< Inception x_s1_0 : torch.Size([1, 92, 16, 16]) Inception x_s2_0 : torch.Size([1, 128, 16, 16]) Inception x_s1_2 : torch.Size([1, 92, 16, 16]) Inception x_pool0 : torch.Size([1, 92, 16, 16]) Inception x_s1_1 : torch.Size([1, 92, 16, 16]) Inception x_s2_1 : torch.Size([1, 128, 16, 16]) Inception x_s2_2 : torch.Size([1, 128, 16, 16]) Inception output : torch.Size([1, 476, 16, 16]) i3p shape: torch.Size([1, 476, 8, 8]) i4:START <<<<<<< Inception x_s1_0 : torch.Size([1, 92, 8, 8]) Inception x_s2_0 : torch.Size([1, 128, 8, 8]) Inception x_s1_2 : torch.Size([1, 92, 8, 8]) Inception x_pool0 : torch.Size([1, 92, 8, 8]) Inception x_s2_2 : torch.Size([1, 128, 8, 8]) Inception output : torch.Size([1, 348, 8, 8]) FC part :START <<<<<<< flat shape: torch.Size([1, 22272]) concat shape: torch.Size([1, 22273]) fcn_in_features: 22273 fc0 shape: torch.Size([1, 1096]) fc1 shape: torch.Size([1, 1096]) fc2 shape: torch.Size([1, 180]) output shape: torch.Size([1, 180])

But, when I call hl.build_graph(model,(imgs,reds)) then HL complains TypeError: forward() takes 2 positional arguments but 3 were given

Any idea? JE PS: torch 1.1.0 and a fresh HL install on my mac

jecampagne commented 5 years ago

Hi! In fact I have fixed the problem rather I guess by intentation of my custom nn.Modules in the initialisation part.