Skip to content

Commit

Permalink
blackify
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnbera committed Apr 7, 2024
1 parent a43484d commit c810241
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
6 changes: 1 addition & 5 deletions lanfactory/trainers/jax_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,7 @@ def load_state_from_file(self, seed=42, input_dim=6, file_path=None):
return loaded_state

def make_forward_partial(
self,
seed=42,
input_dim=6,
state=None,
add_jitted=False,
self, seed=42, input_dim=6, state=None, add_jitted=False,
):
"""Creates a partial function for the forward pass of the network.
Expand Down
17 changes: 8 additions & 9 deletions lanfactory/trainers/torch_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,7 @@ class TorchMLP(nn.Module):
# In the end I want 'eval', but differentiable
# w.r.t to input ...., might be a problem
def __init__(
self,
network_config=None,
input_shape=10,
network_type=None,
**kwargs,
self, network_config=None, input_shape=10, network_type=None, **kwargs,
):
super(TorchMLP, self).__init__()

Expand Down Expand Up @@ -614,8 +610,7 @@ def train_and_evaluate(
print("Saving model state dict")
train_state_path = full_path + "_train_state_dict_torch.pt"
torch.save(
self.model.state_dict(),
train_state_path,
self.model.state_dict(), train_state_path,
)
print("Saving model parameters to: " + train_state_path)
self.file_path_model = train_state_path
Expand Down Expand Up @@ -706,7 +701,9 @@ def __init__(self, model_file_path=None, network_config=None, input_dim=None):
)
# self.net.load_state_dict(torch.load(self.model_file_path))
if torch.cuda.is_available() == False:
self.net.load_state_dict(torch.load(self.model_file_path, map_location=torch.device('cpu')))
self.net.load_state_dict(
torch.load(self.model_file_path, map_location=torch.device("cpu"))
)
else:
self.net.load_state_dict(torch.load(self.model_file_path))
self.net.to(self.dev)
Expand Down Expand Up @@ -774,7 +771,9 @@ def __init__(self, model_file_path=None, network_config=None, input_dim=None):
)
# self.net.load_state_dict(torch.load(self.model_file_path))
if torch.cuda.is_available() == False:
self.net.load_state_dict(torch.load(self.model_file_path, map_location=torch.device('cpu')))
self.net.load_state_dict(
torch.load(self.model_file_path, map_location=torch.device("cpu"))
)
else:
self.net.load_state_dict(torch.load(self.model_file_path))
self.net.to(self.dev)
Expand Down

0 comments on commit c810241

Please sign in to comment.