inputs = {0, 1, 1}; // The last 1 is the pseudo input for bias
CL
--==-=-=
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
1.0, user-scalable=3Dyes">
Ruben Safir ruben-at-mrbrklyn.com=
writes:
If there is always a bias, why is there a while condition, let alone not=
an if condition. What situation were you anticipating?
These logic-gate perceptrons have two inputs, so you should be able to d=
eclare:
vector<float> inputs =3D {0, 1};
But the weight vector is three values:
vector<float> weights =3D {0.1, -0.2, 0.3};
The last one is what we call the bias. You can think of it as the weight=
attached to a =E2=80=9Cpseudo=E2=80=9D input which is always one. So what =
the loop does is to make that =E2=80=9Cpseudo=E2=80=9D input real:
while(input.size() < p.weights.size()) {
input.push_back(1); // Add pseudo input that's always 1
}
Now, since the input.size() matches the weights.size(), we can call the =
dot product to do the calculation:
dot_product(p.weights, input)
It=E2=80=99s just the =E2=80=9Crobustness principle=E2=80=9D: be strict =
in what you send and tolerant in what you accept. In the feed_forward funct=
ion I=E2=80=99m receiving the input vector. I=E2=80=99m sending it to the d=
ot_product function. I=E2=80=99m tolerant if the input is too small, and I =
augment it with ones (pseudo inputs) until there are enough inputs that the=
dot_product will work.
BTW, it only has to append the first time through the feed_forward. Ther=
eafter, if I continue to use the same input vector then the size will alrea=
dy be correct and the loop body is never executed.
Or if you just want to declare the inputs to have three values, then it =
just amounts to a check that you did that, and doesn=E2=80=99t have to appe=
nd:
vector<float> inputs =3D {0, 1, 1}; // The last 1 is the =
pseudo input for bias
CL
--==-=-=--
--=-=-=--
--===-=-=
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQEcBAEBCAAGBQJY2+qcAAoJEGuLsz1PMbCLblsH/R4VTOoVMu37ggaIHW9b/8t8
NaSa+gi2gCzqNWLmw+urQyDR/GsX2GryqypGa+hSnXAfC1d9YST3fP/1xSuwZA4U
vTnVCbj/MoYeUnY10O4ShzlTrZnIDOXHNTRpUT0PnMP3vGoj+gdPyCDYMwb+/86j
EgQLVes3VnbIlsRfYBIsPZ3tDSlx+NtSyYAldLqsYS3wuQYCqR1ltlxQKCvNGP/+
uiwexxolJoqH+o+X64J16p/4OD4nWfJ1md3d8q3+OZjVDOyPkp5D0/RRYPXKQJ+q
vwt+o+hlVbdsUgy6t3MWn+LrM8i1oLvxRP8UXso4KQhjYqMed5mRAjjTgTPUXkM=
=3R+c
-----END PGP SIGNATURE-----
--===-=-=--
--===============1355307894==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Learn mailing list
Learn-at-nylxs.com
http://lists.mrbrklyn.com/mailman/listinfo/learn
--===============1355307894==--