Skip to content

Commit

Permalink
(#7) Attack: Support for non-layer-based models
Browse files Browse the repository at this point in the history
  • Loading branch information
betarixm committed May 16, 2022
1 parent 17508b0 commit 3c9238a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/typings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ def __init__(

self.__input_shape = input_shape

self.__model: keras.Model = keras.Sequential(
[keras.Input(self.__input_shape), *self._model().layers], name=self._name
self.__model: keras.Model = (
keras.Sequential(
[keras.Input(self.__input_shape), *self._model().layers],
name=self._name,
)
if len(self._model().layers) != 0
else self._model()
)

self.intensity: float = intensity
Expand Down Expand Up @@ -115,7 +120,7 @@ def compile(self):
)

def predict(self, inputs):
outs = self.__model.predict(inputs)
outs = self.__model(inputs)
return inputs + (outs - inputs) * self.intensity if self.intensity < 1 else outs

def train(self, epochs: int = 100):
Expand Down

0 comments on commit 3c9238a

Please sign in to comment.