| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 34efa15 commit 5f1f598
30 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,11 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tensorflow.Benchmark", "src | |||
| 9 | 9 | EndProject | |
| 10 | 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tensorflow.UnitTest", "test\TensorFlowNET.UnitTest\Tensorflow.UnitTest.csproj", "{23C28035-2FCE-41F3-9A12-E73CE8A5AE32}" | |
| 11 | 11 | EndProject | |
| 12 | - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tensorflow.Keras", "src\TensorFlowNET.Keras\Tensorflow.Keras.csproj", "{6268B461-486A-460B-9B3C-86493CBBAAF7}" | ||
| 13 | - EndProject | ||
| 14 | - Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tensorflow.Keras.UnitTest", "test\Tensorflow.Keras.UnitTest\Tensorflow.Keras.UnitTest.csproj", "{EB92DD90-6346-41FB-B967-2B33A860AD98}" | ||
| 15 | - EndProject | ||
| 16 | - Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TensorFlowNET.Console", "src\TensorFlowNET.Console\TensorFlowNET.Console.csproj", "{03F06299-3F4B-4449-A709-3A647657BC0C}" | ||
| 12 | + Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TensorFlowNET.Console", "src\TensorFlowNET.Console\TensorFlowNET.Console.csproj", "{03F06299-3F4B-4449-A709-3A647657BC0C}" | ||
| 17 | 13 | EndProject | |
| 18 | 14 | Global | |
| 19 | 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
@@ -103,54 +99,6 @@ Global | |||
| 103 | 99 | {23C28035-2FCE-41F3-9A12-E73CE8A5AE32}.Release|x64.Build.0 = Release|x64 | |
| 104 | 100 | {23C28035-2FCE-41F3-9A12-E73CE8A5AE32}.Release|x86.ActiveCfg = Release|Any CPU | |
| 105 | 101 | {23C28035-2FCE-41F3-9A12-E73CE8A5AE32}.Release|x86.Build.0 = Release|Any CPU | |
| 106 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| 107 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| 108 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug|x64.ActiveCfg = Debug|x64 | ||
| 109 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug|x64.Build.0 = Debug|x64 | ||
| 110 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
| 111 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug|x86.Build.0 = Debug|Any CPU | ||
| 112 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug-Minimal|Any CPU.ActiveCfg = Debug|Any CPU | ||
| 113 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug-Minimal|Any CPU.Build.0 = Debug|Any CPU | ||
| 114 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug-Minimal|x64.ActiveCfg = Debug|x64 | ||
| 115 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug-Minimal|x64.Build.0 = Debug|x64 | ||
| 116 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug-Minimal|x86.ActiveCfg = Debug|Any CPU | ||
| 117 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Debug-Minimal|x86.Build.0 = Debug|Any CPU | ||
| 118 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Publish|Any CPU.ActiveCfg = Release|Any CPU | ||
| 119 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Publish|Any CPU.Build.0 = Release|Any CPU | ||
| 120 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Publish|x64.ActiveCfg = Release|x64 | ||
| 121 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Publish|x64.Build.0 = Release|x64 | ||
| 122 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Publish|x86.ActiveCfg = Release|Any CPU | ||
| 123 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Publish|x86.Build.0 = Release|Any CPU | ||
| 124 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| 125 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| 126 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|x64.ActiveCfg = Release|x64 | ||
| 127 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|x64.Build.0 = Release|x64 | ||
| 128 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|x86.ActiveCfg = Release|Any CPU | ||
| 129 | - {6268B461-486A-460B-9B3C-86493CBBAAF7}.Release|x86.Build.0 = Release|Any CPU | ||
| 130 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| 131 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| 132 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|x64.ActiveCfg = Debug|x64 | ||
| 133 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|x64.Build.0 = Debug|x64 | ||
| 134 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
| 135 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug|x86.Build.0 = Debug|Any CPU | ||
| 136 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug-Minimal|Any CPU.ActiveCfg = Debug|Any CPU | ||
| 137 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug-Minimal|Any CPU.Build.0 = Debug|Any CPU | ||
| 138 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug-Minimal|x64.ActiveCfg = Debug|x64 | ||
| 139 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug-Minimal|x64.Build.0 = Debug|x64 | ||
| 140 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug-Minimal|x86.ActiveCfg = Debug|Any CPU | ||
| 141 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Debug-Minimal|x86.Build.0 = Debug|Any CPU | ||
| 142 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Publish|Any CPU.ActiveCfg = Release|Any CPU | ||
| 143 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Publish|Any CPU.Build.0 = Release|Any CPU | ||
| 144 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Publish|x64.ActiveCfg = Release|x64 | ||
| 145 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Publish|x64.Build.0 = Release|x64 | ||
| 146 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Publish|x86.ActiveCfg = Release|Any CPU | ||
| 147 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Publish|x86.Build.0 = Release|Any CPU | ||
| 148 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| 149 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| 150 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|x64.ActiveCfg = Release|x64 | ||
| 151 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|x64.Build.0 = Release|x64 | ||
| 152 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|x86.ActiveCfg = Release|Any CPU | ||
| 153 | - {EB92DD90-6346-41FB-B967-2B33A860AD98}.Release|x86.Build.0 = Release|Any CPU | ||
| 154 | 102 | {03F06299-3F4B-4449-A709-3A647657BC0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
| 155 | 103 | {03F06299-3F4B-4449-A709-3A647657BC0C}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
| 156 | 104 | {03F06299-3F4B-4449-A709-3A647657BC0C}.Debug|x64.ActiveCfg = Debug|Any CPU | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,9 +14,11 @@ You may obtain a copy of the License at | |||
| 14 | 14 | limitations under the License. | |
| 15 | 15 | ******************************************************************************/ | |
| 16 | 16 | ||
| 17 | + using System; | ||
| 17 | 18 | using System.Collections.Generic; | |
| 18 | 19 | using System.Linq; | |
| 19 | 20 | using NumSharp; | |
| 21 | + using Tensorflow.Keras.ArgsDefinition; | ||
| 20 | 22 | using Tensorflow.Keras.Layers; | |
| 21 | 23 | using Tensorflow.Operations.Activation; | |
| 22 | 24 | using static Tensorflow.Binding; | |
@@ -173,14 +175,19 @@ public Tensor dense(Tensor inputs, | |||
| 173 | 175 | if (bias_initializer == null) | |
| 174 | 176 | bias_initializer = tf.zeros_initializer; | |
| 175 | 177 | ||
| 176 | - var layer = new Dense(units, activation, | ||
| 177 | - use_bias: use_bias, | ||
| 178 | - bias_initializer: bias_initializer, | ||
| 179 | - kernel_initializer: kernel_initializer, | ||
| 180 | - trainable: trainable, | ||
| 181 | - name: name); | ||
| 182 | - | ||
| 183 | - return layer.apply(inputs).Item1; | ||
| 178 | + var layer = new Dense(new DenseArgs | ||
| 179 | + { | ||
| 180 | + Units = units, | ||
| 181 | + Activation = activation, | ||
| 182 | + UseBias = use_bias, | ||
| 183 | + BiasInitializer = bias_initializer, | ||
| 184 | + KernelInitializer = kernel_initializer, | ||
| 185 | + Trainable = trainable, | ||
| 186 | + Name = name | ||
| 187 | + }); | ||
| 188 | + | ||
| 189 | + throw new NotImplementedException(""); | ||
| 190 | + //return layer.apply(inputs).Item1; | ||
| 184 | 191 | } | |
| 185 | 192 | ||
| 186 | 193 | /// <summary> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -515,6 +515,9 @@ public Tensor sigmoid<T>(T x, string name = null) | |||
| 515 | 515 | public Tensor sum(Tensor input, int axis, bool keep_dims = false, string name = null) | |
| 516 | 516 | => gen_math_ops._sum(input, axis, keep_dims: keep_dims, name: name); | |
| 517 | 517 | ||
| 518 | + public Tensor reduce_mean(Tensor input_tensors, int axis, bool keepdims = false, string name = null) | ||
| 519 | + => math_ops.reduce_mean(input_tensors, axis: new[] { axis }, keepdims: keepdims, name: name); | ||
| 520 | + | ||
| 518 | 521 | public Tensor reduce_mean(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null, int? reduction_indices = null) | |
| 519 | 522 | => math_ops.reduce_mean(input_tensor, axis: axis, keepdims: keepdims, name: name, reduction_indices: reduction_indices); | |
| 520 | 523 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ namespace Tensorflow | |||
| 7 | 7 | { | |
| 8 | 8 | public class DatasetManager | |
| 9 | 9 | { | |
| 10 | - public IDatasetV2 from_tensor_slices(NDArray features, NDArray labels) | ||
| 10 | + public IDatasetV2 from_tensor_slices(Tensor features, Tensor labels) | ||
| 11 | 11 | => new TensorSliceDataset(features, labels); | |
| 12 | 12 | } | |
| 13 | 13 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,9 +11,9 @@ namespace Tensorflow | |||
| 11 | 11 | { | |
| 12 | 12 | public class TensorSliceDataset : DatasetSource | |
| 13 | 13 | { | |
| 14 | - public TensorSliceDataset(NDArray features, NDArray labels) | ||
| 14 | + public TensorSliceDataset(Tensor features, Tensor labels) | ||
| 15 | 15 | { | |
| 16 | - _tensors = new[] { tf.convert_to_tensor(features), tf.convert_to_tensor(labels) }; | ||
| 16 | + _tensors = new[] { features, labels }; | ||
| 17 | 17 | var batched_spec = _tensors.Select(x => x.ToTensorSpec()).ToArray(); | |
| 18 | 18 | structure = batched_spec.Select(x => x._unbatch()).ToArray(); | |
| 19 | 19 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + using System; | ||
| 2 | + | ||
| 3 | + namespace Tensorflow | ||
| 4 | + { | ||
| 5 | + public class InvalidArgumentError : TensorflowException | ||
| 6 | + { | ||
| 7 | + public InvalidArgumentError() : base() | ||
| 8 | + { | ||
| 9 | + | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + public InvalidArgumentError(string message) : base(message) | ||
| 13 | + { | ||
| 14 | + | ||
| 15 | + } | ||
| 16 | + } | ||
| 17 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,7 +119,7 @@ public Tensor gradient(Tensor target, ResourceVariable source) | |||
| 119 | 119 | return (results[0], results[1]); | |
| 120 | 120 | } | |
| 121 | 121 | ||
| 122 | - public Tensor[] gradient(Tensor target, ResourceVariable[] sources) | ||
| 122 | + public Tensor[] gradient(Tensor target, IEnumerable<IVariableV1> sources) | ||
| 123 | 123 | { | |
| 124 | 124 | if (_recording) | |
| 125 | 125 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,56 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + using Tensorflow.Operations.Activation; | ||
| 5 | + using static Tensorflow.Binding; | ||
| 6 | + | ||
| 7 | + namespace Tensorflow.Keras.ArgsDefinition | ||
| 8 | + { | ||
| 9 | + public class DenseArgs : LayerArgs | ||
| 10 | + { | ||
| 11 | + /// <summary> | ||
| 12 | + /// Positive integer, dimensionality of the output space. | ||
| 13 | + /// </summary> | ||
| 14 | + public int Units { get; set; } | ||
| 15 | + | ||
| 16 | + /// <summary> | ||
| 17 | + /// Activation function to use. | ||
| 18 | + /// </summary> | ||
| 19 | + public IActivation Activation { get; set; } | ||
| 20 | + | ||
| 21 | + /// <summary> | ||
| 22 | + /// Whether the layer uses a bias vector. | ||
| 23 | + /// </summary> | ||
| 24 | + public bool UseBias { get; set; } = true; | ||
| 25 | + | ||
| 26 | + /// <summary> | ||
| 27 | + /// Initializer for the `kernel` weights matrix. | ||
| 28 | + /// </summary> | ||
| 29 | + public IInitializer KernelInitializer { get; set; } = tf.glorot_uniform_initializer; | ||
| 30 | + | ||
| 31 | + /// <summary> | ||
| 32 | + /// Initializer for the bias vector. | ||
| 33 | + /// </summary> | ||
| 34 | + public IInitializer BiasInitializer { get; set; } = tf.zeros_initializer; | ||
| 35 | + | ||
| 36 | + /// <summary> | ||
| 37 | + /// Regularizer function applied to the `kernel` weights matrix. | ||
| 38 | + /// </summary> | ||
| 39 | + public IInitializer KernelRegularizer { get; set; } | ||
| 40 | + | ||
| 41 | + /// <summary> | ||
| 42 | + /// Regularizer function applied to the bias vector. | ||
| 43 | + /// </summary> | ||
| 44 | + public IInitializer BiasRegularizer { get; set; } | ||
| 45 | + | ||
| 46 | + /// <summary> | ||
| 47 | + /// Constraint function applied to the `kernel` weights matrix. | ||
| 48 | + /// </summary> | ||
| 49 | + public Action KernelConstraint { get; set; } | ||
| 50 | + | ||
| 51 | + /// <summary> | ||
| 52 | + /// Constraint function applied to the bias vector. | ||
| 53 | + /// </summary> | ||
| 54 | + public Action BiasConstraint { get; set; } | ||
| 55 | + } | ||
| 56 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,51 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + | ||
| 5 | + namespace Tensorflow.Keras.ArgsDefinition | ||
| 6 | + { | ||
| 7 | + public class LayerArgs | ||
| 8 | + { | ||
| 9 | + /// <summary> | ||
| 10 | + /// Indicates whether the layer's weights are updated during training | ||
| 11 | + /// and whether the layer's updates are run during training. | ||
| 12 | + /// </summary> | ||
| 13 | + public bool Trainable { get; set; } = true; | ||
| 14 | + | ||
| 15 | + public string Name { get; set; } | ||
| 16 | + | ||
| 17 | + /// <summary> | ||
| 18 | + /// Only applicable to input layers. | ||
| 19 | + /// </summary> | ||
| 20 | + public TF_DataType DType { get; set; } | ||
| 21 | + | ||
| 22 | + /// <summary> | ||
| 23 | + /// Whether the `call` method can be used to build a TF graph without issues. | ||
| 24 | + /// This attribute has no effect if the model is created using the Functional | ||
| 25 | + /// API. Instead, `model.dynamic` is determined based on the internal layers. | ||
| 26 | + /// </summary> | ||
| 27 | + public bool Dynamic { get; set; } = false; | ||
| 28 | + | ||
| 29 | + /// <summary> | ||
| 30 | + /// Only applicable to input layers. | ||
| 31 | + /// </summary> | ||
| 32 | + public TensorShape InputShape { get; set; } | ||
| 33 | + | ||
| 34 | + /// <summary> | ||
| 35 | + /// Only applicable to input layers. | ||
| 36 | + /// </summary> | ||
| 37 | + public TensorShape BatchInputShape { get; set; } | ||
| 38 | + | ||
| 39 | + /// <summary> | ||
| 40 | + /// Initial weight values. | ||
| 41 | + /// </summary> | ||
| 42 | + public float[] Weights { get; set; } | ||
| 43 | + | ||
| 44 | + /// <summary> | ||
| 45 | + /// Regularizer function applied to the output of the layer(its "activation"). | ||
| 46 | + /// </summary> | ||
| 47 | + public IInitializer ActivityRegularizer { get; set; } | ||
| 48 | + | ||
| 49 | + public bool Autocast { get; set; } | ||
| 50 | + } | ||
| 51 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + | ||
| 5 | + namespace Tensorflow.Keras.ArgsDefinition | ||
| 6 | + { | ||
| 7 | + public class ModelArgs : LayerArgs | ||
| 8 | + { | ||
| 9 | + } | ||
| 10 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments