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

Add architecture test for Hopfield Network #221

Open
2 tasks
christianechevarria opened this issue Apr 10, 2020 · 1 comment · Fixed by #222
Open
2 tasks

Add architecture test for Hopfield Network #221

christianechevarria opened this issue Apr 10, 2020 · 1 comment · Fixed by #222
Assignees
Labels
🕷️ bug Something isn't working ✨ enhancement Something could be better

Comments

@christianechevarria
Copy link
Member

Description

There are currently no tests to enforce correct construction of Hopfield Networks inside architect this resulted in issue #220

Tasks

Include specific tasks in the order they need to be done in. Include links to specific lines of code where the task should happen at.

  • Fix Hopfield construction
  • Add unit tests inside test folder
@raimannma
Copy link
Member

#222 Fixed the Hopfield network construction

Implemented a test in the TypeScript version:

it("Build Hopfield network", () => {
const HopfieldSize: number = randInt(10, 20);
const architect: Architect = new Architect();
architect.addLayer(new InputLayer(10));
architect.addLayer(new HopfieldLayer(HopfieldSize));
architect.addLayer(new OutputLayer(2));
const network: Network = architect.buildModel();
expect(network.nodes.length).to.be.equal(10 + HopfieldSize * 2 + 2);
// Check backward pointing connections
let backConnections:number = 0;
for(let i:number=0; i < network.nodes.length;i++){
for(const conn of network.nodes[i].outgoing){
if(network.nodes.indexOf(conn.to)<i){
backConnections++;
}
}
}
expect(backConnections).to.be.equal(HopfieldSize * HopfieldSize);
// 10 * HopfieldSize (input -> LSTM)
// HopfieldSize * HopfieldSize * 8 + HopfieldSize (LSTM intern connection)
// HopfieldSize * 2 (LSTM -> output)
expect(network.connections.length).to.be.equal(10 * HopfieldSize + HopfieldSize * HopfieldSize * 2 + HopfieldSize * 2);
expect(network.gates.length).to.be.equal(0);
const numNodesWithSTEP: number = network.nodes.filter(node => node.squash.type === ActivationType.StepActivation).length;
expect(numNodesWithSTEP).to.be.equal(HopfieldSize);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕷️ bug Something isn't working ✨ enhancement Something could be better
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants