Skip to content

Commit

Permalink
Fix: refactor getattr(keras.optimizers, optimizer) to `keras.optimi…
Browse files Browse the repository at this point in the history
…zers.get(optimizer)` in autoencoders
  • Loading branch information
RollerKnobster committed Jun 24, 2024
1 parent fe3530b commit 9200d07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gordo/machine/model/factories/feedforward_autoencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tensorflow.keras.optimizers import Optimizer
from tensorflow.keras import regularizers
from tensorflow.keras.layers import Dense
from tensorflow import keras
from tensorflow.python import keras

from tensorflow.keras.models import Sequential as KerasSequential
from gordo.machine.model.register import register_model_builder
Expand Down Expand Up @@ -88,7 +88,7 @@ class (e.x. Adam(lr=0.01,beta_1=0.9, beta_2=0.999)). If no arguments are

# Instantiate optimizer with kwargs
if isinstance(optimizer, str):
Optim = keras.optimizers.get(optimizer)
Optim = getattr(keras.optimizer_v1, optimizer)
optimizer = Optim(**optimizer_kwargs)

# Final output layer
Expand Down
4 changes: 2 additions & 2 deletions gordo/machine/model/factories/lstm_autoencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from typing import Tuple, Union, Dict, Any

import tensorflow
from tensorflow import keras
from tensorflow.keras.optimizers import Optimizer
from tensorflow.keras.layers import Dense, LSTM
from tensorflow.keras.models import Sequential as KerasSequential
from tensorflow.python import keras

from gordo.machine.model.register import register_model_builder
from gordo.machine.model.factories.utils import hourglass_calc_dims, check_dim_func_len
Expand Down Expand Up @@ -90,7 +90,7 @@ class (e.x. Adam(lr=0.01,beta_1=0.9, beta_2=0.999)). If no arguments are

# output layer
if isinstance(optimizer, str):
Optim = keras.optimizers.get(optimizer)
Optim = getattr(keras.optimizer_v1, optimizer)
optimizer = Optim(**optimizer_kwargs)

model.add(Dense(units=n_features_out, activation=out_func))
Expand Down

0 comments on commit 9200d07

Please sign in to comment.