Skip to content

Commit

Permalink
Merge pull request #487 from kitsudaiki/feat/update-tolerance-value
Browse files Browse the repository at this point in the history
related issue: #484
  • Loading branch information
kitsudaiki authored Oct 25, 2024
2 parents f2d4d68 + bc81799 commit 5b79a60
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- made internal processing more generic, to have the same worker-workflow for all coming backends
- use debug builds with ASan-check for tests of the CI (unit-, functional-, memory-leak-, sdk-api- and cli-api-tests)
- default-values for initial admin-credentials and token-key were removed from the helm-chart and are now marked as required
- synapse-tolerance was changed to static values

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion src/hanami/src/core/cluster/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ struct Connection {
SourceLocationPtr origin;
float lowerBound = 0.0f;
float potentialRange = std::numeric_limits<float>::max();
float tollerance = 0.49f;
float splitValue = 0.0;
float potential = 0.0f;
float delta = 0.0f;
uint8_t padding[4];

Connection()
{
Expand Down
2 changes: 1 addition & 1 deletion src/hanami/src/core/processing/cpu/backpropagation.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ backpropagateOutput(Hexagon* hexagon)
Neuron* neuron = nullptr;
OutputNeuron* out = nullptr;
OutputTargetLocationPtr* target = nullptr;
constexpr float learnValue = 0.05f;
float totalDelta = 0.0f;
float learnValue = 0.1f;
float delta = 0.0f;
float update = 0.0f;
uint64_t i = 0;
Expand Down
47 changes: 27 additions & 20 deletions src/hanami/src/core/processing/cpu/processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ synapseProcessingBackward(Cluster& cluster,
Synapse* synapse = nullptr;
Neuron* targetNeuron = nullptr;
float halfPotential = 0.0f;
float condition = 0.0f;
constexpr float createBorder = 0.25f;
constexpr float adjustment = (1.0f / 1.5f) - 1.0f;
const bool isAbleToCreate = connection->origin.isInput || cluster.enableCreation;

if (potential > connection->potentialRange) {
Expand All @@ -106,32 +109,36 @@ synapseProcessingBackward(Cluster& cluster,
synapse = &synapseSection->synapses[pos];

if constexpr (doTrain) {
if (isAbleToCreate) {
// create new synapse if necesarry and training is active
if (synapse->targetNeuronId == UNINIT_STATE_8) {
createNewSynapse(synapse, clusterSettings, potential, randomSeed);
cluster.enableCreation = true;
}
}
if (isAbleToCreate && potential < (0.5f + connection->tollerance) * synapse->border
&& potential > (0.5f - connection->tollerance) * synapse->border)
{
synapse->border /= 1.5f;
synapse->weight /= 1.5f;
connection->tollerance /= 1.2f;
// create new synapse if necesarry and training is active
if (isAbleToCreate & (synapse->targetNeuronId == UNINIT_STATE_8)) {
createNewSynapse(synapse, clusterSettings, potential, randomSeed);
cluster.enableCreation = true;
}
}

if (synapse->targetNeuronId != UNINIT_STATE_8) {
// update target-neuron
targetNeuron = &targetNeuronBlock->neurons[synapse->targetNeuronId];
val = synapse->weight;
if (potential < synapse->border) {
val *= ((1.0f / synapse->border) * potential);
// update target-neuron
targetNeuron
= &targetNeuronBlock->neurons[synapse->targetNeuronId % NEURONS_PER_NEURONBLOCK];
val = synapse->weight;
if (potential < synapse->border) {
val *= ((1.0f / synapse->border) * potential);
if constexpr (doTrain) {
condition = static_cast<float>(connection->origin.isInput)
* (potential < (1.0f - createBorder) * synapse->border)
* (potential > createBorder * synapse->border);
synapse->border = synapse->border * (1.0f + (condition * adjustment));
synapse->weight = synapse->weight * (1.0f + (condition * adjustment));
cluster.enableCreation = cluster.enableCreation || (condition != 0);

condition = static_cast<float>(connection->origin.isInput == false)
* static_cast<float>(cluster.enableCreation)
* (potential < synapse->border - createBorder) * (potential > 0.05f);
synapse->border = synapse->border * (1.0f + (condition * adjustment));
synapse->weight = synapse->weight * (1.0f + (condition * adjustment));
cluster.enableCreation = cluster.enableCreation || (condition != 0);
}
targetNeuron->input += val;
}
targetNeuron->input += val;

// update loop-counter
halfPotential
Expand Down

0 comments on commit 5b79a60

Please sign in to comment.