Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix layer count in autoencoder detector #516

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyod/models/auto_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _build_model(self):
model.add(Dropout(self.dropout_rate))

# Additional layers
for i, hidden_neurons in enumerate(self.hidden_neurons_, 1):
for hidden_neurons in self.hidden_neurons_[1:]:
model.add(Dense(
hidden_neurons,
activation=self.hidden_activation,
Expand Down
8 changes: 8 additions & 0 deletions pyod/test/test_auto_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def test_fit_predict_score(self):
def test_model_clone(self):
# for deep models this may not apply
clone_clf = clone(self.clf)

def test_layer_count(self):
hidden_layers = len(self.clf.hidden_neurons)
# add one to account for the dropout after the input layer
dropout_layers = hidden_layers + 1
# add two for the input and output layers
expected_layer_count = hidden_layers + dropout_layers + 2
assert(len(self.clf.model_.layers) == expected_layer_count)

def tearDown(self):
pass
Expand Down