Skip to content

Commit 1c35292

Browse files
Optimizer and Regularizer classes skeleton added
1 parent 5b2d4cc commit 1c35292

17 files changed

Lines changed: 347 additions & 14 deletions

File tree

TensorFlow.NET.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTest", "test\TensorFlow
1111
EndProject
1212
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tensorflow.Keras", "src\TensorFlowNET.Keras\Tensorflow.Keras.csproj", "{6268B461-486A-460B-9B3C-86493CBBAAF7}"
1313
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tensorflow.Keras.UnitTest", "test\Tensorflow.Keras.UnitTest\Tensorflow.Keras.UnitTest.csproj", "{EB92DD90-6346-41FB-B967-2B33A860AD98}"
15+
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1618
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,14 @@ Global
5153
{6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|Any CPU.Build.0 = Release|Any CPU
5254
{6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|x64.ActiveCfg = Release|Any CPU
5355
{6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|x64.Build.0 = Release|Any CPU
56+
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|Any CPU.Build.0 = Debug|Any CPU
58+
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|x64.ActiveCfg = Debug|Any CPU
59+
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|x64.Build.0 = Debug|Any CPU
60+
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|Any CPU.ActiveCfg = Release|Any CPU
61+
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|x64.ActiveCfg = Release|Any CPU
63+
{EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|x64.Build.0 = Release|Any CPU
5464
EndGlobalSection
5565
GlobalSection(SolutionProperties) = preSolution
5666
HideSolutionNode = FALSE

src/TensorFlowNET.Keras/Engine/CallContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public CallContext()
2020

2121
}
2222

23-
public void enter(Layer layer, Tensor[] inputs, Graph build_graph, bool training, Saving saving = null) => throw new NotImplementedException();
23+
public void enter(Layer layer, Tensor[] inputs, Graph build_graph, bool training) => throw new NotImplementedException();
2424

2525
public bool training_arg_passed_to_call(string[] argspec, Dictionary<string, object> args, Dictionary<string, object> kwargs) => throw new NotImplementedException();
2626

src/TensorFlowNET.Keras/Engine/Saving.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/TensorFlowNET.Keras/KwArgs.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Keras
6+
{
7+
public class KwArgs
8+
{
9+
private Dictionary<string, object> args = new Dictionary<string, object>();
10+
11+
public object this[string name]
12+
{
13+
get
14+
{
15+
return args.ContainsKey(name) ? args[name] : null;
16+
}
17+
set
18+
{
19+
args[name] = value;
20+
}
21+
}
22+
23+
public T Get<T>(string name)
24+
{
25+
if (!args.ContainsKey(name))
26+
return default(T);
27+
28+
return (T)args[name];
29+
}
30+
31+
public static explicit operator KwArgs(ValueTuple<string, object>[] p)
32+
{
33+
KwArgs kwArgs = new KwArgs();
34+
kwArgs.args = new Dictionary<string, object>();
35+
foreach (var item in p)
36+
{
37+
kwArgs.args[item.Item1] = item.Item2;
38+
}
39+
40+
return kwArgs;
41+
}
42+
}
43+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Tensorflow.Keras
7+
{
8+
public class Adadelta : Optimizer
9+
{
10+
public Adadelta(float lr= 0.01f, float rho = 0.95f, float? epsilon = null, float decay = 0) : base(null)
11+
{
12+
throw new NotImplementedException();
13+
}
14+
15+
public override Tensor[] get_updates(Tensor loss, variables @params)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
20+
public override Hashtable get_config()
21+
{
22+
throw new NotImplementedException();
23+
}
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Tensorflow.Keras
7+
{
8+
public class Adagrad : Optimizer
9+
{
10+
public Adagrad(float lr= 0.01f, float? epsilon = null, float decay = 0) : base(null)
11+
{
12+
throw new NotImplementedException();
13+
}
14+
15+
public override Tensor[] get_updates(Tensor loss, variables @params)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
20+
public override Hashtable get_config()
21+
{
22+
throw new NotImplementedException();
23+
}
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Tensorflow.Keras
7+
{
8+
public class Adam : Optimizer
9+
{
10+
public Adam(float lr= 0.001f, float beta_1 = 0.9f, float beta_2 = 0.99f, float? epsilon = null, float decay = 0) : base(null)
11+
{
12+
throw new NotImplementedException();
13+
}
14+
15+
public override Tensor[] get_updates(Tensor loss, variables @params)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
20+
public override Hashtable get_config()
21+
{
22+
throw new NotImplementedException();
23+
}
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Tensorflow.Keras
7+
{
8+
public class Adamax : Optimizer
9+
{
10+
public Adamax(float lr = 0.002f, float beta_1 = 0.9f, float beta_2 = 0.999f, float? epsilon = null, float decay = 0) : base(null)
11+
{
12+
throw new NotImplementedException();
13+
}
14+
15+
public override Tensor[] get_updates(Tensor loss, variables @params)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
20+
public override Hashtable get_config()
21+
{
22+
throw new NotImplementedException();
23+
}
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Tensorflow.Keras
7+
{
8+
public class Nadam : Optimizer
9+
{
10+
public Nadam(float lr = 0.002f, float beta_1 = 0.9f, float beta_2 = 0.999f, float? epsilon = null, float schedule_decay = 0.004f) : base(null)
11+
{
12+
throw new NotImplementedException();
13+
}
14+
15+
public override Tensor[] get_updates(Tensor loss, variables @params)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
20+
public override Hashtable get_config()
21+
{
22+
throw new NotImplementedException();
23+
}
24+
}
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using NumSharp;
2+
using System;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
7+
namespace Tensorflow.Keras
8+
{
9+
public class Optimizer
10+
{
11+
public Optimizer(KwArgs kwargs)
12+
{
13+
throw new NotImplementedException();
14+
}
15+
16+
public virtual Tensor[] get_updates(Tensor loss, variables @params)
17+
{
18+
return null;
19+
}
20+
21+
public virtual Tensor[] get_gradients(Tensor loss, variables @params) => throw new NotImplementedException();
22+
23+
public virtual void set_weights(NDArray[] weights) => throw new NotImplementedException();
24+
25+
public virtual NDArray[] get_weights() => throw new NotImplementedException();
26+
27+
public virtual Hashtable get_config() => throw new NotImplementedException();
28+
29+
public static string serialize(Optimizer optimizer) => throw new NotImplementedException();
30+
31+
public static string deserialize(string config, object custom_objects = null) => throw new NotImplementedException();
32+
33+
public static Optimizer get(object identifier) => throw new NotImplementedException();
34+
35+
}
36+
}

0 commit comments

Comments
 (0)