| @@ -15,10 +15,12 @@ namespace Tensorflow | |||||
| public static variable_scope variable_scope(string name, | public static variable_scope variable_scope(string name, | ||||
| string default_name = null, | string default_name = null, | ||||
| Tensor[] values = null, | Tensor[] values = null, | ||||
| bool auxiliary_name_scope = true) => new variable_scope(name, | |||||
| default_name, | |||||
| bool? reuse = null, | |||||
| bool auxiliary_name_scope = true) => new variable_scope(name, | |||||
| default_name, | |||||
| values, | values, | ||||
| auxiliary_name_scope); | |||||
| reuse: reuse, | |||||
| auxiliary_name_scope: auxiliary_name_scope); | |||||
| public static variable_scope variable_scope(VariableScope scope, | public static variable_scope variable_scope(VariableScope scope, | ||||
| string default_name = null, | string default_name = null, | ||||
| @@ -27,7 +29,8 @@ namespace Tensorflow | |||||
| bool auxiliary_name_scope = true) => new variable_scope(scope, | bool auxiliary_name_scope = true) => new variable_scope(scope, | ||||
| default_name, | default_name, | ||||
| values, | values, | ||||
| auxiliary_name_scope); | |||||
| reuse: reuse, | |||||
| auxiliary_name_scope: auxiliary_name_scope); | |||||
| public static IInitializer truncated_normal_initializer(float mean = 0.0f, | public static IInitializer truncated_normal_initializer(float mean = 0.0f, | ||||
| float stddev = 1.0f, | float stddev = 1.0f, | ||||
| @@ -108,11 +108,11 @@ namespace Tensorflow.Keras.Layers | |||||
| // Build layer if applicable (if the `build` method has been | // Build layer if applicable (if the `build` method has been | ||||
| // overridden). | // overridden). | ||||
| _maybe_build(inputs[0]); | _maybe_build(inputs[0]); | ||||
| }); | |||||
| outputs = call(inputs[0], training: training); | |||||
| _handle_activity_regularization(inputs[0], outputs); | |||||
| _set_mask_metadata(inputs[0], outputs, null); | |||||
| outputs = call(inputs[0], training: training); | |||||
| _handle_activity_regularization(inputs[0], outputs); | |||||
| _set_mask_metadata(inputs[0], outputs, null); | |||||
| }); | |||||
| } | } | ||||
| return outputs; | return outputs; | ||||
| @@ -48,6 +48,7 @@ namespace Tensorflow.Layers | |||||
| else | else | ||||
| { | { | ||||
| scope_context_manager = tf.variable_scope(_scope, | scope_context_manager = tf.variable_scope(_scope, | ||||
| reuse: _reuse, | |||||
| auxiliary_name_scope: false); | auxiliary_name_scope: false); | ||||
| } | } | ||||
| @@ -123,34 +124,33 @@ namespace Tensorflow.Layers | |||||
| _set_scope(); | _set_scope(); | ||||
| var reuse = built || (_reuse != null && _reuse.Value); | var reuse = built || (_reuse != null && _reuse.Value); | ||||
| return Python.with(tf.variable_scope(_scope, | |||||
| reuse: reuse, | |||||
| return with(tf.variable_scope(_scope, | |||||
| reuse: reuse, | |||||
| auxiliary_name_scope: false), scope => | auxiliary_name_scope: false), scope => | ||||
| { | |||||
| _current_scope = scope; | |||||
| return Python.with(ops.name_scope(_name_scope()), delegate | |||||
| { | { | ||||
| var variable = base.add_weight(name, | |||||
| shape, | |||||
| dtype: dtype, | |||||
| initializer: initializer, | |||||
| trainable: trainable, | |||||
| getter: (name1, shape1, dtype1, initializer1, trainable1) => | |||||
| { | |||||
| return tf.get_variable(name1, | |||||
| shape: new TensorShape(shape1), | |||||
| dtype: dtype1, | |||||
| initializer: initializer1, | |||||
| trainable: trainable1); | |||||
| }); | |||||
| if(init_graph != null) | |||||
| _current_scope = scope; | |||||
| return with(ops.name_scope(_name_scope()), delegate | |||||
| { | { | ||||
| var trainable_variables = variables.trainable_variables(); | |||||
| } | |||||
| return variable; | |||||
| var variable = base.add_weight(name, | |||||
| shape, | |||||
| dtype: dtype, | |||||
| initializer: initializer, | |||||
| trainable: trainable, | |||||
| getter: (name1, shape1, dtype1, initializer1, trainable1) => | |||||
| { | |||||
| return tf.get_variable(name1, | |||||
| shape: new TensorShape(shape1), | |||||
| dtype: dtype1, | |||||
| initializer: initializer1, | |||||
| trainable: trainable1); | |||||
| }); | |||||
| //if (init_graph != null) | |||||
| //var trainable_variables = variables.trainable_variables(); | |||||
| return variable; | |||||
| }); | |||||
| }); | }); | ||||
| }); | |||||
| } | } | ||||
| @@ -5,6 +5,9 @@ using static Tensorflow.Python; | |||||
| namespace Tensorflow.Operations | namespace Tensorflow.Operations | ||||
| { | { | ||||
| /// <summary> | |||||
| /// Performs the max pooling on the input. | |||||
| /// </summary> | |||||
| public class MaxPoolFunction : IPoolFunction | public class MaxPoolFunction : IPoolFunction | ||||
| { | { | ||||
| public Tensor Apply(Tensor value, | public Tensor Apply(Tensor value, | ||||
| @@ -14,8 +17,9 @@ namespace Tensorflow.Operations | |||||
| string data_format = "NHWC", | string data_format = "NHWC", | ||||
| string name = null) | string name = null) | ||||
| { | { | ||||
| return with(ops.name_scope(name, "MaxPool", new { value }), scope => { | |||||
| return with(ops.name_scope(name, "MaxPool", value), scope => | |||||
| { | |||||
| name = scope; | |||||
| value = ops.convert_to_tensor(value, name: "input"); | value = ops.convert_to_tensor(value, name: "input"); | ||||
| return gen_nn_ops.max_pool( | return gen_nn_ops.max_pool( | ||||
| value, | value, | ||||
| @@ -5,7 +5,7 @@ | |||||
| <AssemblyName>TensorFlow.NET</AssemblyName> | <AssemblyName>TensorFlow.NET</AssemblyName> | ||||
| <RootNamespace>Tensorflow</RootNamespace> | <RootNamespace>Tensorflow</RootNamespace> | ||||
| <TargetTensorFlow>1.14.0</TargetTensorFlow> | <TargetTensorFlow>1.14.0</TargetTensorFlow> | ||||
| <Version>0.8.0</Version> | |||||
| <Version>0.8.1</Version> | |||||
| <Authors>Haiping Chen</Authors> | <Authors>Haiping Chen</Authors> | ||||
| <Company>SciSharp STACK</Company> | <Company>SciSharp STACK</Company> | ||||
| <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
| @@ -17,15 +17,12 @@ | |||||
| <PackageTags>TensorFlow, NumSharp, SciSharp, MachineLearning, TensorFlow.NET, C#</PackageTags> | <PackageTags>TensorFlow, NumSharp, SciSharp, MachineLearning, TensorFlow.NET, C#</PackageTags> | ||||
| <Description>Google's TensorFlow full binding in .NET Standard. | <Description>Google's TensorFlow full binding in .NET Standard. | ||||
| Docs: https://tensorflownet.readthedocs.io</Description> | Docs: https://tensorflownet.readthedocs.io</Description> | ||||
| <AssemblyVersion>0.8.0.0</AssemblyVersion> | |||||
| <PackageReleaseNotes>Changes since v0.7: | |||||
| <AssemblyVersion>0.8.1.0</AssemblyVersion> | |||||
| <PackageReleaseNotes>Changes since v0.8: | |||||
| Add XOR example. | |||||
| Add KMeans example. | |||||
| Add Object Detection example. | |||||
| Add Word2Vec example.</PackageReleaseNotes> | |||||
| Removed global static graph instance.</PackageReleaseNotes> | |||||
| <LangVersion>7.2</LangVersion> | <LangVersion>7.2</LangVersion> | ||||
| <FileVersion>0.8.0.0</FileVersion> | |||||
| <FileVersion>0.8.1.0</FileVersion> | |||||
| </PropertyGroup> | </PropertyGroup> | ||||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||||
| @@ -107,7 +107,7 @@ namespace Tensorflow | |||||
| if (_name != null || _scope != null) | if (_name != null || _scope != null) | ||||
| { | { | ||||
| var name_scope = _name == null ? _scope.name.Split('/').Last() : _name; | var name_scope = _name == null ? _scope.name.Split('/').Last() : _name; | ||||
| if (name_scope != null || current_name_scope != null) | |||||
| if (current_name_scope == null) | |||||
| current_name_scope = ops.name_scope(name_scope); | current_name_scope = ops.name_scope(name_scope); | ||||
| current_name_scope.__enter__(); | current_name_scope.__enter__(); | ||||
| var current_name_scope_name = current_name_scope; | var current_name_scope_name = current_name_scope; | ||||
| @@ -174,7 +174,8 @@ namespace TensorFlowNET.Examples | |||||
| x_emb = tf.expand_dims(x_emb, -1); | x_emb = tf.expand_dims(x_emb, -1); | ||||
| }); | }); | ||||
| for(int len = 0; len < filter_sizes.Rank; len++) | |||||
| var pooled_outputs = new List<Tensor>(); | |||||
| for (int len = 0; len < filter_sizes.Rank; len++) | |||||
| { | { | ||||
| int filter_size = filter_sizes.GetLength(len); | int filter_size = filter_sizes.GetLength(len); | ||||
| var conv = tf.layers.conv2d( | var conv = tf.layers.conv2d( | ||||
| @@ -190,8 +191,11 @@ namespace TensorFlowNET.Examples | |||||
| pool_size: new[] { document_max_len - filter_size + 1, 1 }, | pool_size: new[] { document_max_len - filter_size + 1, 1 }, | ||||
| strides: new[] { 1, 1 }, | strides: new[] { 1, 1 }, | ||||
| padding: "VALID"); | padding: "VALID"); | ||||
| pooled_outputs.Add(pool); | |||||
| } | } | ||||
| // var h_pool = tf.concat(pooled_outputs, 3); | |||||
| return graph; | return graph; | ||||
| } | } | ||||