55 """Return a flat NumPy vector of weights and biases as float64."""
56 values = np.asarray(genome, dtype=float)
57 if values.shape != (self.
genome_size,)
or not np.isfinite(values).all():
58 raise ValueError(f
"Supply {self.genome_size} finite coordinates and biases.")
61 biases = np.split(values[count:], np.cumsum(self.
layer_sizes[1:-1]))
63 with np.errstate(over=
"ignore", invalid=
"ignore", under=
"ignore"):
64 for source, target, bias
in zip(points[:-1], points[1:], biases, strict=
True):
65 difference = source[
None, :, :] - target[:,
None, :]
66 sign_and_scale = np.clip(np.prod(difference, axis=-1), -1., 1.)
67 weights = sign_and_scale * np.hypot.reduce(difference, axis=-1)
68 blocks.extend((weights.ravel(), bias))
69 dense = np.concatenate(blocks)
70 if not np.isfinite(dense).all():
71 raise ValueError(
"The geometric coordinates produced nonfinite weights.")