You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/11/04 15:57:39 UTC

[GitHub] anjishnu commented on issue #8419: DeferredInitializationError after calling trainer.step

anjishnu commented on issue #8419: DeferredInitializationError after calling trainer.step 
URL: https://github.com/apache/incubator-mxnet/issues/8419#issuecomment-341907938
 
 
   I think this error message could definitely be improved:
   
   Works
   ```
   class SiameseFF(gluon.Block):
       def __init__(self, **kwargs):
           super(SiameseFF, self).__init__(**kwargs)
           self.key = 'siamese-ff'
           with self.name_scope():
               # layers created in name_scope will inherit name space
               # from parent layer.
               self.bn = nn.BatchNorm()
               #self.dropout = nn.Dropout(0.3)
               self.fc1 = nn.Dense(50, activation="relu")
               self.fc2 = nn.Dense(50, activation='relu')
               self.fc3 = nn.Dense(2)
   
       def forward(self, (x1, x2)):
   
           z1 = self.fc1(x1)
           z1 = self.bn(z1)
           z1 = self.fc2(z1)
   
           z2 = self.fc1(x2)
           z2 = self.bn(z2)
           z2 = self.fc2(z2)
   
           z = F.concat(z2, z1, dim=1)
           z = self.fc3(z)
           return z
   ```
   
   Fails
   
   ```
   class SiameseFF(gluon.Block):
       def __init__(self, **kwargs):
           super(SiameseFF, self).__init__(**kwargs)
           self.key = 'siamese-ff'
           with self.name_scope():
               # layers created in name_scope will inherit name space
               # from parent layer.
               self.bn = nn.BatchNorm()
               #self.dropout = nn.Dropout(0.3)
               self.fc1 = nn.Dense(50, activation="relu")
               self.fc2 = nn.Dense(50, activation='relu')
               self.fc3 = nn.Dense(2)
   
       def forward(self, (x1, x2)):
   
           z1 = self.fc1(x1)
           #z1 = self.bn(z1)
           z1 = self.fc2(z1)
   
           z2 = self.fc1(x2)
           #z2 = self.bn(z2)
           z2 = self.fc2(z2)
   
           z = F.concat(z2, z1, dim=1)
           z = self.fc3(z)
           return z
   ```
   
   It is not immediately obvious why this should happen, or why it should happen to the batchNorm layer but not to the dropout layer. I suggest making this error message a little more interpretable.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services