-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How exactly one goes about learning XOR in with this tool? #59
Comments
Hi! But same code on sharp doesnt give same result:
Perhaps there are some errors in my code or in the project code. |
Changing of shape changes results. I could not understand how does shapes work =/ |
I've given up on C# approaches. Python is much more readable and while it may not be as 'debuggable' it is easier to understand where you're screwing up. Also so many good libraries. |
From issue #74 var net = new Net<double>();
net.AddLayer(new InputLayer(1, 1, 2)); // Two inputs
net.AddLayer(new FullyConnLayer(3));
net.AddLayer(new TanhLayer());
net.AddLayer(new FullyConnLayer(2));
net.AddLayer(new SoftmaxLayer(2)); // Two possible outcome/class (0 and 1)
// All possible inputs
var x0 = new Volume(new double[] { 1, 1 }, new Shape(2));
var x1 = new Volume(new double[] { 0, 1 }, new Shape(2));
var x2 = new Volume(new double[] { 1, 0 }, new Shape(2));
var x3 = new Volume(new double[] { 0, 0 }, new Shape(2));
var trainer = new SgdTrainer<double>(net) { LearningRate = 0.2 };
for (var i = 0; i < 2000; i++)
{
trainer.Train(x0, new Volume(new[] { 1.0, 0.0 }, new Shape(1, 1, 2, 1)));
trainer.Train(x1, new Volume(new[] { 0.0, 1.0 }, new Shape(1, 1, 2, 1)));
trainer.Train(x2, new Volume(new[] { 0.0, 1.0 }, new Shape(1, 1, 2, 1)));
trainer.Train(x3, new Volume(new[] { 1.0, 0.0 }, new Shape(1, 1, 2, 1)));
Console.WriteLine(trainer.Loss); // Should decrease
}
Console.WriteLine("x0: " + net.Forward(x0).Get(0));
Console.WriteLine("x1: " + net.Forward(x1).Get(0));
Console.WriteLine("x2: " + net.Forward(x2).Get(0));
Console.WriteLine("x3: " + net.Forward(x3).Get(0));
Console.ReadLine(); |
I don't get the concept of 'classes' of the README example.
I know the purpose of this tool is to deal with multidimensional input but I'm a bit stuck
The text was updated successfully, but these errors were encountered: