Skip to content

Commit

Permalink
Issue #1547: fix NN not being updated after sim run.
Browse files Browse the repository at this point in the history
  • Loading branch information
RaghuvirShirodkar authored and bjost2s committed Aug 25, 2023
1 parent 3cf94f7 commit 5727612
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -848,15 +848,13 @@ define(["require", "exports", "./neuralnetwork.helper", "./neuralnetwork.nn", ".
if (rememberProgramWasReplaced) {
return; // program was imported. Old NN should NOT be saved
}
if (neuralNetwork) {
network = neuralNetwork;
}
var networkToSave = neuralNetwork ? neuralNetwork : network;
var startBlock = UTIL.getTheStartBlock();
try {
state.weights = network.getWeightArray();
state.biases = network.getBiasArray();
state.inputs = network.getInputNames();
state.outputs = network.getOutputNames();
state.weights = networkToSave.getWeightArray();
state.biases = networkToSave.getBiasArray();
state.inputs = networkToSave.getInputNames();
state.outputs = networkToSave.getOutputNames();
startBlock.data = JSON.stringify(state);
}
catch (e) {
Expand Down
12 changes: 5 additions & 7 deletions OpenRobertaWeb/src/app/neuralnetwork/neuralnetwork.ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,15 +875,13 @@ export function saveNN2Blockly(neuralNetwork?: Network): void {
if (rememberProgramWasReplaced) {
return; // program was imported. Old NN should NOT be saved
}
if (neuralNetwork) {
network = neuralNetwork;
}
let networkToSave: Network = neuralNetwork ? neuralNetwork : network;
var startBlock = UTIL.getTheStartBlock();
try {
state.weights = network.getWeightArray();
state.biases = network.getBiasArray();
state.inputs = network.getInputNames();
state.outputs = network.getOutputNames();
state.weights = networkToSave.getWeightArray();
state.biases = networkToSave.getBiasArray();
state.inputs = networkToSave.getInputNames();
state.outputs = networkToSave.getOutputNames();
startBlock.data = JSON.stringify(state);
} catch (e) {
LOG.error('failed to create a JSON string from nn state');
Expand Down

0 comments on commit 5727612

Please sign in to comment.