Compare commits
3 Commits
236fa503fb
...
a92a47288c
| Author | SHA1 | Date | |
|---|---|---|---|
| a92a47288c | |||
| bcaf334380 | |||
| dea908c63e |
@@ -29,11 +29,6 @@ class LinearOrderDataSetReader implements IDataSetReader
|
||||
$newLine[] = (float) $value;
|
||||
}
|
||||
|
||||
// if the dataset is for regression, we add a fake label of 0
|
||||
if (count($newLine) === 2) {
|
||||
$newLine[] = 0.0;
|
||||
}
|
||||
|
||||
$this->lines[] = $newLine;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,6 @@ class RandomOrderDataSetReader implements IDataSetReader
|
||||
$newLine[] = (float) $value;
|
||||
}
|
||||
|
||||
// if the dataset is for regression, we add a fake label of 0
|
||||
if (count($newLine) === 2) {
|
||||
$newLine[] = 0.0;
|
||||
}
|
||||
|
||||
$this->lines[] = $newLine;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,20 +32,12 @@ class PerceptronLimitedEpochEventBuffer implements IPerceptronIterationEventBuff
|
||||
'weights' => $synaptic_weights,
|
||||
];
|
||||
|
||||
if ($this->underSizeIncreaseCount <= $this->sizeIncreaseStart) { // Special case where we need to send each iteration separately
|
||||
$this->underSizeIncreaseCount++;
|
||||
$this->data[] = $newData;
|
||||
$this->flush();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$lastEpoch = $this->data[0]['epoch'] ?? null;
|
||||
if ($this->data && $lastEpoch !== $epoch) { // Current Epoch has changed from the last one
|
||||
if ($lastEpoch % $this->epochInterval === 0) { // The last epoch need to be sent
|
||||
if ($lastEpoch == 1 || $lastEpoch % $this->epochInterval === 0) { // The last saved epoch need to be sent
|
||||
$this->flush(); // Flush all data from the previous epoch
|
||||
} else {
|
||||
$this->data = [];
|
||||
$this->data = []; // We clear the data without sending it as we are saving the next epoch data
|
||||
}
|
||||
|
||||
$lastEpoch = $epoch;
|
||||
|
||||
@@ -7,12 +7,12 @@ return [
|
||||
* Beyond this number of iterations, the broadcast will be splitted every x iterations,
|
||||
* x is limited_broadcast_number
|
||||
*/
|
||||
'limited_broadcast_iterations' => 200,
|
||||
'limited_broadcast_iterations' => 100,
|
||||
|
||||
/**
|
||||
* How much broadcasts is sent when in limmited broadcast mode
|
||||
*/
|
||||
'limited_broadcast_number' => 200,
|
||||
'limited_broadcast_number' => 100,
|
||||
|
||||
'broadcast_iteration_size' => 75,
|
||||
|
||||
|
||||
@@ -35,6 +35,30 @@ const farRightDataPointX = computed(() => {
|
||||
return maxX;
|
||||
});
|
||||
|
||||
function getPerceptronOutput(weightsNetwork: number[][], inputs: number[]): number[] {
|
||||
for (const layer of weightsNetwork) {
|
||||
const nextInputs: number[] = [];
|
||||
|
||||
for (const neuron of layer) {
|
||||
const bias = neuron[0];
|
||||
const weights = neuron.slice(1);
|
||||
|
||||
let sum = bias;
|
||||
|
||||
for (let i = 0; i < weights.length; i++) {
|
||||
sum += weights[i] * inputs[i];
|
||||
}
|
||||
|
||||
const activated = props.activationFunction(sum);
|
||||
|
||||
nextInputs.push(activated);
|
||||
}
|
||||
|
||||
inputs = nextInputs;
|
||||
}
|
||||
return inputs;
|
||||
}
|
||||
|
||||
function getPerceptronDecisionBoundaryDataset(
|
||||
networkWeights: number[][][],
|
||||
activationFunction: (x: number) => number = (x) => x,
|
||||
@@ -48,12 +72,17 @@ function getPerceptronDecisionBoundaryDataset(
|
||||
if (
|
||||
networkWeights.length == 1 &&
|
||||
networkWeights[0].length == 1 &&
|
||||
networkWeights[0][0].length == 3
|
||||
networkWeights[0][0].length <= 3
|
||||
) {
|
||||
// Unique, 3 weights perceptron
|
||||
const perceptronWeights = networkWeights[0][0]; // We take the unique perceptron
|
||||
|
||||
function perceptronLine(x: number): number {
|
||||
if (perceptronWeights.length < 3) {
|
||||
// If we have less than 3 weights, we assume missing weights are zero
|
||||
perceptronWeights.push(getPerceptronOutput(networkWeights, [x])[0]);
|
||||
}
|
||||
|
||||
// w0 + w1*x + w2*y = 0 => y = -(w1/w2)*x - w0/w2
|
||||
const w2 = perceptronWeights[2] == 0 ? 1e-6 : perceptronWeights[2]; // Avoid division by zero
|
||||
return -(perceptronWeights[1] / w2) * x - perceptronWeights[0] / w2;
|
||||
|
||||
@@ -127,6 +127,7 @@ watch(selectedDatasetCopy, (newValue) => {
|
||||
name="dataset"
|
||||
id="dataset-select"
|
||||
v-model="selectedDatasetCopy"
|
||||
class="cursor-pointer"
|
||||
>
|
||||
<NativeSelectOption value="" disabled
|
||||
>Sélectionnez un dataset</NativeSelectOption
|
||||
@@ -154,6 +155,7 @@ watch(selectedDatasetCopy, (newValue) => {
|
||||
name="weight_init_method"
|
||||
id="weight_init_method"
|
||||
v-model="selectedMethod"
|
||||
class="cursor-pointer"
|
||||
>
|
||||
<NativeSelectOption
|
||||
v-for="method in ['zeros', 'random']"
|
||||
|
||||
Reference in New Issue
Block a user