Skip to content

investigate if conditions in torch script #42

Description

@TomMelt

Currently #33 hacks the utils/model_definition.py to disable an if condition that isn't used for 1x1 model but causes issue when trying to script

# if self.fac == 1:
# x = torch.squeeze(self.dropout0(self.act_cnn(self.conv1(x))))
# elif self.fac == 2:
# x = torch.squeeze(self.dropout0(self.act_cnn(self.conv1(x))))
# x = torch.squeeze(self.dropout0_2(self.act_cnn2(self.conv2(x))))

Error:

RuntimeError: 
Module 'ANN_CNN' has no attribute 'dropout0' :
  File "/home/melt/sync/cambridge/projects/current/nlgw-cam/nonlocal_gwfluxes/era5_training/../utils/model_definition.py", line 75
    def forward(self, x):
        if self.fac == 1:
            x = torch.squeeze(self.dropout0(self.act_cnn(self.conv1(x))))
                              ~~~~~~~~~~~~~ <--- HERE
        elif self.fac == 2:
            x = torch.squeeze(self.dropout0(self.act_cnn(self.conv1(x))))
  • investigate cause of error
  • find permanent solution rather than commenting the code out

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions