Skip to content

Activation in constructor always falls back to tanh #14

@jaimelias

Description

@jaimelias

File: FeedForwardNeuralNetwork.js

Location: Inside the default constructor branch, around line 30.

When you instantiate the network with a supported activation (e.g. "relu", "logistic", "identity"), the constructor still resets this.activation to "tanh".

That happens because the code is using "in" operator together with "Object.keys". The "in" operator must be used with objects only, but you are converting ACTIVATION_FUNCTIONS with the use of "Object.keys

❌ error:
if (!(this.activation in Object.keys(ACTIVATION_FUNCTIONS))) { this.activation = 'tanh'; }

✅ solution:
if (!ACTIVATION_FUNCTIONS.hasOwnProperty(this.activation)) { this.activation = 'tanh'; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions