| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c9b81c6 commit 81b10e3
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,20 +68,27 @@ public Tensor strided_slice<T>(Tensor input, T[] begin, T[] end, T[] strides = n | |||
| 68 | 68 | /// <param name="name">A name for the operation (optional)</param> | |
| 69 | 69 | /// <returns>if num_or_size_splits is a scalar returns num_or_size_splits Tensor objects; | |
| 70 | 70 | /// if num_or_size_splits is a 1-D Tensor returns num_or_size_splits.get_shape[0] Tensor objects resulting from splitting value.</returns> | |
| 71 | - public Tensor[] split(Tensor value, int num_split, Tensor axis, string name = null) | ||
| 71 | + public Tensor[] split(Tensor value, int num_split, Axis axis, string name = null) | ||
| 72 | 72 | => array_ops.split( | |
| 73 | 73 | value: value, | |
| 74 | 74 | num_or_size_splits: num_split, | |
| 75 | 75 | axis: axis, | |
| 76 | 76 | name: name); | |
| 77 | 77 | ||
| 78 | - public Tensor[] split(Tensor value, int num_split, int axis, string name = null) | ||
| 78 | + public Tensor[] split(Tensor value, int[] num_split, Axis axis, string name = null) | ||
| 79 | 79 | => array_ops.split( | |
| 80 | 80 | value: value, | |
| 81 | 81 | num_or_size_splits: num_split, | |
| 82 | - axis: ops.convert_to_tensor(axis), | ||
| 82 | + axis: axis, | ||
| 83 | 83 | name: name); | |
| 84 | 84 | ||
| 85 | + //public Tensor[] split(Tensor value, int num_split, Axis axis, string name = null) | ||
| 86 | + // => array_ops.split( | ||
| 87 | + // value: value, | ||
| 88 | + // num_or_size_splits: num_split, | ||
| 89 | + // axis: axis, | ||
| 90 | + // name: name); | ||
| 91 | + | ||
| 85 | 92 | public Tensor ensure_shape(Tensor x, Shape shape, string name = null) | |
| 86 | 93 | { | |
| 87 | 94 | return gen_ops.ensure_shape(x, shape, name); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,39 @@ | |||
| 1 | + using Newtonsoft.Json; | ||
| 2 | + using System; | ||
| 3 | + using System.Collections.Generic; | ||
| 4 | + using System.Text; | ||
| 5 | + | ||
| 6 | + namespace Tensorflow.Keras.ArgsDefinition.Rnn | ||
| 7 | + { | ||
| 8 | + public class GRUCellArgs : AutoSerializeLayerArgs | ||
| 9 | + { | ||
| 10 | + [JsonProperty("units")] | ||
| 11 | + public int Units { get; set; } | ||
| 12 | + // TODO(Rinne): lack of initialized value of Activation. Merging keras | ||
| 13 | + // into tf.net could resolve it. | ||
| 14 | + [JsonProperty("activation")] | ||
| 15 | + public Activation Activation { get; set; } | ||
| 16 | + [JsonProperty("recurrent_activation")] | ||
| 17 | + public Activation RecurrentActivation { get; set; } | ||
| 18 | + [JsonProperty("use_bias")] | ||
| 19 | + public bool UseBias { get; set; } = true; | ||
| 20 | + [JsonProperty("dropout")] | ||
| 21 | + public float Dropout { get; set; } = .0f; | ||
| 22 | + [JsonProperty("recurrent_dropout")] | ||
| 23 | + public float RecurrentDropout { get; set; } = .0f; | ||
| 24 | + [JsonProperty("kernel_initializer")] | ||
| 25 | + public IInitializer KernelInitializer { get; set; } | ||
| 26 | + [JsonProperty("recurrent_initializer")] | ||
| 27 | + public IInitializer RecurrentInitializer { get; set; } | ||
| 28 | + [JsonProperty("bias_initializer")] | ||
| 29 | + public IInitializer BiasInitializer { get; set; } | ||
| 30 | + [JsonProperty("reset_after")] | ||
| 31 | + public bool ResetAfter { get;set; } | ||
| 32 | + [JsonProperty("implementation")] | ||
| 33 | + public int Implementation { get; set; } = 2; | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -246,6 +246,18 @@ public ILayer RNN( | |||
| 246 | 246 | bool time_major = false | |
| 247 | 247 | ); | |
| 248 | 248 | ||
| 249 | + public IRnnCell GRUCell( | ||
| 250 | + int units, | ||
| 251 | + string activation = "tanh", | ||
| 252 | + string recurrent_activation = "sigmoid", | ||
| 253 | + bool use_bias = true, | ||
| 254 | + string kernel_initializer = "glorot_uniform", | ||
| 255 | + string recurrent_initializer = "orthogonal", | ||
| 256 | + string bias_initializer = "zeros", | ||
| 257 | + float dropout = 0f, | ||
| 258 | + float recurrent_dropout = 0f, | ||
| 259 | + bool reset_after = true); | ||
| 260 | + | ||
| 249 | 261 | public ILayer Subtract(); | |
| 250 | 262 | } | |
| 251 | 263 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -873,6 +873,45 @@ public ILayer LSTM(int units, | |||
| 873 | 873 | UnitForgetBias = unit_forget_bias | |
| 874 | 874 | }); | |
| 875 | 875 | ||
| 876 | + /// <summary> | ||
| 877 | + /// Cell class for the GRU layer. | ||
| 878 | + /// </summary> | ||
| 879 | + /// <param name="units"></param> | ||
| 880 | + /// <param name="activation"></param> | ||
| 881 | + /// <param name="recurrent_activation"></param> | ||
| 882 | + /// <param name="use_bias"></param> | ||
| 883 | + /// <param name="kernel_initializer"></param> | ||
| 884 | + /// <param name="recurrent_initializer"></param> | ||
| 885 | + /// <param name="bias_initializer"></param> | ||
| 886 | + /// <param name="dropout"></param> | ||
| 887 | + /// <param name="recurrent_dropout"></param> | ||
| 888 | + /// <param name="reset_after"></param> | ||
| 889 | + /// <returns></returns> | ||
| 890 | + public IRnnCell GRUCell( | ||
| 891 | + int units, | ||
| 892 | + string activation = "tanh", | ||
| 893 | + string recurrent_activation = "sigmoid", | ||
| 894 | + bool use_bias = true, | ||
| 895 | + string kernel_initializer = "glorot_uniform", | ||
| 896 | + string recurrent_initializer = "orthogonal", | ||
| 897 | + string bias_initializer = "zeros", | ||
| 898 | + float dropout = 0f, | ||
| 899 | + float recurrent_dropout = 0f, | ||
| 900 | + bool reset_after = true) | ||
| 901 | + => new GRUCell(new GRUCellArgs | ||
| 902 | + { | ||
| 903 | + Units = units, | ||
| 904 | + Activation = keras.activations.GetActivationFromName(activation), | ||
| 905 | + RecurrentActivation = keras.activations.GetActivationFromName(recurrent_activation), | ||
| 906 | + KernelInitializer = GetInitializerByName(kernel_initializer), | ||
| 907 | + RecurrentInitializer = GetInitializerByName(recurrent_initializer), | ||
| 908 | + BiasInitializer = GetInitializerByName(bias_initializer), | ||
| 909 | + UseBias = use_bias, | ||
| 910 | + Dropout = dropout, | ||
| 911 | + RecurrentDropout = recurrent_dropout, | ||
| 912 | + ResetAfter = reset_after | ||
| 913 | + }); | ||
| 914 | + | ||
| 876 | 915 | /// <summary> | |
| 877 | 916 | /// | |
| 878 | 917 | /// </summary> | |
@@ -983,5 +1022,9 @@ public ILayer Normalization(Shape? input_shape = null, int? axis = -1, float? me | |||
| 983 | 1022 | Variance = variance, | |
| 984 | 1023 | Invert = invert | |
| 985 | 1024 | }); | |
| 1025 | + | ||
| 1026 | + | ||
| 1027 | + | ||
| 1028 | + | ||
| 986 | 1029 | } | |
| 987 | 1030 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments