diff --git a/optim_nn.py b/optim_nn.py index 9e52f8d..fce5082 100755 --- a/optim_nn.py +++ b/optim_nn.py @@ -106,8 +106,7 @@ class LayerNorm(Layer): shape = parent.output_shape self.input_shape = shape self.output_shape = shape - if len(shape) != 1: - return False + assert len(shape) == 1, shape if self.affine: self.gamma.shape = (shape[0],) self.beta.shape = (shape[0],) @@ -159,8 +158,7 @@ class Denses(Layer): # TODO: rename? def make_shape(self, parent): shape = parent.output_shape self.input_shape = shape - if len(shape) != 2: - return False + assert len(shape) == 2, shape assert -len(shape) <= self.axis < len(shape) self.axis = self.axis % len(shape) diff --git a/optim_nn_core.py b/optim_nn_core.py index 8cf9bb9..93018c8 100644 --- a/optim_nn_core.py +++ b/optim_nn_core.py @@ -585,8 +585,7 @@ class Dense(Layer): def make_shape(self, parent): shape = parent.output_shape self.input_shape = shape - if len(shape) != 1: - return False + assert len(shape) == 1, shape self.coeffs.shape = (shape[0], self.dim) self.biases.shape = (1, self.dim)