Comments (4)
Hi!
I tried to implement same code with convnetjs from https://gist.github.com/willguitaradmfar/12f7efb2ab9534755619ba4dce72f988
But same code on sharp doesnt give same result:
var net = new Net<double>();
net.AddLayer(new InputLayer(1, 1, 2));
net.AddLayer(new FullyConnLayer(3));
net.AddLayer(new TanhLayer());
net.AddLayer(new FullyConnLayer(2));
net.AddLayer(new SoftmaxLayer(2));
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));
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.WriteLine();
Console.WriteLine();
var trainer = new SgdTrainer<double>(net) { LearningRate = 0.2, L2Decay = 0.001 };
for (int i = 0; i < 2000; i++)
{
trainer.Train(x0, new Volume(new double[] { 0.0 }, new Shape(1)));
trainer.Train(x1, new Volume(new double[] { 1.0 }, new Shape(1)));
trainer.Train(x2, new Volume(new double[] { 1.0 }, new Shape(1)));
trainer.Train(x3, new Volume(new double[] { 0.0 }, new Shape(1)));
}
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));
Perhaps there are some errors in my code or in the project code.
from convnetsharp.
Changing of shape changes results. I could not understand how does shapes work =/
from convnetsharp.
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 convnetsharp.
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();
from convnetsharp.
Related Issues (20)
- Wrong gradient computation in Flow when batch size > 1
- How to load FluentNet<T> from json file? HOT 8
- Executable file locks after a crash. HOT 3
- using Dropout HOT 2
- Creating convolutional network? HOT 1
- Convolutional network, annealing and epochs HOT 15
- how to concat multi layers? HOT 3
- ConvNetSharp compare to other Deep Learning frameworks HOT 9
- TrainerBase class is not updated in NuGet HOT 9
- How to make deconvolution neural network U-Net. HOT 1
- Fluent serialization not working
- [Question] Network with different output kind (softmax & scalar) HOT 5
- how to create 1d Convolutional network with pading? HOT 3
- Import ONNX models / models from other frameworks HOT 2
- "disposable" not defined HOT 5
- "Invalid Input!" occurs at fully connected layer during training HOT 3
- Getting started - basic network won't classify two distinct patterns HOT 7
- Question HOT 2
- How to implement the following layer?
- Show Graph is not work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from convnetsharp.