public void perceptron_should_learn_all_except_xor_nor( [ValueSource("Backends")] string backend, [ValueSource("Targets")] float[] y, [Values(false, true)] bool useBias) { KerasSharp.Backends.Current.Switch(backend); var model = new Sequential(); model.Add(new Dense(1, input_dim: 2, kernel_initializer: new GlorotUniform(), bias_initializer: new GlorotUniform(), use_bias: useBias, activation: new Sigmoid())); model.Compile(loss: new MeanSquareError(), optimizer: new SGD(lr: 1), metrics: new[] { new Accuracy() }); model.fit(x, y, epochs: 1000, batch_size: y.Length); Array yy = model.predict(x, batch_size: y.Length)[0]; float[] pred = MatrixEx.Round(yy.To <float[, ]>()).GetColumn(0); if ((useBias && (y == xor)) || (!useBias && (y == xor || y == nor || y == and))) { Assert.AreNotEqual(y, pred); } else { Assert.AreEqual(y, pred); } }