Skip to content

Commit

Permalink
Working on GH-3: Make the first example for a Dense layer pass.
Browse files Browse the repository at this point in the history
Adding examples & passing unit tests for:

  - int_shape
  - ndim
  - random_normal
  - random_uniform
  - variable
  - zeros
  • Loading branch information
cesarsouza committed Aug 10, 2017
1 parent d21bfef commit 1f83959
Show file tree
Hide file tree
Showing 29 changed files with 578 additions and 97 deletions.
35 changes: 16 additions & 19 deletions Sources/Backends/Base/IBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace KerasSharp.Backends
using TensorFlow;
using KerasSharp.Models;

public interface IBackend
public interface IBackend : IDisposable
{
// TODO: Rename all methods to PascalCase

Expand Down Expand Up @@ -65,7 +65,7 @@ public interface IBackend

Tensor max(Tensor x, int v, object p);

int ndim(Tensor x);
int? ndim(Tensor x);

Tensor max(Tensor x, int axis, bool keepdims);

Expand Down Expand Up @@ -93,6 +93,7 @@ public interface IBackend

Tensor div(Tensor desired, object v);

object eval(Tensor tensor);

Tensor add(Tensor desired, Tensor v);

Expand All @@ -102,9 +103,7 @@ public interface IBackend

Tensor add(double v, Tensor tensor);

Tensor constant(int v, TFShape shape, TFDataType dtype);

Tensor random_uniform(TFShape shape, double v, double limit, TFDataType dtype, int? seed);
Tensor random_uniform(int?[] shape, double minvalue = 0.0, double maxvalue = 1.0, TFDataType dtype = Utils.DEFAULT_DTYPE, int? seed = null, string name = null);

Tensor truncated_normal(TFShape shape, double v, double stddev, TFDataType dtype, int? seed);

Expand Down Expand Up @@ -132,27 +131,26 @@ public interface IBackend

double subtract(double v, Tensor expected);

Tensor constant(int v, int?[] shape, TFDataType dtype);

Tensor add(object v1, double v2);

Tensor variable(double v, string name);
Tensor variable(Array array, string name = null);

Tensor variable<T>(T value, string name = null) where T : struct;

Tensor variable(Tensor tensor, TFDataType dtype = Utils.DEFAULT_DTYPE, string name = null);

Tensor in_train_phase(Func<Tensor> dropped_inputs, Tensor inputs, bool? training);

TFDataType? dtype(Tensor input_tensor);

Tensor constant(int v, int[] shape, TFDataType dtype);
Tensor constant<T>(T value, int?[] shape, TFDataType dtype = Utils.DEFAULT_DTYPE, string name = null);

Tensor placeholder(int[] shape, TFDataType? dtype, bool sparse, string name);
int get_uid(string prefix);

string get_uid(string prefix);

List<Tensor> gradients(ILoss loss, object param);
List<Tensor> gradients(Tensor loss, object param);

int?[] int_shape(Tensor input_tensor);

Tensor variable(Tensor Tensor, TFDataType? dtype, string name);

object sum(object[] v);

Expand All @@ -168,7 +166,7 @@ public interface IBackend

void batch_set_value(List<Tuple<Tensor, Array>> weight_value_tuples);

Tensor placeholder(int?[] shape, TFDataType? dtype, bool sparse, string name);
Tensor placeholder(int?[] shape, TFDataType? dtype = Utils.DEFAULT_DTYPE, bool sparse = false, string name = null);

int?[] int_shape(TFTensor input_tensor);

Expand Down Expand Up @@ -204,7 +202,9 @@ public interface IBackend

object learning_phase();

Function function(object inputs, List<Tensor> list, Func<List<object>> updates, string name);
Function function(object inputs, List<Tensor> list, Func<List<List<Tensor>>> updates, string name);

Function function(object inputs, List<Tensor> list, List<List<Tensor>> updates, string name);

Tensor mul(Tensor momentum, object v);

Expand All @@ -222,10 +222,7 @@ public interface IBackend

Tensor truncated_normal(int[] shape, double v, double stddev, TFDataType dtype, int? seed);

Tensor random_uniform(int[] shape, double v, double limit, TFDataType dtype, int? seed);

Tensor truncated_normal(int?[] shape, double v, double stddev, TFDataType dtype, int? seed);

Tensor random_uniform(int?[] shape, double v, double limit, TFDataType dtype, int? seed);
}
}
2 changes: 1 addition & 1 deletion Sources/Backends/Current.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ namespace KerasSharp.Backends
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KerasSharp.Engine.Topology;

public static class Current
{

public static IBackend K { get; set; } = new TensorFlowBackend();


}
}
Loading

0 comments on commit 1f83959

Please sign in to comment.