Compare commits
3 Commits
236fa503fb
...
a92a47288c
| Author | SHA1 | Date | |
|---|---|---|---|
| a92a47288c | |||
| bcaf334380 | |||
| dea908c63e |
@@ -29,11 +29,6 @@ class LinearOrderDataSetReader implements IDataSetReader
|
|||||||
$newLine[] = (float) $value;
|
$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;
|
$this->lines[] = $newLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,6 @@ class RandomOrderDataSetReader implements IDataSetReader
|
|||||||
$newLine[] = (float) $value;
|
$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;
|
$this->lines[] = $newLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,20 +32,12 @@ class PerceptronLimitedEpochEventBuffer implements IPerceptronIterationEventBuff
|
|||||||
'weights' => $synaptic_weights,
|
'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;
|
$lastEpoch = $this->data[0]['epoch'] ?? null;
|
||||||
if ($this->data && $lastEpoch !== $epoch) { // Current Epoch has changed from the last one
|
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
|
$this->flush(); // Flush all data from the previous epoch
|
||||||
} else {
|
} else {
|
||||||
$this->data = [];
|
$this->data = []; // We clear the data without sending it as we are saving the next epoch data
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastEpoch = $epoch;
|
$lastEpoch = $epoch;
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ return [
|
|||||||
* Beyond this number of iterations, the broadcast will be splitted every x iterations,
|
* Beyond this number of iterations, the broadcast will be splitted every x iterations,
|
||||||
* x is limited_broadcast_number
|
* x is limited_broadcast_number
|
||||||
*/
|
*/
|
||||||
'limited_broadcast_iterations' => 200,
|
'limited_broadcast_iterations' => 100,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How much broadcasts is sent when in limmited broadcast mode
|
* How much broadcasts is sent when in limmited broadcast mode
|
||||||
*/
|
*/
|
||||||
'limited_broadcast_number' => 200,
|
'limited_broadcast_number' => 100,
|
||||||
|
|
||||||
'broadcast_iteration_size' => 75,
|
'broadcast_iteration_size' => 75,
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,30 @@ const farRightDataPointX = computed(() => {
|
|||||||
return maxX;
|
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(
|
function getPerceptronDecisionBoundaryDataset(
|
||||||
networkWeights: number[][][],
|
networkWeights: number[][][],
|
||||||
activationFunction: (x: number) => number = (x) => x,
|
activationFunction: (x: number) => number = (x) => x,
|
||||||
@@ -48,12 +72,17 @@ function getPerceptronDecisionBoundaryDataset(
|
|||||||
if (
|
if (
|
||||||
networkWeights.length == 1 &&
|
networkWeights.length == 1 &&
|
||||||
networkWeights[0].length == 1 &&
|
networkWeights[0].length == 1 &&
|
||||||
networkWeights[0][0].length == 3
|
networkWeights[0][0].length <= 3
|
||||||
) {
|
) {
|
||||||
// Unique, 3 weights perceptron
|
// Unique, 3 weights perceptron
|
||||||
const perceptronWeights = networkWeights[0][0]; // We take the unique perceptron
|
const perceptronWeights = networkWeights[0][0]; // We take the unique perceptron
|
||||||
|
|
||||||
function perceptronLine(x: number): number {
|
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
|
// 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
|
const w2 = perceptronWeights[2] == 0 ? 1e-6 : perceptronWeights[2]; // Avoid division by zero
|
||||||
return -(perceptronWeights[1] / w2) * x - perceptronWeights[0] / w2;
|
return -(perceptronWeights[1] / w2) * x - perceptronWeights[0] / w2;
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ watch(selectedDatasetCopy, (newValue) => {
|
|||||||
name="dataset"
|
name="dataset"
|
||||||
id="dataset-select"
|
id="dataset-select"
|
||||||
v-model="selectedDatasetCopy"
|
v-model="selectedDatasetCopy"
|
||||||
|
class="cursor-pointer"
|
||||||
>
|
>
|
||||||
<NativeSelectOption value="" disabled
|
<NativeSelectOption value="" disabled
|
||||||
>Sélectionnez un dataset</NativeSelectOption
|
>Sélectionnez un dataset</NativeSelectOption
|
||||||
@@ -154,6 +155,7 @@ watch(selectedDatasetCopy, (newValue) => {
|
|||||||
name="weight_init_method"
|
name="weight_init_method"
|
||||||
id="weight_init_method"
|
id="weight_init_method"
|
||||||
v-model="selectedMethod"
|
v-model="selectedMethod"
|
||||||
|
class="cursor-pointer"
|
||||||
>
|
>
|
||||||
<NativeSelectOption
|
<NativeSelectOption
|
||||||
v-for="method in ['zeros', 'random']"
|
v-for="method in ['zeros', 'random']"
|
||||||
|
|||||||
Reference in New Issue
Block a user