Various fixess and xor
This commit is contained in:
@@ -6,6 +6,7 @@ use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class PerceptronTrainingIteration implements ShouldBroadcast
|
||||
@@ -38,9 +39,15 @@ class PerceptronTrainingIteration implements ShouldBroadcast
|
||||
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
$weights = collect($this->iterations)
|
||||
->pluck('weights')
|
||||
->first(fn (array $weights): bool => $weights !== []);
|
||||
$shouldBroadcastAllWeights = $weights !== null
|
||||
&& count(Arr::flatten($weights)) <= config('perceptron.max_displayed_weights');
|
||||
|
||||
$lastIterationIndex = count($this->iterations) - 1;
|
||||
$iterations = array_map(
|
||||
fn (array $iteration, int $index): array => $index === $lastIterationIndex
|
||||
fn (array $iteration, int $index): array => $shouldBroadcastAllWeights || $index === $lastIterationIndex
|
||||
? $iteration
|
||||
: [...$iteration, 'weights' => []],
|
||||
$this->iterations,
|
||||
|
||||
Reference in New Issue
Block a user