Skip to content

Commit e271a44

Browse files
authored
Merge pull request #78 from cbovar/Develop
Develop
2 parents e95e410 + 9ea75e9 commit e271a44

49 files changed

Lines changed: 150 additions & 101 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Examples/Classify2DDemo/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static void Classify2DDemo()
6161
} while (!Console.KeyAvailable);
6262

6363
// Testing
64-
var netx = new Volume(new double[2 * n], new Shape(1, 1, 2, n));
64+
var netx = BuilderInstance.Volume.From(new double[2 * n], new Shape(1, 1, 2, n));
6565
for (var ix = 0; ix < n; ix++)
6666
{
6767
netx.Set(0, 0, 0, ix, data[ix][0]);

Examples/FlowDemo/ExampleCPUDouble.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public static void Example2()
7878
double currentCost;
7979
do
8080
{
81-
var xx = BuilderInstance<double>.Volume.SameAs(new[] { -2.0, -3.0, -10.0 }, new Shape(1, 1, 1, 3));
82-
var yy = BuilderInstance<double>.Volume.SameAs(new[] { -5.0, -6.0, -13.0 }, new Shape(1, 1, 1, 3));
81+
var xx = BuilderInstance<double>.Volume.From(new[] { -2.0, -3.0, -10.0 }, new Shape(1, 1, 1, 3));
82+
var yy = BuilderInstance<double>.Volume.From(new[] { -5.0, -6.0, -13.0 }, new Shape(1, 1, 1, 3));
8383

8484
var dico = new Dictionary<string, Volume<double>> { { "x", xx }, { "y", yy } };
8585

Examples/FluentMnistDemo/DataSet.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using ConvNetSharp.Volume;
44
using ConvNetSharp.Volume.Double;
5+
using Volume = ConvNetSharp.Volume.Volume<double>;
56

67
namespace FluentMnistDemo
78
{
@@ -41,7 +42,7 @@ public Tuple<Volume, Volume, int[]> NextBatch(int batchSize)
4142
}
4243
}
4344

44-
var dataVolume = new Volume(data, dataShape);
45+
var dataVolume = BuilderInstance.Volume.From(data, dataShape);
4546

4647
for (var i = 0; i < batchSize; i++)
4748
{
@@ -70,7 +71,7 @@ public Tuple<Volume, Volume, int[]> NextBatch(int batchSize)
7071
}
7172

7273

73-
var labelVolume = new Volume(label, labelShape);
74+
var labelVolume = BuilderInstance.Volume.From(label, labelShape);
7475

7576
return new Tuple<Volume, Volume, int[]>(dataVolume, labelVolume, labels);
7677
}

Examples/FluentMnistDemo/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using ConvNetSharp.Core;
44
using ConvNetSharp.Core.Fluent;
55
using ConvNetSharp.Core.Training;
6-
using ConvNetSharp.Volume.Double;
6+
using Volume = ConvNetSharp.Volume.Volume<double>;
77

88
namespace FluentMnistDemo
99
{

Examples/FluentMnistDemo/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
//
2727
// Major Version
2828
// Minor Version
29-
// SameAs Number
29+
// Build Number
3030
// Revision
3131
//
32-
// You can specify all the values or you can default the SameAs and Revision Numbers
32+
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.0.0")]

Examples/MinimalExample/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ private static void Main()
3232
net.AddLayer(new SoftmaxLayer(10));
3333

3434
// forward a random data point through the network
35-
var x = new Volume(new[] { 0.3, -0.5 }, new Shape(2));
35+
var x = BuilderInstance.Volume.From(new[] { 0.3, -0.5 }, new Shape(2));
3636

3737
var prob = net.Forward(x);
3838

3939
// prob is a Volume. Volumes have a property Weights that stores the raw data, and WeightGradients that stores gradients
4040
Console.WriteLine("probability that x is class 0: " + prob.Get(0)); // prints e.g. 0.50101
4141

4242
var trainer = new SgdTrainer(net) { LearningRate = 0.01, L2Decay = 0.001 };
43-
trainer.Train(x, new Volume(new[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, new Shape(1, 1, 10, 1))); // train the network, specifying that x is class zero
43+
trainer.Train(x, BuilderInstance.Volume.From(new[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, new Shape(1, 1, 10, 1))); // train the network, specifying that x is class zero
4444

4545
var prob2 = net.Forward(x);
4646
Console.WriteLine("probability that x is class 0: " + prob2.Get(0));

Examples/MinimalExample/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
//
2727
// Major Version
2828
// Minor Version
29-
// SameAs Number
29+
// Build Number
3030
// Revision
3131
//
32-
// You can specify all the values or you can default the SameAs and Revision Numbers
32+
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.0.0")]

Examples/MnistDemo.Flow.GPU/DataSet.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public DataSet(List<MnistEntry> trainImages)
1717
this._trainImages = trainImages;
1818
}
1919

20-
public Tuple<Volume, Volume, int[]> NextBatch(int batchSize)
20+
public Tuple<Volume<float>, Volume<float>, int[]> NextBatch(int batchSize)
2121
{
2222
const int w = 28;
2323
const int h = 28;
@@ -41,7 +41,7 @@ public Tuple<Volume, Volume, int[]> NextBatch(int batchSize)
4141
}
4242
}
4343

44-
var dataVolume = new Volume(data, dataShape);
44+
var dataVolume = BuilderInstance.Volume.From(data, dataShape);
4545

4646
for (var i = 0; i < batchSize; i++)
4747
{
@@ -70,9 +70,9 @@ public Tuple<Volume, Volume, int[]> NextBatch(int batchSize)
7070
}
7171

7272

73-
var labelVolume = new Volume(label, labelShape);
73+
var labelVolume = BuilderInstance.Volume.From(label, labelShape);
7474

75-
return new Tuple<Volume, Volume, int[]>(dataVolume, labelVolume, labels);
75+
return new Tuple<Volume<float>, Volume<float>, int[]>(dataVolume, labelVolume, labels);
7676
}
7777
}
7878
}

Examples/MnistDemo.Flow.GPU/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
using ConvNetSharp.Flow.Layers;
88
using ConvNetSharp.Flow.Training;
99
using ConvNetSharp.Utils.GraphVisualizer;
10-
using ConvNetSharp.Volume.GPU.Single;
10+
using ConvNetSharp.Volume;
11+
1112

1213
namespace MnistDemo.GPU
1314
{
@@ -28,7 +29,7 @@ private static void Main()
2829

2930
private void MnistDemo()
3031
{
31-
BuilderInstance.Volume = new VolumeBuilder();
32+
BuilderInstance<float>.Volume = new ConvNetSharp.Volume.GPU.Single.VolumeBuilder();
3233

3334
var datasets = new DataSets();
3435
if (!datasets.Load(100))
@@ -104,7 +105,7 @@ private void MnistDemo()
104105
this._trainer.Dispose();
105106
}
106107

107-
private void Test(Volume x, int[] labels, CircularBuffer<double> accuracy, bool forward = true)
108+
private void Test(Volume<float> x, int[] labels, CircularBuffer<double> accuracy, bool forward = true)
108109
{
109110
if (forward)
110111
{
@@ -121,7 +122,7 @@ private void Test(Volume x, int[] labels, CircularBuffer<double> accuracy, bool
121122
x.Dispose();
122123
}
123124

124-
private void Train(Volume x, Volume y, int[] labels)
125+
private void Train(Volume<float> x, Volume<float> y, int[] labels)
125126
{
126127
this._trainer.Train(x, y);
127128

Examples/MnistDemo.Flow.GPU/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
//
2727
// Major Version
2828
// Minor Version
29-
// SameAs Number
29+
// Build Number
3030
// Revision
3131
//
32-
// You can specify all the values or you can default the SameAs and Revision Numbers
32+
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.0.0")]

0 commit comments

Comments
 (0)