diff --git a/src/TensorFlowNET.Core/APIs/c_api.cs b/src/TensorFlowNET.Core/APIs/c_api.cs index db8f1c8f..10f678e0 100644 --- a/src/TensorFlowNET.Core/APIs/c_api.cs +++ b/src/TensorFlowNET.Core/APIs/c_api.cs @@ -63,8 +63,8 @@ namespace Tensorflow static unsafe DeallocatorArgs() { - Empty = new IntPtr(EmptyPtr = (DeallocatorArgs*) Marshal.AllocHGlobal(Marshal.SizeOf())); - *EmptyPtr = new DeallocatorArgs() {gc_handle = IntPtr.Zero, deallocator_called = false}; + Empty = new IntPtr(EmptyPtr = (DeallocatorArgs*)Marshal.AllocHGlobal(Marshal.SizeOf())); + *EmptyPtr = new DeallocatorArgs() { gc_handle = IntPtr.Zero, deallocator_called = false }; } public bool deallocator_called; diff --git a/src/TensorFlowNET.Core/APIs/tf.array.cs b/src/TensorFlowNET.Core/APIs/tf.array.cs index 1c28f124..a87e041e 100644 --- a/src/TensorFlowNET.Core/APIs/tf.array.cs +++ b/src/TensorFlowNET.Core/APIs/tf.array.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using NumSharp; -using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; diff --git a/src/TensorFlowNET.Core/APIs/tf.autograph.cs b/src/TensorFlowNET.Core/APIs/tf.autograph.cs index 71a4d481..55acac62 100644 --- a/src/TensorFlowNET.Core/APIs/tf.autograph.cs +++ b/src/TensorFlowNET.Core/APIs/tf.autograph.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using Tensorflow.Graphs; -using Tensorflow.Operations; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/APIs/tf.compat.cs b/src/TensorFlowNET.Core/APIs/tf.compat.cs index d29de189..4d979eb5 100644 --- a/src/TensorFlowNET.Core/APIs/tf.compat.cs +++ b/src/TensorFlowNET.Core/APIs/tf.compat.cs @@ -14,8 +14,6 @@ limitations under the License. ******************************************************************************/ -using NumSharp; - namespace Tensorflow { public partial class tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.compat.v1.cs b/src/TensorFlowNET.Core/APIs/tf.compat.v1.cs index a08597a8..e5dc6a40 100644 --- a/src/TensorFlowNET.Core/APIs/tf.compat.v1.cs +++ b/src/TensorFlowNET.Core/APIs/tf.compat.v1.cs @@ -14,9 +14,7 @@ limitations under the License. ******************************************************************************/ -using System; using System.Collections.Generic; -using Tensorflow.Contexts; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.control_flow.cs b/src/TensorFlowNET.Core/APIs/tf.control_flow.cs index c419c45d..239487e0 100644 --- a/src/TensorFlowNET.Core/APIs/tf.control_flow.cs +++ b/src/TensorFlowNET.Core/APIs/tf.control_flow.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using System; -using static Tensorflow.Binding; namespace Tensorflow { @@ -42,19 +41,19 @@ namespace Tensorflow public Operation group(T[] inputs, string name = null) where T : ITensorOrOperation => control_flow_ops.group(inputs, name: name); - public Tensor while_loop(Func cond, - Func body, + public Tensor while_loop(Func cond, + Func body, Tensor loop_vars, int parallel_iterations = 10) { - Func cond1 = x + Func cond1 = x => cond(x[0]); - Func body1 = x + Func body1 = x => new[] { body(x[0]) }; - var results = control_flow_ops.while_loop(cond1, - body1, + var results = control_flow_ops.while_loop(cond1, + body1, new[] { loop_vars }); return results[0]; } @@ -68,7 +67,7 @@ namespace Tensorflow parallel_iterations: parallel_iterations, name: name); - public _ControlDependenciesController control_dependencies(ITensorOrOperation[] control_inputs) + public _ControlDependenciesController control_dependencies(ITensorOrOperation[] control_inputs) => ops.control_dependencies(control_inputs); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.data.cs b/src/TensorFlowNET.Core/APIs/tf.data.cs index 149ce067..7fe7fcf9 100644 --- a/src/TensorFlowNET.Core/APIs/tf.data.cs +++ b/src/TensorFlowNET.Core/APIs/tf.data.cs @@ -14,8 +14,6 @@ limitations under the License. ******************************************************************************/ -using NumSharp; - namespace Tensorflow { public partial class tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.data_flow.cs b/src/TensorFlowNET.Core/APIs/tf.data_flow.cs index 3ea6a70d..e4c0a83c 100644 --- a/src/TensorFlowNET.Core/APIs/tf.data_flow.cs +++ b/src/TensorFlowNET.Core/APIs/tf.data_flow.cs @@ -14,8 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; - namespace Tensorflow { public partial class tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.debugging.cs b/src/TensorFlowNET.Core/APIs/tf.debugging.cs index 579698a2..1a9c7b46 100644 --- a/src/TensorFlowNET.Core/APIs/tf.debugging.cs +++ b/src/TensorFlowNET.Core/APIs/tf.debugging.cs @@ -34,10 +34,10 @@ namespace Tensorflow object[] data = null, string message = null, string name = null) - => check_ops.assert_equal(t1, - t2, - data: data, - message: message, + => check_ops.assert_equal(t1, + t2, + data: data, + message: message, name: name); public Tensor assert_greater_equal(Tensor x, diff --git a/src/TensorFlowNET.Core/APIs/tf.gradients.cs b/src/TensorFlowNET.Core/APIs/tf.gradients.cs index bb648bb9..b5724aaa 100644 --- a/src/TensorFlowNET.Core/APIs/tf.gradients.cs +++ b/src/TensorFlowNET.Core/APIs/tf.gradients.cs @@ -40,11 +40,11 @@ namespace Tensorflow int? aggregation_method = null, Tensor[] stop_gradients = null) { - return gradients_util._GradientsHelper(ys, - xs, - grad_ys, - name, - colocate_gradients_with_ops, + return gradients_util._GradientsHelper(ys, + xs, + grad_ys, + name, + colocate_gradients_with_ops, gate_gradients, stop_gradients: stop_gradients); } diff --git a/src/TensorFlowNET.Core/APIs/tf.graph.cs b/src/TensorFlowNET.Core/APIs/tf.graph.cs index 05851b6b..7c0e7585 100644 --- a/src/TensorFlowNET.Core/APIs/tf.graph.cs +++ b/src/TensorFlowNET.Core/APIs/tf.graph.cs @@ -24,7 +24,7 @@ namespace Tensorflow public GraphTransformer graph_transforms => new GraphTransformer(); public GraphKeys GraphKeys { get; } = new GraphKeys(); - public void reset_default_graph() + public void reset_default_graph() => ops.reset_default_graph(); public Graph get_default_graph() diff --git a/src/TensorFlowNET.Core/APIs/tf.image.cs b/src/TensorFlowNET.Core/APIs/tf.image.cs index 433c573d..34cb4be7 100644 --- a/src/TensorFlowNET.Core/APIs/tf.image.cs +++ b/src/TensorFlowNET.Core/APIs/tf.image.cs @@ -14,8 +14,6 @@ limitations under the License. ******************************************************************************/ -using System.Collections.Generic; -using Tensorflow.IO; using static Tensorflow.Binding; namespace Tensorflow @@ -34,7 +32,7 @@ namespace Tensorflow public Tensor flip_left_right(Tensor image) => image_ops_impl.flip_left_right(image); - + public Tensor flip_up_down(Tensor image) => image_ops_impl.flip_up_down(image); @@ -56,7 +54,7 @@ namespace Tensorflow public Tensor resize_image_with_crop_or_pad(Tensor image, object target_height, object target_width) => image_ops_impl.resize_image_with_crop_or_pad(image, target_height, target_width); - public Tensor resize_images(Tensor images, Tensor size, string method = ResizeMethod.BILINEAR, bool preserve_aspect_ratio = false, bool antialias = false, + public Tensor resize_images(Tensor images, Tensor size, string method = ResizeMethod.BILINEAR, bool preserve_aspect_ratio = false, bool antialias = false, string name = null) => image_ops_impl.resize_images(images, size, method, preserve_aspect_ratio, antialias, name); @@ -93,7 +91,7 @@ namespace Tensorflow public Tensor random_hue(Tensor image, float max_delta, int seed = 0) => image_ops_impl.random_hue(image, max_delta, seed); - + public Tensor adjust_hue(Tensor image, Tensor delta, string name = null) => image_ops_impl.adjust_hue(image, delta, name); @@ -169,7 +167,7 @@ namespace Tensorflow string dct_method = "", string name = null) => gen_image_ops.decode_jpeg(contents, channels: channels, ratio: ratio, - fancy_upscaling: fancy_upscaling, try_recover_truncated: try_recover_truncated, + fancy_upscaling: fancy_upscaling, try_recover_truncated: try_recover_truncated, acceptable_fraction: acceptable_fraction, dct_method: dct_method); /// @@ -197,12 +195,12 @@ namespace Tensorflow => image_ops_impl.combined_non_max_suppression(boxes, scores, max_output_size_per_class, max_total_size, iou_threshold, score_threshold, pad_per_class, clip_boxes, name); - public (Tensor, Tensor) non_max_suppression_padded(Tensor boxes, Tensor scores, Tensor max_output_size, + public (Tensor, Tensor) non_max_suppression_padded(Tensor boxes, Tensor scores, Tensor max_output_size, float iou_threshold = 0.5f, float score_threshold = -1f / 0f, bool pad_to_max_output_size = false, string name = null, - bool sorted_input = false, + bool sorted_input = false, bool canonicalized_coordinates = false, int tile_size = 512) => image_ops_impl.non_max_suppression_padded(boxes, scores, max_output_size, iou_threshold, score_threshold, pad_to_max_output_size, diff --git a/src/TensorFlowNET.Core/APIs/tf.init.cs b/src/TensorFlowNET.Core/APIs/tf.init.cs index c674d5c9..b5ebc469 100644 --- a/src/TensorFlowNET.Core/APIs/tf.init.cs +++ b/src/TensorFlowNET.Core/APIs/tf.init.cs @@ -22,7 +22,7 @@ namespace Tensorflow { public InitializersImpl initializers { get; } = new InitializersImpl(); - public IInitializer constant_initializer(T value, TF_DataType dtype = TF_DataType.TF_FLOAT, bool verify_shape = false) + public IInitializer constant_initializer(T value, TF_DataType dtype = TF_DataType.TF_FLOAT, bool verify_shape = false) => new Constant(value, dtype: dtype, verify_shape: verify_shape); public IInitializer zeros_initializer => new Zeros(); public IInitializer ones_initializer => new Ones(); @@ -97,7 +97,7 @@ namespace Tensorflow dtype: dtype); public IInitializer zeros_initializer(TensorShape shape = null, - TF_DataType dtype = TF_DataType.TF_FLOAT) => new Zeros(shape: shape, + TF_DataType dtype = TF_DataType.TF_FLOAT) => new Zeros(shape: shape, dtype: dtype); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.keras.cs b/src/TensorFlowNET.Core/APIs/tf.keras.cs index ec3af440..7b3d4c22 100644 --- a/src/TensorFlowNET.Core/APIs/tf.keras.cs +++ b/src/TensorFlowNET.Core/APIs/tf.keras.cs @@ -14,8 +14,6 @@ limitations under the License. ******************************************************************************/ -using NumSharp; - namespace Tensorflow { public partial class tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.layers.cs b/src/TensorFlowNET.Core/APIs/tf.layers.cs index 7330e957..11dae546 100644 --- a/src/TensorFlowNET.Core/APIs/tf.layers.cs +++ b/src/TensorFlowNET.Core/APIs/tf.layers.cs @@ -14,14 +14,11 @@ limitations under the License. ******************************************************************************/ -using System; using System.Collections.Generic; using System.Linq; -using NumSharp; using Tensorflow.Keras; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Layers; -using Tensorflow.Operations.Activation; using static Tensorflow.Binding; namespace Tensorflow @@ -37,7 +34,7 @@ namespace Tensorflow int[] kernel_size, int[] strides = null, string padding = "valid", - string data_format= "channels_last", + string data_format = "channels_last", int[] dilation_rate = null, bool use_bias = true, Activation activation = null, @@ -219,7 +216,7 @@ namespace Tensorflow if (inputs.shape.Length == 0) throw new ValueError($"Input 0 of layer flatten is incompatible with the layer: : expected min_ndim={1}, found ndim={0}. Full shape received: ()"); - var premutation = new List() {0}; + var premutation = new List() { 0 }; if (data_format == "channels_first" && inputs.NDims > 1) { premutation.AddRange(Binding.range(2, inputs.NDims)); @@ -234,16 +231,17 @@ namespace Tensorflow int[] compute_output_shape(int[] inputshape) { if (inputshape == null || inputshape.Length == 0) - inputshape = new int[] {1}; + inputshape = new int[] { 1 }; if (inputshape.Skip(1).All(d => d > 0)) { int[] output_shape = new int[2]; output_shape[0] = inputshape[0]; - output_shape[1] = inputshape.Skip(1).Aggregate(1, (acc, rhs) => acc*rhs); //calculate size of all the rest dimensions + output_shape[1] = inputshape.Skip(1).Aggregate(1, (acc, rhs) => acc * rhs); //calculate size of all the rest dimensions return output_shape; - } else - return new int[] {inputshape[0], -1}; //-1 == Binding.None + } + else + return new int[] { inputshape[0], -1 }; //-1 == Binding.None } } } diff --git a/src/TensorFlowNET.Core/APIs/tf.math.cs b/src/TensorFlowNET.Core/APIs/tf.math.cs index 22e875cb..9a405b49 100644 --- a/src/TensorFlowNET.Core/APIs/tf.math.cs +++ b/src/TensorFlowNET.Core/APIs/tf.math.cs @@ -14,9 +14,6 @@ limitations under the License. ******************************************************************************/ -using Tensorflow.Eager; -using Tensorflow.Operations; - namespace Tensorflow { public partial class tensorflow @@ -52,7 +49,7 @@ namespace Tensorflow public Tensor add(Tensor a, Tensor b, string name = null) => gen_math_ops.add(a, b, name: name); - public Tensor add(Tx a, Ty b, string name = null) + public Tensor add(Tx a, Ty b, string name = null) => gen_math_ops.add(a, b, name: name); /// @@ -233,7 +230,7 @@ namespace Tensorflow /// public Tensor _clip_by_value(Tensor t, Tensor clip_value_min, Tensor clip_value_max, string name = null) => gen_math_ops._clip_by_value(t, clip_value_min, clip_value_max); - + /// /// Clips tensor values to a specified min and max. /// @@ -261,16 +258,16 @@ namespace Tensorflow /// Any values less than clip_value_min are set to clip_value_min. Any values /// greater than clip_value_max are set to clip_value_max. /// - public Tensor clip_by_value(Tensor t, T1 clip_value_min, T2 clip_value_max, string name = "ClipByValue") + public Tensor clip_by_value(Tensor t, T1 clip_value_min, T2 clip_value_max, string name = "ClipByValue") => clip_ops.clip_by_value(t, clip_value_min, clip_value_max, name); - + public Tensor sub(Tx a, Ty b, string name = null) => gen_math_ops.sub(a, b, name: name); public Tensor divide(Tensor a, Tensor b) => a / b; - public Tensor sqrt(Tensor a, string name = null) + public Tensor sqrt(Tensor a, string name = null) => gen_math_ops.sqrt(a, name); public Tensor sign(Tensor a, string name = null) @@ -367,7 +364,7 @@ namespace Tensorflow /// /// /// - public Tensor multiply(Tx x, Ty y, string name = null) + public Tensor multiply(Tx x, Ty y, string name = null) => gen_math_ops.mul(x, y, name: name); public Tensor negative(Tensor x, string name = null) @@ -424,7 +421,7 @@ namespace Tensorflow public Tensor real(Tensor input, string name = null) => math_ops.real(input, name); - + /// /// Computes the "logical or" of elements across dimensions of a tensor. /// @@ -478,7 +475,7 @@ namespace Tensorflow /// /// /// - public Tensor reduce_sum(Tensor input, int? axis = null, int? reduction_indices = null, + public Tensor reduce_sum(Tensor input, int? axis = null, int? reduction_indices = null, bool keepdims = false, string name = null) { if (!axis.HasValue && reduction_indices.HasValue && !keepdims) @@ -491,7 +488,7 @@ namespace Tensorflow return math_ops.reduce_sum(input, keepdims: keepdims, name: name); } - public Tensor reduce_sum(Tensor input, TensorShape axis, int? reduction_indices = null, + public Tensor reduce_sum(Tensor input, TensorShape axis, int? reduction_indices = null, bool keepdims = false, string name = null) => math_ops.reduce_sum(input, axis, keepdims: keepdims, name: name); @@ -517,7 +514,7 @@ namespace Tensorflow public Tensor reduce_variance(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) => math_ops.reduce_variance(input_tensor, axis, keepdims, name); - + public Tensor sigmoid(T x, string name = null) => math_ops.sigmoid(x, name: name); @@ -536,7 +533,7 @@ namespace Tensorflow public Tensor round(Tensor x, string name = null) => gen_math_ops.round(x, name: name); - public Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, string name = null) + public Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, string name = null) => math_ops.cast(x, dtype, name); public Tensor cumsum(Tensor x, int axis = 0, bool exclusive = false, bool reverse = false, string name = null) diff --git a/src/TensorFlowNET.Core/APIs/tf.nn.cs b/src/TensorFlowNET.Core/APIs/tf.nn.cs index 38fb267c..f58536cb 100644 --- a/src/TensorFlowNET.Core/APIs/tf.nn.cs +++ b/src/TensorFlowNET.Core/APIs/tf.nn.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using Tensorflow.Operations; using Tensorflow.Operations.Activation; using static Tensorflow.Binding; @@ -27,8 +26,8 @@ namespace Tensorflow public class nn_internal { - public Tensor conv2d(Tensor input, IVariableV1 filter, int[] strides, string padding, bool use_cudnn_on_gpu = true, - string data_format= "NHWC", int[] dilations= null, string name = null) + public Tensor conv2d(Tensor input, IVariableV1 filter, int[] strides, string padding, bool use_cudnn_on_gpu = true, + string data_format = "NHWC", int[] dilations = null, string name = null) { var parameters = new Conv2dParams { @@ -92,9 +91,9 @@ namespace Tensorflow public (Tensor, Tensor) moments(Tensor x, int[] axes, string name = null, - bool keep_dims = false) => nn_impl.moments(x, - axes, - name: name, + bool keep_dims = false) => nn_impl.moments(x, + axes, + name: name, keep_dims: keep_dims); public Tensor embedding_lookup(IVariableV1 @params, @@ -121,7 +120,7 @@ namespace Tensorflow public Tensor tanh(Tensor x, string name = null) => gen_nn_ops.tanh(x, name); - public Tensor relu(Tensor features, string name = null) + public Tensor relu(Tensor features, string name = null) => gen_nn_ops.relu(features, name); public Tensor[] fused_batch_norm(Tensor x, @@ -140,7 +139,7 @@ namespace Tensorflow public IPoolFunction max_pool_fn => new MaxPoolFunction(); - public Tensor max_pool(Tensor value, int[] ksize, int[] strides, string padding, string data_format = "NHWC", string name = null) + public Tensor max_pool(Tensor value, int[] ksize, int[] strides, string padding, string data_format = "NHWC", string name = null) => nn_ops.max_pool(value, ksize, strides, padding, data_format: data_format, name: name); public Tensor in_top_k(Tensor predictions, Tensor targets, int k, string name = "InTopK") @@ -183,7 +182,7 @@ namespace Tensorflow public Tensor softmax(Tensor logits, int axis = -1, string name = null) => gen_nn_ops.softmax(logits, name); - + /// /// Computes sparse softmax cross entropy between `logits` and `labels`. diff --git a/src/TensorFlowNET.Core/APIs/tf.ops.cs b/src/TensorFlowNET.Core/APIs/tf.ops.cs index d8109676..4308ff91 100644 --- a/src/TensorFlowNET.Core/APIs/tf.ops.cs +++ b/src/TensorFlowNET.Core/APIs/tf.ops.cs @@ -27,7 +27,7 @@ namespace Tensorflow public void add_to_collections(List names, T value) => get_default_graph().add_to_collections(names, value); - public Tensor assign(Tensor @ref, object value, bool validate_shape = true, bool use_locking = true, string name = null) + public Tensor assign(Tensor @ref, object value, bool validate_shape = true, bool use_locking = true, string name = null) => state_ops.assign(@ref, value, validate_shape, use_locking, name); public Tensor assign(IVariableV1 @ref, object value, bool validate_shape = true, bool use_locking = true, string name = null) @@ -36,7 +36,7 @@ namespace Tensorflow public void device(string device_name) => get_default_graph().device(device_name); - public List get_collection(string key, string scope = "") + public List get_collection(string key, string scope = "") => get_default_graph().get_collection(key, scope: scope); /// @@ -54,7 +54,7 @@ namespace Tensorflow /// The default name to use if the name argument is None. /// The list of Tensor arguments that are passed to the op function. /// The scope name. - public ops.NameScope name_scope(string name, string default_name = "", object values = null) + public ops.NameScope name_scope(string name, string default_name = "", object values = null) => new ops.NameScope(name, default_name, values); /// diff --git a/src/TensorFlowNET.Core/APIs/tf.optimizers.cs b/src/TensorFlowNET.Core/APIs/tf.optimizers.cs index ceccca5b..8385b57d 100644 --- a/src/TensorFlowNET.Core/APIs/tf.optimizers.cs +++ b/src/TensorFlowNET.Core/APIs/tf.optimizers.cs @@ -14,8 +14,6 @@ limitations under the License. ******************************************************************************/ -using Tensorflow.Keras; -using Tensorflow.Keras.Engine; using Tensorflow.Keras.Optimizers; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.queue.cs b/src/TensorFlowNET.Core/APIs/tf.queue.cs index 91947e5b..e3258813 100644 --- a/src/TensorFlowNET.Core/APIs/tf.queue.cs +++ b/src/TensorFlowNET.Core/APIs/tf.queue.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using Tensorflow.Queues; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.random.cs b/src/TensorFlowNET.Core/APIs/tf.random.cs index a8c18808..bd74c8fd 100644 --- a/src/TensorFlowNET.Core/APIs/tf.random.cs +++ b/src/TensorFlowNET.Core/APIs/tf.random.cs @@ -97,7 +97,7 @@ namespace Tensorflow public Tensor multinomial(Tensor logits, int num_samples, int? seed = null, string name = null, TF_DataType output_dtype = TF_DataType.DtInvalid) - => random_ops.multinomial(logits, num_samples, seed: seed, + => random_ops.multinomial(logits, num_samples, seed: seed, name: name, output_dtype: output_dtype); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.sparse.cs b/src/TensorFlowNET.Core/APIs/tf.sparse.cs index c615a614..11f6a55d 100644 --- a/src/TensorFlowNET.Core/APIs/tf.sparse.cs +++ b/src/TensorFlowNET.Core/APIs/tf.sparse.cs @@ -52,7 +52,7 @@ namespace Tensorflow bool validate_indices = true, string name = null) => gen_sparse_ops.sparse_to_dense(sparse_indices, - output_shape, + output_shape, sparse_values, default_value: default_value, validate_indices: validate_indices, diff --git a/src/TensorFlowNET.Core/APIs/tf.strings.cs b/src/TensorFlowNET.Core/APIs/tf.strings.cs index e19136a9..be0cf765 100644 --- a/src/TensorFlowNET.Core/APIs/tf.strings.cs +++ b/src/TensorFlowNET.Core/APIs/tf.strings.cs @@ -14,9 +14,6 @@ limitations under the License. ******************************************************************************/ -using System.Collections.Generic; -using Tensorflow.IO; - namespace Tensorflow { public partial class tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.summary.cs b/src/TensorFlowNET.Core/APIs/tf.summary.cs index a2611739..4d0492b6 100644 --- a/src/TensorFlowNET.Core/APIs/tf.summary.cs +++ b/src/TensorFlowNET.Core/APIs/tf.summary.cs @@ -20,7 +20,7 @@ namespace Tensorflow { public Summaries.Summary summary = new Summaries.Summary(); - public Tensor scalar(string name, Tensor tensor) + public Tensor scalar(string name, Tensor tensor) => summary.scalar(name, tensor); } } diff --git a/src/TensorFlowNET.Core/APIs/tf.tensor.cs b/src/TensorFlowNET.Core/APIs/tf.tensor.cs index 3121e354..a0dac3c7 100644 --- a/src/TensorFlowNET.Core/APIs/tf.tensor.cs +++ b/src/TensorFlowNET.Core/APIs/tf.tensor.cs @@ -18,7 +18,7 @@ namespace Tensorflow { public partial class tensorflow { - public Tensor convert_to_tensor(object value, TF_DataType dtype = TF_DataType.DtInvalid, string name = null, TF_DataType preferred_dtype = TF_DataType.DtInvalid) + public Tensor convert_to_tensor(object value, TF_DataType dtype = TF_DataType.DtInvalid, string name = null, TF_DataType preferred_dtype = TF_DataType.DtInvalid) => ops.convert_to_tensor(value, dtype, name, preferred_dtype); public Tensor strided_slice(Tensor input, Tensor begin, Tensor end, Tensor strides = null, @@ -66,7 +66,7 @@ namespace Tensorflow /// A name for the operation (optional) /// if num_or_size_splits is a scalar returns num_or_size_splits Tensor objects; /// if num_or_size_splits is a 1-D Tensor returns num_or_size_splits.get_shape[0] Tensor objects resulting from splitting value. - public Tensor[] split(Tensor value, int num_split, Tensor axis, string name = null) + public Tensor[] split(Tensor value, int num_split, Tensor axis, string name = null) => array_ops.split( value: value, num_split: num_split, diff --git a/src/TensorFlowNET.Core/APIs/tf.tile.cs b/src/TensorFlowNET.Core/APIs/tf.tile.cs index 0995dc27..71717e9c 100644 --- a/src/TensorFlowNET.Core/APIs/tf.tile.cs +++ b/src/TensorFlowNET.Core/APIs/tf.tile.cs @@ -14,8 +14,6 @@ limitations under the License. ******************************************************************************/ -using NumSharp; - namespace Tensorflow { public partial class tensorflow diff --git a/src/TensorFlowNET.Core/APIs/tf.train.cs b/src/TensorFlowNET.Core/APIs/tf.train.cs index 3a9103ce..9db0b8eb 100644 --- a/src/TensorFlowNET.Core/APIs/tf.train.cs +++ b/src/TensorFlowNET.Core/APIs/tf.train.cs @@ -32,14 +32,14 @@ namespace Tensorflow public IVariableV1 get_global_step(Graph graph) => TrainingUtil.get_global_step(graph); - public Optimizer GradientDescentOptimizer(float learning_rate) + public Optimizer GradientDescentOptimizer(float learning_rate) => new GradientDescentOptimizer(learning_rate); public Optimizer GradientDescentOptimizer(Tensor learning_rate) => new GradientDescentOptimizer(learning_rate); - public Optimizer AdamOptimizer(float learning_rate, float epsilon = 1e-8f, string name = "Adam") - => new AdamOptimizer(learning_rate, epsilon:epsilon, name: name); + public Optimizer AdamOptimizer(float learning_rate, float epsilon = 1e-8f, string name = "Adam") + => new AdamOptimizer(learning_rate, epsilon: epsilon, name: name); public Optimizer AdamOptimizer(float learning_rate, TF_DataType dtype, string name = "Adam") => new AdamOptimizer(learning_rate, name: name, dtype: dtype); @@ -53,10 +53,10 @@ namespace Tensorflow public ExponentialMovingAverage ExponentialMovingAverage(float decay) => new ExponentialMovingAverage(decay); - public Saver Saver(IVariableV1[] var_list = null, int max_to_keep = 5) + public Saver Saver(IVariableV1[] var_list = null, int max_to_keep = 5) => new Saver(var_list: var_list, max_to_keep: max_to_keep); - public string write_graph(Graph graph, string logdir, string name, bool as_text = true) + public string write_graph(Graph graph, string logdir, string name, bool as_text = true) => graph_io.write_graph(graph, logdir, name, as_text); public Graph load_graph(string freeze_graph_pb) diff --git a/src/TensorFlowNET.Core/Attributes/c_api.ops.cs b/src/TensorFlowNET.Core/Attributes/c_api.ops.cs index 8480e92a..1476d4d3 100644 --- a/src/TensorFlowNET.Core/Attributes/c_api.ops.cs +++ b/src/TensorFlowNET.Core/Attributes/c_api.ops.cs @@ -47,7 +47,7 @@ namespace Tensorflow /// TF_Status* [DllImport(TensorFlowLibName)] public static extern void TF_OperationGetAttrString(IntPtr oper, string attr_name, IntPtr value, uint max_length, SafeStatusHandle status); - + /// /// Sets `output_attr_value` to the binary-serialized AttrValue proto /// representation of the value of the `attr_name` attr of `oper`. diff --git a/src/TensorFlowNET.Core/Binding.FuncTools.cs b/src/TensorFlowNET.Core/Binding.FuncTools.cs index 8705cf44..42a7b4ef 100644 --- a/src/TensorFlowNET.Core/Binding.FuncTools.cs +++ b/src/TensorFlowNET.Core/Binding.FuncTools.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Binding.Util.cs b/src/TensorFlowNET.Core/Binding.Util.cs index 3dcd1ad7..503ee131 100644 --- a/src/TensorFlowNET.Core/Binding.Util.cs +++ b/src/TensorFlowNET.Core/Binding.Util.cs @@ -15,14 +15,13 @@ ******************************************************************************/ using NumSharp; +using NumSharp.Utilities; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; -using NumSharp.Utilities; -using System.Runtime.CompilerServices; namespace Tensorflow { @@ -32,8 +31,8 @@ namespace Tensorflow public static partial class Binding { public static T2 get(this Dictionary dict, T1 key) - => key == null ? - default : + => key == null ? + default : (dict.ContainsKey(key) ? dict[key] : default); public static void Update(this IList list, T element) @@ -71,7 +70,7 @@ namespace Tensorflow case NDArray nd: return nd.ToString(false); case Array arr: - if (arr.Rank!=1 || arr.GetType().GetElementType()?.IsArray == true) + if (arr.Rank != 1 || arr.GetType().GetElementType()?.IsArray == true) arr = Arrays.Flatten(arr); var objs = toObjectArray(arr); return $"[{string.Join(", ", objs.Select(_tostring))}]"; @@ -105,7 +104,7 @@ namespace Tensorflow return; } - foreach(var obj in objects) + foreach (var obj in objects) { } @@ -239,13 +238,13 @@ namespace Tensorflow yield return (t1[i], t2[i], t3[i]); } - public static IEnumerable<(T1, T2)> zip(NDArray t1, NDArray t2) - where T1: unmanaged - where T2: unmanaged + public static IEnumerable<(T1, T2)> zip(NDArray t1, NDArray t2) + where T1 : unmanaged + where T2 : unmanaged { var a = t1.AsIterator(); var b = t2.AsIterator(); - while(a.HasNext() && b.HasNext()) + while (a.HasNext() && b.HasNext()) yield return (a.MoveNext(), b.MoveNext()); } @@ -390,7 +389,8 @@ namespace Tensorflow { yield return flds[i].GetValue(tuple); } - } else + } + else { throw new System.Exception("Expected Tuple."); } @@ -404,7 +404,7 @@ namespace Tensorflow public static bool isinstance(object Item1, object tuple) { foreach (var t in TupleToEnumerable(tuple)) - if (isinstance(Item1, (Type) t)) + if (isinstance(Item1, (Type)t)) return true; return false; } diff --git a/src/TensorFlowNET.Core/Binding.cs b/src/TensorFlowNET.Core/Binding.cs index 8fc8a5d4..3ca2b3e6 100644 --- a/src/TensorFlowNET.Core/Binding.cs +++ b/src/TensorFlowNET.Core/Binding.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Dynamic; -using System.Text; +using System.Diagnostics; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Buffers/Buffer.cs b/src/TensorFlowNET.Core/Buffers/Buffer.cs index a537ce9f..87e808af 100644 --- a/src/TensorFlowNET.Core/Buffers/Buffer.cs +++ b/src/TensorFlowNET.Core/Buffers/Buffer.cs @@ -17,7 +17,6 @@ using NumSharp.Backends.Unmanaged; using System; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using Tensorflow.Util; using static Tensorflow.c_api; diff --git a/src/TensorFlowNET.Core/Clustering/_InitializeClustersOpFactory.cs b/src/TensorFlowNET.Core/Clustering/_InitializeClustersOpFactory.cs index 2e86a5ea..adb26ef2 100644 --- a/src/TensorFlowNET.Core/Clustering/_InitializeClustersOpFactory.cs +++ b/src/TensorFlowNET.Core/Clustering/_InitializeClustersOpFactory.cs @@ -89,7 +89,7 @@ namespace Tensorflow.Clustering public Tensor op() { var x = control_flow_ops.cond(gen_math_ops.equal(_num_remaining, 0), - () => + () => { return check_ops.assert_equal(_cluster_centers_initialized, true); }, diff --git a/src/TensorFlowNET.Core/Contexts/Context.cs b/src/TensorFlowNET.Core/Contexts/Context.cs index bb34d209..65988b87 100644 --- a/src/TensorFlowNET.Core/Contexts/Context.cs +++ b/src/TensorFlowNET.Core/Contexts/Context.cs @@ -70,8 +70,8 @@ namespace Tensorflow.Contexts => context_switches.Current().EagerMode; public string shared_name(string name = null) - => !string.IsNullOrEmpty(name) || !executing_eagerly() ? - name : + => !string.IsNullOrEmpty(name) || !executing_eagerly() ? + name : "cd2c89b7-88b7-44c8-ad83-06c2a9158347"; public void graph_mode() diff --git a/src/TensorFlowNET.Core/Contexts/ContextSwitch.cs b/src/TensorFlowNET.Core/Contexts/ContextSwitch.cs index c55d5281..02f2fd9c 100644 --- a/src/TensorFlowNET.Core/Contexts/ContextSwitch.cs +++ b/src/TensorFlowNET.Core/Contexts/ContextSwitch.cs @@ -15,8 +15,6 @@ ******************************************************************************/ using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow.Contexts { diff --git a/src/TensorFlowNET.Core/Contexts/ContextSwitchStack.cs b/src/TensorFlowNET.Core/Contexts/ContextSwitchStack.cs index 7d758c0d..e4011b68 100644 --- a/src/TensorFlowNET.Core/Contexts/ContextSwitchStack.cs +++ b/src/TensorFlowNET.Core/Contexts/ContextSwitchStack.cs @@ -14,9 +14,7 @@ limitations under the License. ******************************************************************************/ -using System; using System.Collections.Generic; -using System.Text; namespace Tensorflow.Contexts { diff --git a/src/TensorFlowNET.Core/Contrib/Learn/Estimators/tensor_signature.cs b/src/TensorFlowNET.Core/Contrib/Learn/Estimators/tensor_signature.cs index 60426af6..b2e7dd75 100644 --- a/src/TensorFlowNET.Core/Contrib/Learn/Estimators/tensor_signature.cs +++ b/src/TensorFlowNET.Core/Contrib/Learn/Estimators/tensor_signature.cs @@ -1,5 +1,5 @@ -using System.Linq; -using NumSharp; +using NumSharp; +using System.Linq; using Tensorflow.Framework; namespace Tensorflow.Contrib.Learn.Estimators diff --git a/src/TensorFlowNET.Core/Contrib/Train/HParams.cs b/src/TensorFlowNET.Core/Contrib/Train/HParams.cs index bd85ad4c..77eb5923 100644 --- a/src/TensorFlowNET.Core/Contrib/Train/HParams.cs +++ b/src/TensorFlowNET.Core/Contrib/Train/HParams.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Contrib.Train +namespace Tensorflow.Contrib.Train { /// /// Class to hold a set of hyperparameters as name-value pairs. diff --git a/src/TensorFlowNET.Core/Data/BatchDataset.cs b/src/TensorFlowNET.Core/Data/BatchDataset.cs index 331cc5ba..874c433d 100644 --- a/src/TensorFlowNET.Core/Data/BatchDataset.cs +++ b/src/TensorFlowNET.Core/Data/BatchDataset.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using Tensorflow.Framework.Models; using static Tensorflow.Binding; namespace Tensorflow @@ -15,13 +12,13 @@ namespace Tensorflow Tensor _batch_size; Tensor _drop_remainder; - public BatchDataset(IDatasetV2 input_dataset, int batch_size, bool drop_remainder = false) : + public BatchDataset(IDatasetV2 input_dataset, int batch_size, bool drop_remainder = false) : base(input_dataset) { _input_dataset = input_dataset; _batch_size = tf.convert_to_tensor(batch_size, dtype: TF_DataType.TF_INT64, name: "batch_size"); _drop_remainder = tf.convert_to_tensor(drop_remainder, dtype: TF_DataType.TF_BOOL, name: "drop_remainder"); - + if (drop_remainder) { throw new NotImplementedException(""); diff --git a/src/TensorFlowNET.Core/Data/CacheDataset.cs b/src/TensorFlowNET.Core/Data/CacheDataset.cs index b5766c25..a85d58f7 100644 --- a/src/TensorFlowNET.Core/Data/CacheDataset.cs +++ b/src/TensorFlowNET.Core/Data/CacheDataset.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/DataSetBase.cs b/src/TensorFlowNET.Core/Data/DataSetBase.cs index cf8eaf6a..d09df21b 100644 --- a/src/TensorFlowNET.Core/Data/DataSetBase.cs +++ b/src/TensorFlowNET.Core/Data/DataSetBase.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NumSharp; +using NumSharp; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/DatasetManager.cs b/src/TensorFlowNET.Core/Data/DatasetManager.cs index 95c722db..16f89642 100644 --- a/src/TensorFlowNET.Core/Data/DatasetManager.cs +++ b/src/TensorFlowNET.Core/Data/DatasetManager.cs @@ -1,7 +1,5 @@ using NumSharp; -using System; using System.Collections.Generic; -using System.Text; using Tensorflow.Data; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Data/DatasetOps.cs b/src/TensorFlowNET.Core/Data/DatasetOps.cs index 4035ee4f..171e90f8 100644 --- a/src/TensorFlowNET.Core/Data/DatasetOps.cs +++ b/src/TensorFlowNET.Core/Data/DatasetOps.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public class DatasetOps { diff --git a/src/TensorFlowNET.Core/Data/DatasetOptions.cs b/src/TensorFlowNET.Core/Data/DatasetOptions.cs index 4b1b0b56..189b80ce 100644 --- a/src/TensorFlowNET.Core/Data/DatasetOptions.cs +++ b/src/TensorFlowNET.Core/Data/DatasetOptions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public class DatasetOptions { diff --git a/src/TensorFlowNET.Core/Data/DatasetSource.cs b/src/TensorFlowNET.Core/Data/DatasetSource.cs index bf503ec8..c235fcf6 100644 --- a/src/TensorFlowNET.Core/Data/DatasetSource.cs +++ b/src/TensorFlowNET.Core/Data/DatasetSource.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Tensorflow.Framework.Models; - -namespace Tensorflow +namespace Tensorflow { public class DatasetSource : DatasetV2 { diff --git a/src/TensorFlowNET.Core/Data/DatasetV2.cs b/src/TensorFlowNET.Core/Data/DatasetV2.cs index e5e6eb75..104789df 100644 --- a/src/TensorFlowNET.Core/Data/DatasetV2.cs +++ b/src/TensorFlowNET.Core/Data/DatasetV2.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Framework.Models; namespace Tensorflow @@ -18,9 +17,9 @@ namespace Tensorflow public TensorSpec[] structure { get; set; } public TensorShape[] output_shapes => structure.Select(x => x.shape).ToArray(); - + public TF_DataType[] output_types => structure.Select(x => x.dtype).ToArray(); - + public TensorSpec[] element_spec => structure; public IDatasetV2 cache(string filename = "") @@ -54,7 +53,7 @@ namespace Tensorflow bool use_inter_op_parallelism = true, bool preserve_cardinality = true, bool use_legacy_function = false) - => new MapDataset(this, + => new MapDataset(this, map_func, use_inter_op_parallelism: use_inter_op_parallelism, preserve_cardinality: preserve_cardinality, diff --git a/src/TensorFlowNET.Core/Data/Datasets.cs b/src/TensorFlowNET.Core/Data/Datasets.cs index 361f74ee..81ce6974 100644 --- a/src/TensorFlowNET.Core/Data/Datasets.cs +++ b/src/TensorFlowNET.Core/Data/Datasets.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NumSharp; +using NumSharp; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/FlatMapDataset.cs b/src/TensorFlowNET.Core/Data/FlatMapDataset.cs index 202a67f9..8b1872c3 100644 --- a/src/TensorFlowNET.Core/Data/FlatMapDataset.cs +++ b/src/TensorFlowNET.Core/Data/FlatMapDataset.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Tensorflow.Functions; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Data/GeneratorDataset.cs b/src/TensorFlowNET.Core/Data/GeneratorDataset.cs index 937c1eb4..b1c46d3b 100644 --- a/src/TensorFlowNET.Core/Data/GeneratorDataset.cs +++ b/src/TensorFlowNET.Core/Data/GeneratorDataset.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Data +namespace Tensorflow.Data { public class GeneratorDataset : DatasetSource { diff --git a/src/TensorFlowNET.Core/Data/IDataSet.cs b/src/TensorFlowNET.Core/Data/IDataSet.cs index 0b496f96..eceb21bf 100644 --- a/src/TensorFlowNET.Core/Data/IDataSet.cs +++ b/src/TensorFlowNET.Core/Data/IDataSet.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NumSharp; +using NumSharp; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/IDatasetV2.cs b/src/TensorFlowNET.Core/Data/IDatasetV2.cs index 2a96dca2..fc47c832 100644 --- a/src/TensorFlowNET.Core/Data/IDatasetV2.cs +++ b/src/TensorFlowNET.Core/Data/IDatasetV2.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq.Expressions; -using System.Text; using Tensorflow.Framework.Models; namespace Tensorflow @@ -23,7 +21,7 @@ namespace Tensorflow /// /// /// - IDatasetV2 cache(string filename=""); + IDatasetV2 cache(string filename = ""); /// /// @@ -57,12 +55,12 @@ namespace Tensorflow IDatasetV2 optimize(string[] optimizations, string[] optimization_configs); - IDatasetV2 map(Func map_func, + IDatasetV2 map(Func map_func, bool use_inter_op_parallelism = true, bool preserve_cardinality = false, bool use_legacy_function = false); - IDatasetV2 map(Func map_func, + IDatasetV2 map(Func map_func, int num_parallel_calls = -1); IDatasetV2 flat_map(Func map_func); diff --git a/src/TensorFlowNET.Core/Data/IModelLoader.cs b/src/TensorFlowNET.Core/Data/IModelLoader.cs index e54a5af2..fd94dbe3 100644 --- a/src/TensorFlowNET.Core/Data/IModelLoader.cs +++ b/src/TensorFlowNET.Core/Data/IModelLoader.cs @@ -1,8 +1,4 @@ -using System; -using System.Threading.Tasks; -using System.Collections.Generic; -using System.Text; -using NumSharp; +using System.Threading.Tasks; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/IteratorBase.cs b/src/TensorFlowNET.Core/Data/IteratorBase.cs index 159c0272..6a2c22ee 100644 --- a/src/TensorFlowNET.Core/Data/IteratorBase.cs +++ b/src/TensorFlowNET.Core/Data/IteratorBase.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public class IteratorBase { diff --git a/src/TensorFlowNET.Core/Data/IteratorResourceDeleter.cs b/src/TensorFlowNET.Core/Data/IteratorResourceDeleter.cs index 2c981c81..0e434260 100644 --- a/src/TensorFlowNET.Core/Data/IteratorResourceDeleter.cs +++ b/src/TensorFlowNET.Core/Data/IteratorResourceDeleter.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/MapDataset.cs b/src/TensorFlowNET.Core/Data/MapDataset.cs index daa11202..231e613e 100644 --- a/src/TensorFlowNET.Core/Data/MapDataset.cs +++ b/src/TensorFlowNET.Core/Data/MapDataset.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Tensorflow.Functions; -using Tensorflow.Graphs; -using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/MnistDataSet.cs b/src/TensorFlowNET.Core/Data/MnistDataSet.cs index 7e0f61bc..3c5640fa 100644 --- a/src/TensorFlowNET.Core/Data/MnistDataSet.cs +++ b/src/TensorFlowNET.Core/Data/MnistDataSet.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; +using NumSharp; +using System; using System.Diagnostics; -using System.Text; -using NumSharp; namespace Tensorflow { @@ -40,7 +38,7 @@ namespace Tensorflow var start = IndexInEpoch; // Shuffle for the first epoch - if(EpochsCompleted == 0 && start == 0 && shuffle) + if (EpochsCompleted == 0 && start == 0 && shuffle) { var perm0 = np.arange(NumOfExamples); np.random.shuffle(perm0); diff --git a/src/TensorFlowNET.Core/Data/MnistModelLoader.cs b/src/TensorFlowNET.Core/Data/MnistModelLoader.cs index 4940509a..ebef9733 100644 --- a/src/TensorFlowNET.Core/Data/MnistModelLoader.cs +++ b/src/TensorFlowNET.Core/Data/MnistModelLoader.cs @@ -1,9 +1,7 @@ -using System; -using System.Threading.Tasks; -using System.Collections.Generic; -using System.Text; +using NumSharp; +using System; using System.IO; -using NumSharp; +using System.Threading.Tasks; namespace Tensorflow { @@ -90,7 +88,7 @@ namespace Tensorflow var validationImages = trainImages[np.arange(validationSize)]; var validationLabels = trainLabels[np.arange(validationSize)]; - + trainImages = trainImages[np.arange(validationSize, end)]; trainLabels = trainLabels[np.arange(validationSize, end)]; @@ -114,8 +112,8 @@ namespace Tensorflow var magic = Read32(bytestream); if (magic != 2051) throw new Exception($"Invalid magic number {magic} in MNIST image file: {file}"); - - var num_images = Read32(bytestream); + + var num_images = Read32(bytestream); num_images = limit == null ? num_images : Math.Min(num_images, (int)limit); var rows = Read32(bytestream); @@ -136,25 +134,25 @@ namespace Tensorflow { if (!Path.IsPathRooted(file)) file = Path.Combine(AppContext.BaseDirectory, file); - + using (var bytestream = new FileStream(file, FileMode.Open)) { var magic = Read32(bytestream); if (magic != 2049) throw new Exception($"Invalid magic number {magic} in MNIST label file: {file}"); - + var num_items = Read32(bytestream); num_items = limit == null ? num_items : Math.Min(num_items, (int)limit); - + var buf = new byte[num_items]; bytestream.Read(buf, 0, buf.Length); - + var labels = np.frombuffer(buf, np.uint8); if (one_hot) return DenseToOneHot(labels, num_classes); - + return labels; } } diff --git a/src/TensorFlowNET.Core/Data/ModelDataset.cs b/src/TensorFlowNET.Core/Data/ModelDataset.cs index 3e44b0b2..97a6ea24 100644 --- a/src/TensorFlowNET.Core/Data/ModelDataset.cs +++ b/src/TensorFlowNET.Core/Data/ModelDataset.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Framework.Models; +using Tensorflow.Framework.Models; namespace Tensorflow { @@ -10,8 +7,8 @@ namespace Tensorflow /// public class ModelDataset : UnaryUnchangedStructureDataset { - public ModelDataset(IDatasetV2 input_dataset, - AutotuneAlgorithm algorithm, + public ModelDataset(IDatasetV2 input_dataset, + AutotuneAlgorithm algorithm, long cpu_budget) : base(input_dataset) { diff --git a/src/TensorFlowNET.Core/Data/ModelLoadSetting.cs b/src/TensorFlowNET.Core/Data/ModelLoadSetting.cs index 94a5bec0..d053d252 100644 --- a/src/TensorFlowNET.Core/Data/ModelLoadSetting.cs +++ b/src/TensorFlowNET.Core/Data/ModelLoadSetting.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using NumSharp; namespace Tensorflow { @@ -12,7 +9,7 @@ namespace Tensorflow public Type DataType { get; set; } = typeof(float); public bool ReShape { get; set; } public int ValidationSize { get; set; } = 5000; - public int? TrainSize { get; set; } + public int? TrainSize { get; set; } public int? TestSize { get; set; } public string SourceUrl { get; set; } public bool ShowProgressInConsole { get; set; } diff --git a/src/TensorFlowNET.Core/Data/OptimizeDataset.cs b/src/TensorFlowNET.Core/Data/OptimizeDataset.cs index 818980f4..3ae0f947 100644 --- a/src/TensorFlowNET.Core/Data/OptimizeDataset.cs +++ b/src/TensorFlowNET.Core/Data/OptimizeDataset.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow { @@ -12,9 +9,9 @@ namespace Tensorflow { Tensor _optimizations; - public OptimizeDataset(IDatasetV2 dataset, - string[] optimizations = null, - string[] optimization_configs = null) : + public OptimizeDataset(IDatasetV2 dataset, + string[] optimizations = null, + string[] optimization_configs = null) : base(dataset) { if (optimizations == null) @@ -26,7 +23,7 @@ namespace Tensorflow variant_tensor = ops.optimize_dataset( _input_dataset.variant_tensor, _optimizations, - output_types, + output_types, output_shapes, optimization_configs: optimization_configs); } diff --git a/src/TensorFlowNET.Core/Data/OptionsDataset.cs b/src/TensorFlowNET.Core/Data/OptionsDataset.cs index cce22e65..ae63814f 100644 --- a/src/TensorFlowNET.Core/Data/OptionsDataset.cs +++ b/src/TensorFlowNET.Core/Data/OptionsDataset.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { /// /// An identity `Dataset` that stores options. @@ -11,7 +7,7 @@ namespace Tensorflow { DatasetOptions options; - public OptionsDataset(IDatasetV2 input_dataset, DatasetOptions options) + public OptionsDataset(IDatasetV2 input_dataset, DatasetOptions options) : base(input_dataset) { this.options = options; diff --git a/src/TensorFlowNET.Core/Data/OwnedIterator.cs b/src/TensorFlowNET.Core/Data/OwnedIterator.cs index eda7fae3..6327d174 100644 --- a/src/TensorFlowNET.Core/Data/OwnedIterator.cs +++ b/src/TensorFlowNET.Core/Data/OwnedIterator.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Framework.Models; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Data/ParallelMapDataset.cs b/src/TensorFlowNET.Core/Data/ParallelMapDataset.cs index c84eb328..cd9cd3df 100644 --- a/src/TensorFlowNET.Core/Data/ParallelMapDataset.cs +++ b/src/TensorFlowNET.Core/Data/ParallelMapDataset.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Functions; using static Tensorflow.Binding; @@ -10,14 +8,14 @@ namespace Tensorflow //A `Dataset` that maps a function over elements in its input in parallel. public class ParallelMapDataset : UnaryDataset { - public ParallelMapDataset(IDatasetV2 input_dataset, + public ParallelMapDataset(IDatasetV2 input_dataset, Func map_func, int num_parallel_calls = -1, bool use_inter_op_parallelism = true, bool preserve_cardinality = false, bool use_legacy_function = false) : base(input_dataset) { - var func = new ConcreteFunction(map_func, + var func = new ConcreteFunction(map_func, input_dataset.element_spec.Select(x => x.dtype).ToArray(), input_dataset.element_spec.Select(x => x.shape).ToArray()); diff --git a/src/TensorFlowNET.Core/Data/PrefetchDataset.cs b/src/TensorFlowNET.Core/Data/PrefetchDataset.cs index 0a8c82dc..ed360dec 100644 --- a/src/TensorFlowNET.Core/Data/PrefetchDataset.cs +++ b/src/TensorFlowNET.Core/Data/PrefetchDataset.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow { @@ -13,7 +10,7 @@ namespace Tensorflow Tensor _buffer_size; public PrefetchDataset(IDatasetV2 input_dataset, - long buffer_size = -1, + long buffer_size = -1, int? slack_period = null) : base(input_dataset) { diff --git a/src/TensorFlowNET.Core/Data/RangeDataset.cs b/src/TensorFlowNET.Core/Data/RangeDataset.cs index 72ef91b8..060d2310 100644 --- a/src/TensorFlowNET.Core/Data/RangeDataset.cs +++ b/src/TensorFlowNET.Core/Data/RangeDataset.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Framework.Models; +using Tensorflow.Framework.Models; using static Tensorflow.Binding; namespace Tensorflow.Data @@ -12,8 +9,8 @@ namespace Tensorflow.Data Tensor step; Tensor stop; - public RangeDataset(int stop, - int start = 0, + public RangeDataset(int stop, + int start = 0, int step = 1, TF_DataType output_type = TF_DataType.TF_INT64) { diff --git a/src/TensorFlowNET.Core/Data/RepeatDataset.cs b/src/TensorFlowNET.Core/Data/RepeatDataset.cs index ba3e9727..0898c452 100644 --- a/src/TensorFlowNET.Core/Data/RepeatDataset.cs +++ b/src/TensorFlowNET.Core/Data/RepeatDataset.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { /// /// A `Dataset` that repeats its input several times. diff --git a/src/TensorFlowNET.Core/Data/ShardDataset.cs b/src/TensorFlowNET.Core/Data/ShardDataset.cs index 4bb8ebfc..673fe2c4 100644 --- a/src/TensorFlowNET.Core/Data/ShardDataset.cs +++ b/src/TensorFlowNET.Core/Data/ShardDataset.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/ShuffleDataset.cs b/src/TensorFlowNET.Core/Data/ShuffleDataset.cs index 1804ba53..8d22ab91 100644 --- a/src/TensorFlowNET.Core/Data/ShuffleDataset.cs +++ b/src/TensorFlowNET.Core/Data/ShuffleDataset.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow @@ -15,9 +13,9 @@ namespace Tensorflow Tensor _seed2; bool _reshuffle_each_iteration; - public ShuffleDataset(IDatasetV2 input_dataset, - long buffer_size, - int? seed = null, + public ShuffleDataset(IDatasetV2 input_dataset, + long buffer_size, + int? seed = null, bool reshuffle_each_iteration = true) : base(input_dataset) { diff --git a/src/TensorFlowNET.Core/Data/SkipDataset.cs b/src/TensorFlowNET.Core/Data/SkipDataset.cs index 1bcfd3fa..48746f02 100644 --- a/src/TensorFlowNET.Core/Data/SkipDataset.cs +++ b/src/TensorFlowNET.Core/Data/SkipDataset.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow { @@ -16,7 +13,7 @@ namespace Tensorflow int count) : base(input_dataset) { _count = tf.convert_to_tensor(count, dtype: dtypes.int64, name: "count"); - variant_tensor = ops.skip_dataset(input_dataset.variant_tensor, + variant_tensor = ops.skip_dataset(input_dataset.variant_tensor, _count, output_types, output_shapes); } diff --git a/src/TensorFlowNET.Core/Data/TakeDataset.cs b/src/TensorFlowNET.Core/Data/TakeDataset.cs index 2e5476ff..6c4a49f3 100644 --- a/src/TensorFlowNET.Core/Data/TakeDataset.cs +++ b/src/TensorFlowNET.Core/Data/TakeDataset.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Data/TensorDataset.cs b/src/TensorFlowNET.Core/Data/TensorDataset.cs index a3584886..ac5d397e 100644 --- a/src/TensorFlowNET.Core/Data/TensorDataset.cs +++ b/src/TensorFlowNET.Core/Data/TensorDataset.cs @@ -1,8 +1,5 @@ using NumSharp; -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Data/TensorSliceDataset.cs b/src/TensorFlowNET.Core/Data/TensorSliceDataset.cs index 5de46637..854e6047 100644 --- a/src/TensorFlowNET.Core/Data/TensorSliceDataset.cs +++ b/src/TensorFlowNET.Core/Data/TensorSliceDataset.cs @@ -1,10 +1,5 @@ using NumSharp; -using NumSharp.Utilities; -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using Tensorflow.Framework.Models; using static Tensorflow.Binding; namespace Tensorflow.Data @@ -45,7 +40,7 @@ namespace Tensorflow.Data _tensors = new[] { features, labels }; var batched_spec = _tensors.Select(x => x.ToTensorSpec()).ToArray(); structure = batched_spec.Select(x => x._unbatch()).ToArray(); - + variant_tensor = ops.tensor_slice_dataset(_tensors, output_shapes); } } diff --git a/src/TensorFlowNET.Core/Data/UnaryDataset.cs b/src/TensorFlowNET.Core/Data/UnaryDataset.cs index 3cab9a96..8a95b00e 100644 --- a/src/TensorFlowNET.Core/Data/UnaryDataset.cs +++ b/src/TensorFlowNET.Core/Data/UnaryDataset.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Framework.Models; - -namespace Tensorflow +namespace Tensorflow { /// /// Abstract class representing a dataset with one input. diff --git a/src/TensorFlowNET.Core/Data/UnaryUnchangedStructureDataset.cs b/src/TensorFlowNET.Core/Data/UnaryUnchangedStructureDataset.cs index dd25ab45..31b718f3 100644 --- a/src/TensorFlowNET.Core/Data/UnaryUnchangedStructureDataset.cs +++ b/src/TensorFlowNET.Core/Data/UnaryUnchangedStructureDataset.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { /// /// Represents a unary dataset with the same input and output structure. @@ -12,7 +8,7 @@ namespace Tensorflow public UnaryUnchangedStructureDataset(IDatasetV2 input_dataset) : base(input_dataset) { - + } } } diff --git a/src/TensorFlowNET.Core/Data/Utils.cs b/src/TensorFlowNET.Core/Data/Utils.cs index 46d708b2..3ca6ae23 100644 --- a/src/TensorFlowNET.Core/Data/Utils.cs +++ b/src/TensorFlowNET.Core/Data/Utils.cs @@ -1,12 +1,9 @@ using System; using System.IO; using System.IO.Compression; -using System.Collections.Generic; using System.Net; -using System.Text; using System.Threading; using System.Threading.Tasks; -using Tensorflow.Framework.Models; namespace Tensorflow { @@ -42,9 +39,9 @@ namespace Tensorflow return; } - + Directory.CreateDirectory(dirSaveTo); - + using (var wc = new WebClient()) { await wc.DownloadFileTaskAsync(url, fileSaveTo).ConfigureAwait(false); @@ -73,7 +70,7 @@ namespace Tensorflow { if (showProgressInConsole) Console.WriteLine($"The file {destFileName} already exists"); - } + } using (GZipStream unzipStream = new GZipStream(File.OpenRead(zipFile), CompressionMode.Decompress)) { @@ -86,7 +83,7 @@ namespace Tensorflow unzipStream.Close(); } - } + } public static async Task ShowProgressInConsole(this Task task, bool enable) { @@ -101,12 +98,12 @@ namespace Tensorflow var showProgressTask = ShowProgressInConsole(cts); try - { + { await task; } finally { - cts.Cancel(); + cts.Cancel(); } await showProgressTask; diff --git a/src/TensorFlowNET.Core/Data/ZipDataset.cs b/src/TensorFlowNET.Core/Data/ZipDataset.cs index e7fea1cd..0d1c4f0e 100644 --- a/src/TensorFlowNET.Core/Data/ZipDataset.cs +++ b/src/TensorFlowNET.Core/Data/ZipDataset.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Framework.Models; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/DisposableObject.cs b/src/TensorFlowNET.Core/DisposableObject.cs index a7fc5a2c..6dacca90 100644 --- a/src/TensorFlowNET.Core/DisposableObject.cs +++ b/src/TensorFlowNET.Core/DisposableObject.cs @@ -15,10 +15,8 @@ ******************************************************************************/ using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; -using System.Text; namespace Tensorflow { @@ -77,7 +75,7 @@ namespace Tensorflow public void Dispose() { - lock(this) + lock (this) { internal_dispose(true); GC.SuppressFinalize(this); diff --git a/src/TensorFlowNET.Core/Eager/EagerOperation.cs b/src/TensorFlowNET.Core/Eager/EagerOperation.cs index 13e546c1..3664f187 100644 --- a/src/TensorFlowNET.Core/Eager/EagerOperation.cs +++ b/src/TensorFlowNET.Core/Eager/EagerOperation.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using static Tensorflow.Binding; namespace Tensorflow.Eager { diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.ArgsToMatchingEager.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.ArgsToMatchingEager.cs index 7c3f1307..8a1da87a 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.ArgsToMatchingEager.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.ArgsToMatchingEager.cs @@ -14,10 +14,9 @@ limitations under the License. ******************************************************************************/ -using System.Collections.Generic; using System; +using System.Collections.Generic; using System.Linq; -using static Tensorflow.Binding; using Tensorflow.Contexts; namespace Tensorflow.Eager diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.Execute.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.Execute.cs index 2bb39bad..690d5a9a 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.Execute.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.Execute.cs @@ -14,10 +14,8 @@ limitations under the License. ******************************************************************************/ -using System.Linq; -using System; -using static Tensorflow.Binding; using Tensorflow.Contexts; +using static Tensorflow.Binding; namespace Tensorflow.Eager { diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs index 7e18ea81..e89c710a 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.RecordGradient.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using Tensorflow.Gradients; using static Tensorflow.Binding; using static Tensorflow.tensorflow; @@ -21,7 +18,7 @@ namespace Tensorflow.Eager bool should_record = false; foreach (var tape in tf.GetTapeSet()) { - if(tape.ShouldRecord(input_ids, input_dtypes)) + if (tape.ShouldRecord(input_ids, input_dtypes)) { should_record = true; break; @@ -66,7 +63,7 @@ namespace Tensorflow.Eager bool op_inputs_tuple_created = false; #pragma warning restore CS0219 // Variable is assigned but its value is never used var unused_input_indices = gradient_exclustions.OpGradientUnusedInputIndices(op_name); - if(unused_input_indices != null) + if (unused_input_indices != null) { if (unused_input_indices.Length == 0) op_inputs = new Tensor[0]; @@ -79,7 +76,7 @@ namespace Tensorflow.Eager else op_inputs = inputs; - TapeSetRecordOperation(op_name, inputs, results, input_ids, input_dtypes, + TapeSetRecordOperation(op_name, inputs, results, input_ids, input_dtypes, () => GetGradientFunction(op_name, inputs, attrs, results)); diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.RunCallbacks.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.RunCallbacks.cs index 485cf049..1dfa4046 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.RunCallbacks.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.RunCallbacks.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Eager +namespace Tensorflow.Eager { public partial class EagerRunner { diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_Execute.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_Execute.cs index a4f2f345..9aaae355 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_Execute.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_Execute.cs @@ -15,9 +15,8 @@ ******************************************************************************/ using System.Linq; -using System; -using static Tensorflow.Binding; using Tensorflow.Contexts; +using static Tensorflow.Binding; namespace Tensorflow.Eager { diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs index d1c7eb13..c703aaaa 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_FastPathExecute.cs @@ -1,12 +1,12 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; -using System; -using static Tensorflow.OpDef.Types; -using static Tensorflow.Binding; -using Tensorflow.Util; using System.Runtime.InteropServices; using Tensorflow.Contexts; using Tensorflow.Functions; +using Tensorflow.Util; +using static Tensorflow.Binding; +using static Tensorflow.OpDef.Types; namespace Tensorflow.Eager { @@ -61,7 +61,7 @@ namespace Tensorflow.Eager var attr_value = args[i + 1]; var attr = op_def.Attr.FirstOrDefault(x => x.Name == attr_name); - if(attr != null) + if (attr != null) { flattened_attrs.Add(attr_name); flattened_attrs.Add(attr_value); @@ -89,7 +89,7 @@ namespace Tensorflow.Eager flattened_attrs.Add(len); } attr_list_sizes[input_arg.NumberAttr] = len; - + if (len > 0) { var fast_input_array = (object[])args[i]; @@ -179,7 +179,7 @@ namespace Tensorflow.Eager op = c_api.TFE_NewOp(ctx.Handle, op_or_function_name, status.Handle); thread_local_eager_operation_map[ctx] = op; } - + status.Check(true); return op; } @@ -189,7 +189,7 @@ namespace Tensorflow.Eager //return !GetAccumulatorSet()->empty(); return false; } - + bool HasGradientTape() { return tf.GetTapeSet().Count > 0; @@ -262,7 +262,7 @@ namespace Tensorflow.Eager var key = attrs[i].ToString(); var value = attrs[i + 1]; - byte is_list = 0; + byte is_list = 0; var type = c_api.TFE_OpGetAttrType(op, key, ref is_list, status.Handle); if (!status.ok()) return; if (is_list != 0) @@ -286,8 +286,8 @@ namespace Tensorflow.Eager /// /// /// - void SetOpAttrWithDefaults(Context ctx, SafeOpHandle op, AttrDef attr, - string attr_name, object attr_value, + void SetOpAttrWithDefaults(Context ctx, SafeOpHandle op, AttrDef attr, + string attr_name, object attr_value, Dictionary attr_list_sizes, Status status) { @@ -295,7 +295,7 @@ namespace Tensorflow.Eager var type = c_api.TFE_OpGetAttrType(op, attr_name, ref is_list, status.Handle); if (status.Code != TF_Code.TF_OK) return; - if(attr_value == null) + if (attr_value == null) { if (is_list != 0) #pragma warning disable CS0642 // Possible mistaken empty statement @@ -345,7 +345,7 @@ namespace Tensorflow.Eager c_api.TFE_OpSetAttrShapeList(op, key, dims, num_dims, num_values, status.Handle); Array.ForEach(dims, x => Marshal.FreeHGlobal(x)); } - else if(type == TF_AttrType.TF_ATTR_TYPE && values is TF_DataType[] values2) + else if (type == TF_AttrType.TF_ATTR_TYPE && values is TF_DataType[] values2) { c_api.TFE_OpSetAttrTypeList(op, key, values2, values2.Length); attr_list_sizes[key] = values2.Length; @@ -363,12 +363,12 @@ namespace Tensorflow.Eager return true; } - bool SetOpAttrScalar(Context ctx, SafeOpHandle op, + bool SetOpAttrScalar(Context ctx, SafeOpHandle op, string key, object value, TF_AttrType type, Dictionary attr_list_sizes, Status status) { - switch(type) + switch (type) { case TF_AttrType.TF_ATTR_STRING: c_api.TFE_OpSetAttrString(op, key, value.ToString(), (uint)value.ToString().Length); @@ -394,7 +394,7 @@ namespace Tensorflow.Eager if (value is ConcreteFunction func) c_api.TFE_OpSetAttrFunctionName(op, key, func.Name, func.Name.Length); else - throw new NotImplementedException("TF_AttrType.TF_ATTR_FUNC"); + throw new NotImplementedException("TF_AttrType.TF_ATTR_FUNC"); break; default: throw new NotImplementedException($"SetOpAttrScalar for {type}"); diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_TapeGradient.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_TapeGradient.cs index c850e877..3f15ac55 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_TapeGradient.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TFE_TapeGradient.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System; -using static Tensorflow.OpDef.Types; +using System; using Tensorflow.Gradients; using Tensorflow.Util; @@ -31,7 +28,7 @@ namespace Tensorflow.Eager source_tensors_that_are_targets.Add(target_id, TapeTensorFromTensor(tensor)); } - if(output_gradients != null) + if (output_gradients != null) { throw new NotImplementedException(""); } diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordBackprop.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordBackprop.cs index 64552811..1e764e64 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordBackprop.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordBackprop.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Gradients; using static Tensorflow.Binding; using static Tensorflow.tensorflow; @@ -21,7 +19,7 @@ namespace Tensorflow.Eager return; } - foreach(var tape in tf.GetTapeSet()) + foreach (var tape in tf.GetTapeSet()) { tape.RecordOperation(op_type, input_tensors, output_tensors, input_ids, input_dtypes, diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordForwardprop.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordForwardprop.cs index 0d190c91..844addd2 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordForwardprop.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordForwardprop.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Gradients; using static Tensorflow.tensorflow; diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordOperation.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordOperation.cs index d0e73664..bb623d72 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordOperation.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeSetRecordOperation.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using Tensorflow.Gradients; using static Tensorflow.tensorflow; diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeTensorFromTensor.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeTensorFromTensor.cs index db743136..4dabc9a1 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeTensorFromTensor.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeTensorFromTensor.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Tensorflow.Gradients; +using Tensorflow.Gradients; namespace Tensorflow.Eager { diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeTensorsFromTensorSequence.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeTensorsFromTensorSequence.cs index d60ec283..34998c68 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.TapeTensorsFromTensorSequence.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.TapeTensorsFromTensorSequence.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using Tensorflow.Gradients; namespace Tensorflow.Eager diff --git a/src/TensorFlowNET.Core/Eager/EagerRunner.cs b/src/TensorFlowNET.Core/Eager/EagerRunner.cs index 637af1f4..5a0e20be 100644 --- a/src/TensorFlowNET.Core/Eager/EagerRunner.cs +++ b/src/TensorFlowNET.Core/Eager/EagerRunner.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Gradients; -using static Tensorflow.Binding; - -namespace Tensorflow.Eager +namespace Tensorflow.Eager { /// /// Eager mode runner diff --git a/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs b/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs index 88b9280a..afb776aa 100644 --- a/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs +++ b/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs @@ -1,8 +1,5 @@ using NumSharp; using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; using static Tensorflow.Binding; namespace Tensorflow.Eager @@ -11,7 +8,7 @@ namespace Tensorflow.Eager { public EagerTensor() : base(IntPtr.Zero) { - + } public EagerTensor(SafeTensorHandleHandle handle) : base(IntPtr.Zero) @@ -84,7 +81,7 @@ namespace Tensorflow.Eager void copy_handle_data(Tensor target_t) { - if(target_t.dtype == TF_DataType.TF_RESOURCE || + if (target_t.dtype == TF_DataType.TF_RESOURCE || target_t.dtype == TF_DataType.TF_VARIANT) { // need to export diff --git a/src/TensorFlowNET.Core/Eager/EagerTensor.Implicit.cs b/src/TensorFlowNET.Core/Eager/EagerTensor.Implicit.cs index 3635808d..28c41bb1 100644 --- a/src/TensorFlowNET.Core/Eager/EagerTensor.Implicit.cs +++ b/src/TensorFlowNET.Core/Eager/EagerTensor.Implicit.cs @@ -1,8 +1,4 @@ -using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Eager; +using System; namespace Tensorflow.Eager { diff --git a/src/TensorFlowNET.Core/Eager/EagerTensor.ToString.cs b/src/TensorFlowNET.Core/Eager/EagerTensor.ToString.cs index adf44007..fbb4b6a2 100644 --- a/src/TensorFlowNET.Core/Eager/EagerTensor.ToString.cs +++ b/src/TensorFlowNET.Core/Eager/EagerTensor.ToString.cs @@ -1,11 +1,4 @@ -using NumSharp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using static Tensorflow.Binding; - -namespace Tensorflow.Eager +namespace Tensorflow.Eager { public partial class EagerTensor { diff --git a/src/TensorFlowNET.Core/Eager/EagerTensor.cs b/src/TensorFlowNET.Core/Eager/EagerTensor.cs index 084a8cb3..f1ce52a5 100644 --- a/src/TensorFlowNET.Core/Eager/EagerTensor.cs +++ b/src/TensorFlowNET.Core/Eager/EagerTensor.cs @@ -1,6 +1,4 @@ -using NumSharp; -using System; -using System.Linq; +using System; using Tensorflow.Util; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Eager/FastPathOpExecInfo.cs b/src/TensorFlowNET.Core/Eager/FastPathOpExecInfo.cs index 4a45b2df..654c25b2 100644 --- a/src/TensorFlowNET.Core/Eager/FastPathOpExecInfo.cs +++ b/src/TensorFlowNET.Core/Eager/FastPathOpExecInfo.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Contexts; +using Tensorflow.Contexts; namespace Tensorflow.Eager { diff --git a/src/TensorFlowNET.Core/Eager/IEagerRunner.cs b/src/TensorFlowNET.Core/Eager/IEagerRunner.cs index fced90c9..dbf09eb1 100644 --- a/src/TensorFlowNET.Core/Eager/IEagerRunner.cs +++ b/src/TensorFlowNET.Core/Eager/IEagerRunner.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Contexts; using Tensorflow.Gradients; @@ -13,8 +11,8 @@ namespace Tensorflow.Eager Tensor[] inputs, object[] attrs, string name = null); - (TF_DataType, Tensor[]) ArgsToMatchingEager(Context ctx, - TF_DataType default_dtype = TF_DataType.DtInvalid, + (TF_DataType, Tensor[]) ArgsToMatchingEager(Context ctx, + TF_DataType default_dtype = TF_DataType.DtInvalid, object[] args = null); Tensor[] TFE_FastPathExecute(Context ctx, diff --git a/src/TensorFlowNET.Core/Eager/c_api.eager.cs b/src/TensorFlowNET.Core/Eager/c_api.eager.cs index d1879b99..8120ed66 100644 --- a/src/TensorFlowNET.Core/Eager/c_api.eager.cs +++ b/src/TensorFlowNET.Core/Eager/c_api.eager.cs @@ -242,7 +242,7 @@ namespace Tensorflow /// size_t [DllImport(TensorFlowLibName)] public static extern void TFE_OpSetAttrString(SafeOpHandle op, string attr_name, string value, uint length); - + [DllImport(TensorFlowLibName)] public static extern void TFE_OpSetAttrTypeList(SafeOpHandle op, string attr_name, TF_DataType[] values, int num_values); @@ -442,8 +442,8 @@ namespace Tensorflow public static extern IntPtr ResourceVariable_Handle(IntPtr variable); [DllImport(TensorFlowLibName)] - public static extern SafeStatusHandle TFE_TapeGradient(IntPtr tape, - IntPtr[] target, int target_size, + public static extern SafeStatusHandle TFE_TapeGradient(IntPtr tape, + IntPtr[] target, int target_size, IntPtr[] sources, int source_size, IntPtr[] outputs, int output_size); } diff --git a/src/TensorFlowNET.Core/Exceptions/InvalidArgumentError.cs b/src/TensorFlowNET.Core/Exceptions/InvalidArgumentError.cs index b16e4fd6..d5d13156 100644 --- a/src/TensorFlowNET.Core/Exceptions/InvalidArgumentError.cs +++ b/src/TensorFlowNET.Core/Exceptions/InvalidArgumentError.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tensorflow +namespace Tensorflow { public class InvalidArgumentError : TensorflowException { diff --git a/src/TensorFlowNET.Core/Exceptions/KeyError.cs b/src/TensorFlowNET.Core/Exceptions/KeyError.cs index 949fd309..5f9bbc79 100644 --- a/src/TensorFlowNET.Core/Exceptions/KeyError.cs +++ b/src/TensorFlowNET.Core/Exceptions/KeyError.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tensorflow +namespace Tensorflow { public class KeyError : TensorflowException { diff --git a/src/TensorFlowNET.Core/Exceptions/LookupError.cs b/src/TensorFlowNET.Core/Exceptions/LookupError.cs index ebbaa526..5d5418a5 100644 --- a/src/TensorFlowNET.Core/Exceptions/LookupError.cs +++ b/src/TensorFlowNET.Core/Exceptions/LookupError.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tensorflow +namespace Tensorflow { public class LookupError : TensorflowException { diff --git a/src/TensorFlowNET.Core/Exceptions/OutOfRangeError.cs b/src/TensorFlowNET.Core/Exceptions/OutOfRangeError.cs index 422ff059..f330de82 100644 --- a/src/TensorFlowNET.Core/Exceptions/OutOfRangeError.cs +++ b/src/TensorFlowNET.Core/Exceptions/OutOfRangeError.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tensorflow +namespace Tensorflow { public class OutOfRangeError : TensorflowException { diff --git a/src/TensorFlowNET.Core/Exceptions/RuntimeError.cs b/src/TensorFlowNET.Core/Exceptions/RuntimeError.cs index 6f7e4f48..964534aa 100644 --- a/src/TensorFlowNET.Core/Exceptions/RuntimeError.cs +++ b/src/TensorFlowNET.Core/Exceptions/RuntimeError.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tensorflow +namespace Tensorflow { public class RuntimeError : TensorflowException { diff --git a/src/TensorFlowNET.Core/Exceptions/StopIteration.cs b/src/TensorFlowNET.Core/Exceptions/StopIteration.cs index d91408a2..bdfed255 100644 --- a/src/TensorFlowNET.Core/Exceptions/StopIteration.cs +++ b/src/TensorFlowNET.Core/Exceptions/StopIteration.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tensorflow +namespace Tensorflow { public class StopIteration : TensorflowException { diff --git a/src/TensorFlowNET.Core/Exceptions/TypeError.cs b/src/TensorFlowNET.Core/Exceptions/TypeError.cs index 42c8e3a0..da340e4e 100644 --- a/src/TensorFlowNET.Core/Exceptions/TypeError.cs +++ b/src/TensorFlowNET.Core/Exceptions/TypeError.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tensorflow +namespace Tensorflow { public class TypeError : TensorflowException { diff --git a/src/TensorFlowNET.Core/Exceptions/ValueError.cs b/src/TensorFlowNET.Core/Exceptions/ValueError.cs index 0d6fb4e3..df9833b3 100644 --- a/src/TensorFlowNET.Core/Exceptions/ValueError.cs +++ b/src/TensorFlowNET.Core/Exceptions/ValueError.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tensorflow +namespace Tensorflow { public class ValueError : TensorflowException { diff --git a/src/TensorFlowNET.Core/Framework/Models/AutotuneAlgorithm.cs b/src/TensorFlowNET.Core/Framework/Models/AutotuneAlgorithm.cs index 6600d6b0..5289de71 100644 --- a/src/TensorFlowNET.Core/Framework/Models/AutotuneAlgorithm.cs +++ b/src/TensorFlowNET.Core/Framework/Models/AutotuneAlgorithm.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Framework.Models +namespace Tensorflow.Framework.Models { public enum AutotuneAlgorithm { diff --git a/src/TensorFlowNET.Core/Framework/Models/DenseSpec.cs b/src/TensorFlowNET.Core/Framework/Models/DenseSpec.cs index f4f0a62f..37747cca 100644 --- a/src/TensorFlowNET.Core/Framework/Models/DenseSpec.cs +++ b/src/TensorFlowNET.Core/Framework/Models/DenseSpec.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Framework.Models +namespace Tensorflow.Framework.Models { /// /// Describes a dense object with shape, dtype, and name. diff --git a/src/TensorFlowNET.Core/Framework/Models/TensorSpec.cs b/src/TensorFlowNET.Core/Framework/Models/TensorSpec.cs index bb5874ed..0d5aa7d0 100644 --- a/src/TensorFlowNET.Core/Framework/Models/TensorSpec.cs +++ b/src/TensorFlowNET.Core/Framework/Models/TensorSpec.cs @@ -1,13 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; namespace Tensorflow.Framework.Models { public class TensorSpec : DenseSpec { - public TensorSpec(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) : + public TensorSpec(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) : base(shape, dtype, name) { diff --git a/src/TensorFlowNET.Core/Framework/Models/TypeSpec.cs b/src/TensorFlowNET.Core/Framework/Models/TypeSpec.cs index c9f05aef..84fd6e25 100644 --- a/src/TensorFlowNET.Core/Framework/Models/TypeSpec.cs +++ b/src/TensorFlowNET.Core/Framework/Models/TypeSpec.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Framework.Models +namespace Tensorflow.Framework.Models { /// /// Specifies a TensorFlow value type. diff --git a/src/TensorFlowNET.Core/Framework/graph_util_impl.cs b/src/TensorFlowNET.Core/Framework/graph_util_impl.cs index 280ee8b9..9ff90000 100644 --- a/src/TensorFlowNET.Core/Framework/graph_util_impl.cs +++ b/src/TensorFlowNET.Core/Framework/graph_util_impl.cs @@ -53,7 +53,7 @@ namespace Tensorflow foreach (var node in inference_graph.Node) { - if(new string[] { "Variable", "VariableV2", "VarHandleOp" }.Contains(node.Op)) + if (new string[] { "Variable", "VariableV2", "VarHandleOp" }.Contains(node.Op)) { var variable_name = node.Name; @@ -68,7 +68,7 @@ namespace Tensorflow // There can be one or more Identity ops in between the ReadVariableOp and // VarHandleOp. Store the Identity ops with the associated dtypes. var source_op_name = get_input_name(node); - while(map_name_to_node[source_op_name].Op == "Identity") + while (map_name_to_node[source_op_name].Op == "Identity") { throw new NotImplementedException("map_name_to_node[source_op_name].Op"); /*resource_identity_types[source_op_name] = node.attr["dtype"]; @@ -83,14 +83,14 @@ namespace Tensorflow returned_variables = sess.run(variable_names); var variables_data_map = new Dictionary(); - foreach(var (i, name) in enumerate(variable_dict_names)) + foreach (var (i, name) in enumerate(variable_dict_names)) variables_data_map[name] = returned_variables[i]; print($"Froze {len(returned_variables)} variables."); // Reconstruct the graph with constants in place of variables. var output_graph_def = new GraphDef(); int how_many_converted = 0; - foreach(var input_node in inference_graph.Node) + foreach (var input_node in inference_graph.Node) { var output_node = new NodeDef(); if (variables_data_map.ContainsKey(input_node.Name)) @@ -101,7 +101,7 @@ namespace Tensorflow how_many_converted += 1; } // else if (resource_identity_types.ContainsKey(input_node.Name)) - else if(input_node.Op == "ReadVariableOp") + else if (input_node.Op == "ReadVariableOp") { output_node.Op = "Identity"; output_node.Name = input_node.Name; @@ -180,7 +180,7 @@ namespace Tensorflow { var nodes_to_keep = new List(); var next_to_visit = target_nodes.Select(x => x).ToList(); - while(next_to_visit.Count > 0) + while (next_to_visit.Count > 0) { var node = next_to_visit[0]; next_to_visit.RemoveAt(0); diff --git a/src/TensorFlowNET.Core/Framework/importer.cs b/src/TensorFlowNET.Core/Framework/importer.cs index 43e4e666..1d0098b4 100644 --- a/src/TensorFlowNET.Core/Framework/importer.cs +++ b/src/TensorFlowNET.Core/Framework/importer.cs @@ -18,8 +18,8 @@ using Google.Protobuf; using System; using System.Collections.Generic; using System.Linq; -using static Tensorflow.OpDef.Types; using static Tensorflow.Binding; +using static Tensorflow.OpDef.Types; namespace Tensorflow { @@ -74,8 +74,8 @@ namespace Tensorflow return _GatherReturnElements(return_elements, graph, results); } - private static ITensorOrOperation[] _GatherReturnElements(string[] requested_return_elements, - Graph graph, + private static ITensorOrOperation[] _GatherReturnElements(string[] requested_return_elements, + Graph graph, TF_ImportGraphDefResults results) { var return_outputs = results.return_tensors; @@ -86,7 +86,7 @@ namespace Tensorflow #pragma warning disable CS0219 // Variable is assigned but its value is never used int opers_idx = 0; #pragma warning restore CS0219 // Variable is assigned but its value is never used - foreach(var name in requested_return_elements) + foreach (var name in requested_return_elements) { if (name.Contains(":")) { @@ -105,21 +105,21 @@ namespace Tensorflow private static void _ProcessNewOps(Graph graph) { - foreach(var new_op in graph._add_new_tf_operations()) + foreach (var new_op in graph._add_new_tf_operations()) { var original_device = new_op.Device; } } - public static void _PopulateTFImportGraphDefOptions(ImportGraphDefOptions options, - string prefix, + public static void _PopulateTFImportGraphDefOptions(ImportGraphDefOptions options, + string prefix, Dictionary input_map, string[] return_elements) { c_api.TF_ImportGraphDefOptionsSetPrefix(options.Handle, prefix); c_api.TF_ImportGraphDefOptionsSetUniquifyNames(options.Handle, (char)1); - foreach(var input in input_map) + foreach (var input in input_map) { var (src_name, src_index) = _ParseTensorName(input.Key); c_api.TF_ImportGraphDefOptionsAddInputMapping(options.Handle, src_name, src_index, input.Value._as_tf_output()); @@ -130,7 +130,7 @@ namespace Tensorflow foreach (var name in return_elements) { - if(name.Contains(":")) + if (name.Contains(":")) { var (op_name, index) = _ParseTensorName(name); c_api.TF_ImportGraphDefOptionsAddReturnOutput(options.Handle, op_name, index); @@ -162,7 +162,7 @@ namespace Tensorflow public static GraphDef _ProcessGraphDefParam(GraphDef graph_def, Dictionary op_dict) { - foreach(var node in graph_def.Node) + foreach (var node in graph_def.Node) { if (!op_dict.ContainsKey(node.Op)) continue; @@ -176,10 +176,10 @@ namespace Tensorflow private static void _SetDefaultAttrValues(NodeDef node_def, OpDef op_def) { - foreach(var attr_def in op_def.Attr) + foreach (var attr_def in op_def.Attr) { var key = attr_def.Name; - if(attr_def.DefaultValue != null) + if (attr_def.DefaultValue != null) { if (node_def.Attr.ContainsKey(key)) { @@ -220,16 +220,16 @@ namespace Tensorflow return op; }).ToArray(); - foreach(var node in graph_def.Node) + foreach (var node in graph_def.Node) { // Remove any default attr values that aren't in op_def. if (producer_op_dict.ContainsKey(node.Op)) { var op_def = op_dict[node.Op]; var producer_op_def = producer_op_dict[node.Op]; - foreach(var key in node.Attr) + foreach (var key in node.Attr) { - if(_FindAttrInOpDef(key.Key, op_def) == null) + if (_FindAttrInOpDef(key.Key, op_def) == null) { var attr_def = _FindAttrInOpDef(key.Key, producer_op_def); if (attr_def != null && attr_def.DefaultValue != null && diff --git a/src/TensorFlowNET.Core/Framework/meta_graph.cs b/src/TensorFlowNET.Core/Framework/meta_graph.cs index 2716dfa2..096b25a2 100644 --- a/src/TensorFlowNET.Core/Framework/meta_graph.cs +++ b/src/TensorFlowNET.Core/Framework/meta_graph.cs @@ -20,9 +20,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Tensorflow.Operations; +using static Tensorflow.Binding; using static Tensorflow.CollectionDef; using static Tensorflow.MetaGraphDef.Types; -using static Tensorflow.Binding; namespace Tensorflow { @@ -272,12 +272,12 @@ namespace Tensorflow col_def.BytesList = new Types.BytesList(); foreach (var x in collection_list) { - if(x is RefVariable x_ref_var) + if (x is RefVariable x_ref_var) { var proto = x_ref_var.to_proto(export_scope); col_def.BytesList.Value.Add(proto.ToByteString()); } - else if(x is ResourceVariable x_res_var) + else if (x is ResourceVariable x_res_var) { var proto = x_res_var.to_proto(export_scope); col_def.BytesList.Value.Add(proto.ToByteString()); diff --git a/src/TensorFlowNET.Core/Framework/op_def_registry.py.cs b/src/TensorFlowNET.Core/Framework/op_def_registry.py.cs index dfc654a4..fa9432d2 100644 --- a/src/TensorFlowNET.Core/Framework/op_def_registry.py.cs +++ b/src/TensorFlowNET.Core/Framework/op_def_registry.py.cs @@ -14,9 +14,7 @@ limitations under the License. ******************************************************************************/ -using System; using System.Collections.Generic; -using System.IO; using Tensorflow.Util; namespace Tensorflow @@ -27,12 +25,12 @@ namespace Tensorflow public static Dictionary get_registered_ops() { - if(_registered_ops.Count == 0) + if (_registered_ops.Count == 0) { lock (_registered_ops) { // double validation to avoid multi-thread executing - if (_registered_ops.Count > 0) + if (_registered_ops.Count > 0) return _registered_ops; using var buffer = new Buffer(c_api.TF_GetAllOpList()); diff --git a/src/TensorFlowNET.Core/Framework/smart_module.cs b/src/TensorFlowNET.Core/Framework/smart_module.cs index 3b837af2..24437f0b 100644 --- a/src/TensorFlowNET.Core/Framework/smart_module.cs +++ b/src/TensorFlowNET.Core/Framework/smart_module.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using System; -using static Tensorflow.Binding; namespace Tensorflow.Framework { diff --git a/src/TensorFlowNET.Core/Framework/sparse_tensor.py.cs b/src/TensorFlowNET.Core/Framework/sparse_tensor.py.cs index 13b75ee9..de093ec9 100644 --- a/src/TensorFlowNET.Core/Framework/sparse_tensor.py.cs +++ b/src/TensorFlowNET.Core/Framework/sparse_tensor.py.cs @@ -1,5 +1,4 @@ -using NumSharp; -using System; +using System; using System.Linq; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Framework/tensor_shape.cs b/src/TensorFlowNET.Core/Framework/tensor_shape.cs index 06d80972..96265758 100644 --- a/src/TensorFlowNET.Core/Framework/tensor_shape.cs +++ b/src/TensorFlowNET.Core/Framework/tensor_shape.cs @@ -1,7 +1,7 @@ -using System; +using NumSharp; +using System; using System.Linq; using System.Text; -using NumSharp; using Tensorflow.Contrib.Learn.Estimators; namespace Tensorflow.Framework diff --git a/src/TensorFlowNET.Core/Functions/ConcreteFunction.cs b/src/TensorFlowNET.Core/Functions/ConcreteFunction.cs index e07171da..89828600 100644 --- a/src/TensorFlowNET.Core/Functions/ConcreteFunction.cs +++ b/src/TensorFlowNET.Core/Functions/ConcreteFunction.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Framework.Models; using Tensorflow.Graphs; using static Tensorflow.Binding; @@ -56,7 +54,7 @@ namespace Tensorflow.Functions } } - public ConcreteFunction(Func func, + public ConcreteFunction(Func func, TF_DataType[] dtypes, TensorShape[] shapes) { string func_name = $"autograph_{Guid.NewGuid()}_{func.Method.Name}"; diff --git a/src/TensorFlowNET.Core/Gradients/AccumulatorCallState.cs b/src/TensorFlowNET.Core/Gradients/AccumulatorCallState.cs index 919383d8..1806a455 100644 --- a/src/TensorFlowNET.Core/Gradients/AccumulatorCallState.cs +++ b/src/TensorFlowNET.Core/Gradients/AccumulatorCallState.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Gradients +namespace Tensorflow.Gradients { public class AccumulatorCallState { diff --git a/src/TensorFlowNET.Core/Gradients/BackpropInitialState.cs b/src/TensorFlowNET.Core/Gradients/BackpropInitialState.cs index 90bfb7cc..0e775d46 100644 --- a/src/TensorFlowNET.Core/Gradients/BackpropInitialState.cs +++ b/src/TensorFlowNET.Core/Gradients/BackpropInitialState.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Util; +using Tensorflow.Util; using static Tensorflow.tensorflow; namespace Tensorflow.Gradients diff --git a/src/TensorFlowNET.Core/Gradients/GradientTape.cs b/src/TensorFlowNET.Core/Gradients/GradientTape.cs index e94dc62a..0987a102 100644 --- a/src/TensorFlowNET.Core/Gradients/GradientTape.cs +++ b/src/TensorFlowNET.Core/Gradients/GradientTape.cs @@ -1,12 +1,6 @@ -using Google.Protobuf.WellKnownTypes; -using NumSharp.Utilities; -using System; +using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Text; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow.Gradients @@ -55,14 +49,14 @@ namespace Tensorflow.Gradients private void _push_tape() { if (_recording) - throw new ValueError("Tape is still recording, This can happen if you try to " + + throw new ValueError("Tape is still recording, This can happen if you try to " + "re-enter an already-active tape."); if (_tape == null) _tape = new Tape(_persistent, _watch_accessed_variables); else tf.GetTapeSet().Add(_tape); - + _recording = true; } @@ -127,9 +121,9 @@ namespace Tensorflow.Gradients _pop_tape(); } - var results = tf.Runner.TFE_TapeGradient(_tape, - new[] { target }, - sources.Select(x => x.Handle).ToArray(), + var results = tf.Runner.TFE_TapeGradient(_tape, + new[] { target }, + sources.Select(x => x.Handle).ToArray(), null); if (!_persistent) diff --git a/src/TensorFlowNET.Core/Gradients/ITape.cs b/src/TensorFlowNET.Core/Gradients/ITape.cs index fc0495f5..69f102a7 100644 --- a/src/TensorFlowNET.Core/Gradients/ITape.cs +++ b/src/TensorFlowNET.Core/Gradients/ITape.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Util; using static Tensorflow.tensorflow; diff --git a/src/TensorFlowNET.Core/Gradients/OpTape.cs b/src/TensorFlowNET.Core/Gradients/OpTape.cs index d415caef..329cdee8 100644 --- a/src/TensorFlowNET.Core/Gradients/OpTape.cs +++ b/src/TensorFlowNET.Core/Gradients/OpTape.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Tensorflow.Util; +using Tensorflow.Util; namespace Tensorflow.Gradients { @@ -11,7 +7,7 @@ namespace Tensorflow.Gradients /// /// /// - public class OpTape : + public class OpTape : UnorderedMap> { diff --git a/src/TensorFlowNET.Core/Gradients/OpTapeEntry.cs b/src/TensorFlowNET.Core/Gradients/OpTapeEntry.cs index ff04866d..d44ea361 100644 --- a/src/TensorFlowNET.Core/Gradients/OpTapeEntry.cs +++ b/src/TensorFlowNET.Core/Gradients/OpTapeEntry.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Gradients +namespace Tensorflow.Gradients { /// /// Represents an entry in the tape. diff --git a/src/TensorFlowNET.Core/Gradients/Tape.CallBackwardFunction.cs b/src/TensorFlowNET.Core/Gradients/Tape.CallBackwardFunction.cs index f4908c71..4c5f8b1c 100644 --- a/src/TensorFlowNET.Core/Gradients/Tape.CallBackwardFunction.cs +++ b/src/TensorFlowNET.Core/Gradients/Tape.CallBackwardFunction.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Eager; +using System.Collections.Generic; using static Tensorflow.tensorflow; namespace Tensorflow.Gradients @@ -13,7 +10,7 @@ namespace Tensorflow.Gradients List output_gradients) { var grads = new Tensor[output_gradients.Count]; - var result = backward_function(output_gradients.ToArray(), + var result = backward_function(output_gradients.ToArray(), unneeded_gradients.ToArray()); return result; diff --git a/src/TensorFlowNET.Core/Gradients/Tape.ComputeGradient.cs b/src/TensorFlowNET.Core/Gradients/Tape.ComputeGradient.cs index 13a68530..a9d8b10a 100644 --- a/src/TensorFlowNET.Core/Gradients/Tape.ComputeGradient.cs +++ b/src/TensorFlowNET.Core/Gradients/Tape.ComputeGradient.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Util; using static Tensorflow.tensorflow; @@ -69,7 +68,7 @@ namespace Tensorflow.Gradients else { any_gradient_nonzero = true; - var new_gradients = grad_it.Count == 1 ? + var new_gradients = grad_it.Count == 1 ? grad_it[0] : gen_math_ops.add_n(grad_it.ToArray()); // vspace.AggregateGradients @@ -91,8 +90,8 @@ namespace Tensorflow.Gradients foreach (var i in zero_indices) out_gradients[i] = trace.output_tensor_info[i].ZerosLike(); - in_gradients = CallBackwardFunction(trace.backward_function, - unneeded_gradients, + in_gradients = CallBackwardFunction(trace.backward_function, + unneeded_gradients, out_gradients); if (in_gradients.Count() != trace.input_tensor_id.Count()) @@ -141,7 +140,7 @@ namespace Tensorflow.Gradients if (gradients.find(id, out var grad_it)) { // foreach (var g in grad_it) - // DeleteGradient(g); + // DeleteGradient(g); gradients.erase(id); } continue; @@ -151,7 +150,7 @@ namespace Tensorflow.Gradients if (op_id == -1) continue; - if(state.op_missing_tensor.find(op_id, out var missing_it)) + if (state.op_missing_tensor.find(op_id, out var missing_it)) { state.op_missing_tensor[op_id]--; if (state.op_missing_tensor[op_id] == 0) @@ -170,7 +169,7 @@ namespace Tensorflow.Gradients result.Add(null); else { - if(grad_it.Count > 1) + if (grad_it.Count > 1) { var grad = gen_math_ops.add_n(grad_it.ToArray()); grad_it.Clear(); @@ -258,7 +257,7 @@ namespace Tensorflow.Gradients UnorderedMap op_missing_tensor) { var result = new Queue(); - foreach(var op_entry in op_tape) + foreach (var op_entry in op_tape) { if (!op_missing_tensor.find(op_entry.Key)) result.Enqueue(op_entry.Key); diff --git a/src/TensorFlowNET.Core/Gradients/Tape.PrepareBackprop.cs b/src/TensorFlowNET.Core/Gradients/Tape.PrepareBackprop.cs index 55e6d7e4..ba95fc99 100644 --- a/src/TensorFlowNET.Core/Gradients/Tape.PrepareBackprop.cs +++ b/src/TensorFlowNET.Core/Gradients/Tape.PrepareBackprop.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using Tensorflow.Util; using static Tensorflow.tensorflow; @@ -24,7 +21,7 @@ namespace Tensorflow.Gradients if (!tensor_tape.find(tensor_id, out var op_id)) continue; - if (op_id == -1 || + if (op_id == -1 || !op_tape.find(op_id, out var op_it) || result.op_tape.find(op_id, out var result_op_it)) continue; @@ -33,7 +30,7 @@ namespace Tensorflow.Gradients foreach (var it in op_it.input_tensor_id) { - if(result.tensor_usage_counts.find(it)) + if (result.tensor_usage_counts.find(it)) result.tensor_usage_counts[it]++; else { diff --git a/src/TensorFlowNET.Core/Gradients/Tape.RecordOperation.cs b/src/TensorFlowNET.Core/Gradients/Tape.RecordOperation.cs index 79595112..2550dd59 100644 --- a/src/TensorFlowNET.Core/Gradients/Tape.RecordOperation.cs +++ b/src/TensorFlowNET.Core/Gradients/Tape.RecordOperation.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using Tensorflow.Util; using static Tensorflow.tensorflow; @@ -38,7 +37,7 @@ namespace Tensorflow.Gradients tensor_usage_[o.GetID()] = 1; tensors.Add(o); } - + op_tape_[op_id] = new OpTapeEntry { op_type = op_type, diff --git a/src/TensorFlowNET.Core/Gradients/Tape.cs b/src/TensorFlowNET.Core/Gradients/Tape.cs index af6134c7..33e3ea89 100644 --- a/src/TensorFlowNET.Core/Gradients/Tape.cs +++ b/src/TensorFlowNET.Core/Gradients/Tape.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using Tensorflow.Util; using static Tensorflow.Binding; using static Tensorflow.tensorflow; diff --git a/src/TensorFlowNET.Core/Gradients/TapeTensor.cs b/src/TensorFlowNET.Core/Gradients/TapeTensor.cs index 6999bee7..92c4e39f 100644 --- a/src/TensorFlowNET.Core/Gradients/TapeTensor.cs +++ b/src/TensorFlowNET.Core/Gradients/TapeTensor.cs @@ -1,9 +1,4 @@ -using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Eager; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow.Gradients { diff --git a/src/TensorFlowNET.Core/Gradients/TensorTape.cs b/src/TensorFlowNET.Core/Gradients/TensorTape.cs index 8fb0de41..c2760407 100644 --- a/src/TensorFlowNET.Core/Gradients/TensorTape.cs +++ b/src/TensorFlowNET.Core/Gradients/TensorTape.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Dynamic; -using System.Linq; -using System.Text; -using Tensorflow.Util; +using Tensorflow.Util; namespace Tensorflow.Gradients { @@ -14,6 +9,6 @@ namespace Tensorflow.Gradients /// public class TensorTape : UnorderedMap { - + } } diff --git a/src/TensorFlowNET.Core/Gradients/array_grad.cs b/src/TensorFlowNET.Core/Gradients/array_grad.cs index 36148287..5176d3ca 100644 --- a/src/TensorFlowNET.Core/Gradients/array_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/array_grad.cs @@ -41,7 +41,7 @@ namespace Tensorflow.Gradients keepdims: true); var updates_grad = array_ops.reshape(updates_grad_reshaped, input_value_shape); - return new Tensor[] + return new Tensor[] { updates_grad, null @@ -117,7 +117,7 @@ namespace Tensorflow.Gradients new Tensor[] { non_neg_concat_dim, tf.constant(0) }, new Tensor[] { tf.constant(1), tf.constant(-1) }); var squeeze_sizes = array_ops.squeeze(slice); - out_grads = array_ops.split(axis: grad, value: squeeze_sizes, num_split:(int)non_neg_concat_dim).ToList(); + out_grads = array_ops.split(axis: grad, value: squeeze_sizes, num_split: (int)non_neg_concat_dim).ToList(); } else { @@ -126,8 +126,8 @@ namespace Tensorflow.Gradients out_grads.Add(gen_array_ops.slice(grad, begin, size)); } - return (end_value_index <= dim_index ? - out_grads.ToArray().Concat(new Tensor[] { null }) : + return (end_value_index <= dim_index ? + out_grads.ToArray().Concat(new Tensor[] { null }) : new Tensor[] { null }.Concat(out_grads)).ToArray(); } @@ -146,7 +146,7 @@ namespace Tensorflow.Gradients { var sizes = new Tensor[inputs.Length]; bool fully_known = true; - for(int i = 0; i < inputs.Length; i++) + for (int i = 0; i < inputs.Length; i++) { var x = inputs[i]; @@ -157,7 +157,7 @@ namespace Tensorflow.Gradients break; } - sizes[i] = input_shape; + sizes[i] = input_shape; } if (fully_known) @@ -188,9 +188,9 @@ namespace Tensorflow.Gradients var axis_static = tensor_util.constant_value(axis); // For axis 0 gathers, build an appropriately shaped IndexedSlices. - if((int)axis_static == 0) + if ((int)axis_static == 0) { - var params_tail_shape = params_shape.slice(new NumSharp.Slice(start:1)); + var params_tail_shape = params_shape.slice(new NumSharp.Slice(start: 1)); var values_shape = array_ops.concat(new[] { indices_size, params_tail_shape }, 0); var values = array_ops.reshape(grad, values_shape); indices = array_ops.reshape(indices, indices_size); @@ -250,10 +250,10 @@ namespace Tensorflow.Gradients var before_pad = array_ops.reshape(begin_vec, shape); var after_pad = array_ops.reshape(array_ops.shape(input_vec) - slice_size - begin_vec, shape); var paddings = array_ops.concat(new Tensor[] { before_pad, after_pad }, 1); - return new Tensor[] + return new Tensor[] { - array_ops.pad(grad, paddings), - null, + array_ops.pad(grad, paddings), + null, null }; } @@ -267,7 +267,7 @@ namespace Tensorflow.Gradients [RegisterGradient("StopGradient")] public static Tensor[] _NoGradient(Operation op, Tensor[] grads) { - return new Tensor[] {null}; + return new Tensor[] { null }; } /// @@ -286,7 +286,7 @@ namespace Tensorflow.Gradients var x = array_ops.shape(op.inputs[0], out_type: begin.dtype); - return new Tensor[] + return new Tensor[] { gen_array_ops.strided_slice_grad( x, @@ -313,7 +313,7 @@ namespace Tensorflow.Gradients var end = op.inputs[2]; var strides = op.inputs[3]; - return new Tensor[] + return new Tensor[] { null, null, diff --git a/src/TensorFlowNET.Core/Gradients/c_api.gradient.cs b/src/TensorFlowNET.Core/Gradients/c_api.gradient.cs index c0f132ee..70dcfd67 100644 --- a/src/TensorFlowNET.Core/Gradients/c_api.gradient.cs +++ b/src/TensorFlowNET.Core/Gradients/c_api.gradient.cs @@ -15,10 +15,7 @@ ******************************************************************************/ using System; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Threading; -using Tensorflow.Gradients; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Gradients/control_flow_grad.cs b/src/TensorFlowNET.Core/Gradients/control_flow_grad.cs index d96b3f8c..eba821d2 100644 --- a/src/TensorFlowNET.Core/Gradients/control_flow_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/control_flow_grad.cs @@ -68,19 +68,19 @@ namespace Tensorflow.Gradients var zero_grad = grads[1 - op_ctxt.branch]; // At this point, we have created zero_grad guarded by the right switch. // Unfortunately, we may still get None here for not trainable data types. - if(zero_grad == null) + if (zero_grad == null) { throw new NotImplementedException("_SwitchGrad CondContext zero_grad"); } - return new Tensor[] + return new Tensor[] { merge(grads, name: "cond_grad")[0], - null + null }; } default: - throw new NotImplementedException("_SwitchGrad WhileContext"); + throw new NotImplementedException("_SwitchGrad WhileContext"); } throw new NotImplementedException("_SwitchGrad"); } diff --git a/src/TensorFlowNET.Core/Gradients/gradient_exclustions.cs b/src/TensorFlowNET.Core/Gradients/gradient_exclustions.cs index 70d5a32f..53d09eea 100644 --- a/src/TensorFlowNET.Core/Gradients/gradient_exclustions.cs +++ b/src/TensorFlowNET.Core/Gradients/gradient_exclustions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Gradients +namespace Tensorflow.Gradients { public class gradient_exclustions { diff --git a/src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs b/src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs index 9a486207..e91bafe8 100644 --- a/src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs +++ b/src/TensorFlowNET.Core/Gradients/gradients_impl.py.cs @@ -21,7 +21,7 @@ namespace Tensorflow public class gradients_impl { public static Tensor[] gradients(Tensor[] ys, - Tensor[] xs, + Tensor[] xs, Tensor[] grad_ys = null, string name = "gradients", bool colocate_gradients_with_ops = false, diff --git a/src/TensorFlowNET.Core/Gradients/gradients_util.cs b/src/TensorFlowNET.Core/Gradients/gradients_util.cs index 6eec094e..ce7c309b 100644 --- a/src/TensorFlowNET.Core/Gradients/gradients_util.cs +++ b/src/TensorFlowNET.Core/Gradients/gradients_util.cs @@ -108,10 +108,10 @@ namespace Tensorflow } } - if(loop_state != null) + if (loop_state != null) { var loop_exits = loop_state.ProcessUnusedLoopExits(pending_count, to_ops_set); - foreach(var y in loop_exits) + foreach (var y in loop_exits) { //if(IsTrainable(y)) throw new NotImplementedException(""); @@ -236,7 +236,7 @@ namespace Tensorflow if (loop_state != null) loop_state.ExitGradWhileContext(op, before: false); } - + // Update pending count for the inputs of op and enqueue ready ops. _UpdatePendingAndEnqueueReady(grads, op, queue, pending_count, loop_state, xs); } @@ -376,7 +376,7 @@ namespace Tensorflow yield return op.inputs[i]; } - private static List> _AggregatedGrads(Dictionary>> grads, Operation op, string gradient_uid, + private static List> _AggregatedGrads(Dictionary>> grads, Operation op, string gradient_uid, ControlFlowState loop_state, int aggregation_method = 0) { var out_grads = _GetGrads(grads, op); @@ -385,8 +385,8 @@ namespace Tensorflow { if (loop_state != null) { - if (out_grads.Count > 1 && - out_grads[1].Count > 0 && + if (out_grads.Count > 1 && + out_grads[1].Count > 0 && control_flow_util.IsLoopSwitch(op)) continue; } @@ -610,7 +610,7 @@ namespace Tensorflow if (grad_state.pending_exits_count == 0) { var has_not_none_grad = false; - foreach(var y in grad_state.deferred_exits) + foreach (var y in grad_state.deferred_exits) { if (_HasAnyNotNoneGrads(grads, y.op)) { @@ -664,7 +664,7 @@ namespace Tensorflow private static bool _HasAnyNotNoneGrads(Dictionary>> grads, Operation op) { var out_grads = _GetGrads(grads, op); - foreach(var out_grad in out_grads) + foreach (var out_grad in out_grads) { if (out_grad.Exists(g => g != null)) return true; diff --git a/src/TensorFlowNET.Core/Gradients/image_grad.cs b/src/TensorFlowNET.Core/Gradients/image_grad.cs index 23b19de9..87a67d64 100644 --- a/src/TensorFlowNET.Core/Gradients/image_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/image_grad.cs @@ -15,11 +15,7 @@ ******************************************************************************/ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using Tensorflow.Framework; -using static Tensorflow.Binding; namespace Tensorflow.Gradients { diff --git a/src/TensorFlowNET.Core/Gradients/math_grad.cs b/src/TensorFlowNET.Core/Gradients/math_grad.cs index 7622a6ae..3a6e9754 100644 --- a/src/TensorFlowNET.Core/Gradients/math_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/math_grad.cs @@ -18,7 +18,6 @@ using NumSharp; using System; using System.Linq; using Tensorflow.Eager; -using Tensorflow.Operations; using static Tensorflow.Binding; namespace Tensorflow.Gradients @@ -48,7 +47,7 @@ namespace Tensorflow.Gradients var x = op.inputs[0]; var y = op.inputs[1]; var grad = grads[0]; - if (grad is Tensor && + if (grad is Tensor && _ShapesFullySpecifiedAndEqual(x, y, grad)) return new Tensor[] { grad, grad }; @@ -127,7 +126,8 @@ namespace Tensorflow.Gradients { var grad = grads[0]; var y = op.outputs[0]; // y = e^x - return tf_with(ops.control_dependencies(new Operation[] { grad }), dp => { + return tf_with(ops.control_dependencies(new Operation[] { grad }), dp => + { y = math_ops.conj(y); // forward_compatible(2019, 9, 14) // return new Tensor[] { math_ops.mul_no_nan(y, grad) }; @@ -152,7 +152,8 @@ namespace Tensorflow.Gradients { var grad = grads[0]; var x = op.inputs[0]; - return tf_with(ops.control_dependencies(new Operation[] { grad }), dp => { + return tf_with(ops.control_dependencies(new Operation[] { grad }), dp => + { x = math_ops.conj(x); return new Tensor[] { grad * math_ops.digamma(x) }; }); @@ -163,7 +164,8 @@ namespace Tensorflow.Gradients { var grad = grads[0]; var x = op.inputs[0]; - return tf_with(ops.control_dependencies(new Operation[] { grad }), dp => { + return tf_with(ops.control_dependencies(new Operation[] { grad }), dp => + { x = math_ops.conj(x); return new Tensor[] { grad * math_ops.reciprocal(x) }; }); @@ -174,7 +176,8 @@ namespace Tensorflow.Gradients { var grad = grads[0]; var x = op.inputs[0]; - return tf_with(ops.control_dependencies(new Operation[] { grad }), dp => { + return tf_with(ops.control_dependencies(new Operation[] { grad }), dp => + { x = math_ops.conj(x); return new Tensor[] { grad * math_ops.reciprocal(1 + x) }; }); @@ -260,7 +263,7 @@ namespace Tensorflow.Gradients var t_b = (bool)op.get_attr("transpose_b"); var a = math_ops.conj(op.inputs[0]); var b = math_ops.conj(op.inputs[1]); - if(!t_a && !t_b) + if (!t_a && !t_b) { grad_a = gen_math_ops.mat_mul(grad, b, transpose_b: true); grad_b = gen_math_ops.mat_mul(a, grad, transpose_a: true); @@ -327,8 +330,8 @@ namespace Tensorflow.Gradients var output_shape = op.outputs[0]._shape_tuple(); Tensor result, factor_tensor; - if(tf.executing_eagerly() - && input_shape != null + if (tf.executing_eagerly() + && input_shape != null && output_shape != null) { var input_size = np.prod(input_shape); @@ -472,7 +475,7 @@ namespace Tensorflow.Gradients var grad = grads[0]; var x = op.inputs[0]; var y = op.inputs[1]; - if (grad is Tensor && + if (grad is Tensor && _ShapesFullySpecifiedAndEqual(x, y, grad)) return new Tensor[] { grad, -grad }; @@ -490,7 +493,7 @@ namespace Tensorflow.Gradients var x_shape = x._shape_tuple(); var y_shape = y._shape_tuple(); var grad_shape = grad._shape_tuple(); - return x_shape != null && + return x_shape != null && y_shape != null && Enumerable.SequenceEqual(x_shape, y_shape) && Enumerable.SequenceEqual(y_shape, grad_shape) && @@ -507,7 +510,7 @@ namespace Tensorflow.Gradients if (input_0_shape != null) { var axes = tensor_util.constant_value(op.inputs[1]); - if(!(axes is null)) + if (!(axes is null)) { var rank = input_0_shape.Length; if (Enumerable.SequenceEqual(Enumerable.Range(0, rank), axes.Data())) @@ -535,7 +538,7 @@ namespace Tensorflow.Gradients { throw new NotImplementedException(""); } - } + } } input_shape = array_ops.shape(op.inputs[0]); @@ -578,7 +581,7 @@ namespace Tensorflow.Gradients var reshape1 = array_ops.reshape( math_ops.reduce_sum( - math_ops.realdiv(grad, y), rx), + math_ops.realdiv(grad, y), rx), sx); var reshape2 = array_ops.reshape( math_ops.reduce_sum( @@ -607,7 +610,7 @@ namespace Tensorflow.Gradients var x = op.inputs[0]; var zero = constant_op.constant(0.0f, x.dtype, x.shape); - return new Tensor[] {zero}; + return new Tensor[] { zero }; } [RegisterGradient("Square")] @@ -710,7 +713,7 @@ namespace Tensorflow.Gradients var x = op.inputs[0]; var y = op.inputs[1]; - if (op is EagerOperation op_eager && + if (op is EagerOperation op_eager && op_eager.SkipInputIndices.Contains(1) && y.NDims == 0) { diff --git a/src/TensorFlowNET.Core/Gradients/math_grad_eager.cs b/src/TensorFlowNET.Core/Gradients/math_grad_eager.cs index a82cc699..530bb6c0 100644 --- a/src/TensorFlowNET.Core/Gradients/math_grad_eager.cs +++ b/src/TensorFlowNET.Core/Gradients/math_grad_eager.cs @@ -14,12 +14,9 @@ limitations under the License. ******************************************************************************/ -using NumSharp; using System; using System.Linq; using Tensorflow.Eager; -using Tensorflow.Operations; -using static Tensorflow.Binding; namespace Tensorflow.Gradients { diff --git a/src/TensorFlowNET.Core/Gradients/nn_grad.cs b/src/TensorFlowNET.Core/Gradients/nn_grad.cs index b3e4039c..13acd33f 100644 --- a/src/TensorFlowNET.Core/Gradients/nn_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/nn_grad.cs @@ -53,7 +53,7 @@ namespace Tensorflow.Gradients var grad = grads[0]; var x = op.inputs[0]; var alpha = (float)op.get_attr("alpha"); - return new Tensor[] { gen_nn_ops.leaky_relu_grad(grad, x, alpha: alpha)}; + return new Tensor[] { gen_nn_ops.leaky_relu_grad(grad, x, alpha: alpha) }; } /// @@ -89,12 +89,12 @@ namespace Tensorflow.Gradients var grad = _BroadcastMul(grad_loss, softmax_grad); var logits = op.inputs[0]; - if(grad_grad != null && !IsZero(grad_grad)) + if (grad_grad != null && !IsZero(grad_grad)) { throw new NotImplementedException("_SoftmaxCrossEntropyWithLogitsGrad"); } - return new Tensor[] + return new Tensor[] { grad, _BroadcastMul(grad_loss, -nn_ops.log_softmax(logits)) @@ -135,11 +135,11 @@ namespace Tensorflow.Gradients var use_cudnn_on_gpu = op.get_attr("use_cudnn_on_gpu"); var data_format = op.get_attr("data_format"); var shape = gen_array_ops.shape_n(new Tensor[] { op.inputs[0], op.inputs[1] }); - + return new Tensor[] { gen_nn_ops.conv2d_backprop_input(shape[0], op.inputs[1], grads[0], - strides, padding, use_cudnn_on_gpu, explicit_paddings, + strides, padding, use_cudnn_on_gpu, explicit_paddings, dilations: dilations, data_format: data_format), gen_nn_ops.conv2d_backprop_filter(op.inputs[0], shape[1], grads[0], @@ -234,10 +234,10 @@ namespace Tensorflow.Gradients return new Tensor[] { - dx, - dscale, - doffset, - null, + dx, + dscale, + doffset, + null, null }; } @@ -304,7 +304,7 @@ namespace Tensorflow.Gradients var stack = array_ops.stack(new object[] { -1L, ind_lastdim }); var ind_2d = array_ops.reshape(op.outputs[1], stack); - var in_lastdim = array_ops.gather(math_ops.cast(in_shape, TF_DataType.TF_INT64), + var in_lastdim = array_ops.gather(math_ops.cast(in_shape, TF_DataType.TF_INT64), array_ops.size(in_shape) - 1); var outerdim = array_ops.shape(ind_2d).slice(0); diff --git a/src/TensorFlowNET.Core/Gradients/resource_variable_grad.cs b/src/TensorFlowNET.Core/Gradients/resource_variable_grad.cs index 8abbb589..5ab55011 100644 --- a/src/TensorFlowNET.Core/Gradients/resource_variable_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/resource_variable_grad.cs @@ -14,10 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using System.Text; - namespace Tensorflow.Gradients { [RegisterGradient("resource_variable_grad")] diff --git a/src/TensorFlowNET.Core/GraphTransformation/GraphTransformer.cs b/src/TensorFlowNET.Core/GraphTransformation/GraphTransformer.cs index 12f169b0..8870e295 100644 --- a/src/TensorFlowNET.Core/GraphTransformation/GraphTransformer.cs +++ b/src/TensorFlowNET.Core/GraphTransformation/GraphTransformer.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using Google.Protobuf; +using Google.Protobuf; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/GraphTransformation/c_api.transform_graph.cs b/src/TensorFlowNET.Core/GraphTransformation/c_api.transform_graph.cs index cf62c5fb..3b350839 100644 --- a/src/TensorFlowNET.Core/GraphTransformation/c_api.transform_graph.cs +++ b/src/TensorFlowNET.Core/GraphTransformation/c_api.transform_graph.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using System.Runtime.InteropServices; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Graphs/AutoGraph.cs b/src/TensorFlowNET.Core/Graphs/AutoGraph.cs index 77c1d664..68a7a1d0 100644 --- a/src/TensorFlowNET.Core/Graphs/AutoGraph.cs +++ b/src/TensorFlowNET.Core/Graphs/AutoGraph.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow.Graphs @@ -43,7 +40,7 @@ namespace Tensorflow.Graphs string func_name = $"autograph_{Guid.NewGuid()}_{func.Method.Name}"; // IntPtr func_handle; - using(var graph = new FuncGraph(func_name)) + using (var graph = new FuncGraph(func_name)) { var input1 = tf.placeholder(tf.int32); var input2 = tf.placeholder(tf.int32); diff --git a/src/TensorFlowNET.Core/Graphs/AutoGraphAttribute.cs b/src/TensorFlowNET.Core/Graphs/AutoGraphAttribute.cs index 976c7fd8..b777f29a 100644 --- a/src/TensorFlowNET.Core/Graphs/AutoGraphAttribute.cs +++ b/src/TensorFlowNET.Core/Graphs/AutoGraphAttribute.cs @@ -2,9 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Eager; -using Tensorflow.Keras.Engine; using static Tensorflow.Binding; namespace Tensorflow.Graphs @@ -23,19 +21,19 @@ namespace Tensorflow.Graphs if (functions.ContainsKey(func_name)) { - if(args.Arguments[0] is Tensors tensor_inputs) + if (args.Arguments[0] is Tensors tensor_inputs) args.ReturnValue = functions[func_name](tensor_inputs.ToArray()); else args.ReturnValue = functions[func_name](args.Arguments.Select(x => x as Tensor).ToArray()); args.FlowBehavior = FlowBehavior.Return; return; - } - + } + // make function as an Operation by autograph graph = new FuncGraph(func_name); // convert to Tensors - if(args.Arguments[0] is Tensors inputs) + if (args.Arguments[0] is Tensors inputs) { originalInputs = inputs; var new_inputs = inputs.Select(x => tf.placeholder(x.dtype, shape: x.TensorShape)).ToArray(); @@ -62,7 +60,7 @@ namespace Tensorflow.Graphs if (args.ReturnValue is Tensors outputs) { - if(args.Arguments[0] is Tensors inputs) + if (args.Arguments[0] is Tensors inputs) { graph.ToGraph(opers, inputs.Select(x => x.op).ToArray(), diff --git a/src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs b/src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs index 3dc77859..5407dcfe 100644 --- a/src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs +++ b/src/TensorFlowNET.Core/Graphs/DefaultGraphStack.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using System.Collections.Generic; using System.Linq; using static Tensorflow.Binding; @@ -31,7 +30,7 @@ namespace Tensorflow public void set_controller(Graph @default) { if (!_stack.Exists(x => x.Graph == @default)) - _stack.Add(new StackModel {Graph = @default, IsDefault = true}); + _stack.Add(new StackModel { Graph = @default, IsDefault = true }); foreach (var s in _stack) s.IsDefault = s.Graph == @default; @@ -40,7 +39,7 @@ namespace Tensorflow public Graph get_controller() { if (_stack.Count == 0 || _stack.Count(x => x.IsDefault) == 0) - _stack.Add(new StackModel {Graph = tf.Graph(), IsDefault = true}); + _stack.Add(new StackModel { Graph = tf.Graph(), IsDefault = true }); for (var i = _stack.Count - 1; i >= 0; i--) { var x = _stack[i]; diff --git a/src/TensorFlowNET.Core/Graphs/FuncGraph.cs b/src/TensorFlowNET.Core/Graphs/FuncGraph.cs index d69a89d6..f89536e5 100644 --- a/src/TensorFlowNET.Core/Graphs/FuncGraph.cs +++ b/src/TensorFlowNET.Core/Graphs/FuncGraph.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using Tensorflow.Functions; using static Tensorflow.Binding; namespace Tensorflow.Graphs @@ -37,18 +34,18 @@ namespace Tensorflow.Graphs string[] output_names) { using var status = new Status(); - func_handle = c_api.TF_GraphToFunction(_handle, - func_name, + func_handle = c_api.TF_GraphToFunction(_handle, + func_name, false, opers.Length, opers.Select(x => (IntPtr)x).ToArray(), - inputs.Length, + inputs.Length, inputs.Select(x => new TF_Output(x, 0)).ToArray(), - outputs.Length, + outputs.Length, outputs.Select(x => new TF_Output(x, 0)).ToArray(), output_names == null || output_names.Length == 0 ? null : output_names, - IntPtr.Zero, - null, + IntPtr.Zero, + null, status.Handle); status.Check(true); diff --git a/src/TensorFlowNET.Core/Graphs/Graph.Control.cs b/src/TensorFlowNET.Core/Graphs/Graph.Control.cs index 4db8ab2f..f71ab881 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.Control.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.Control.cs @@ -17,7 +17,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; -using Tensorflow.Eager; using Tensorflow.Operations; using static Tensorflow.Binding; @@ -97,7 +96,7 @@ namespace Tensorflow //case IndexedSlices islice: // control_ops.Add(islice.op); // break; - case Tensor t: + case Tensor t: control_ops.Add(t.op); break; case Operation op: @@ -139,7 +138,7 @@ namespace Tensorflow public void _pop_control_dependencies_controller(_ControlDependenciesController controller) { - _control_dependencies_stack.RemoveAt(_control_dependencies_stack.Count-1); + _control_dependencies_stack.RemoveAt(_control_dependencies_stack.Count - 1); } /// diff --git a/src/TensorFlowNET.Core/Graphs/Graph.Export.cs b/src/TensorFlowNET.Core/Graphs/Graph.Export.cs index 1d9f7e02..88fd670c 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.Export.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.Export.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using Google.Protobuf; -using System.IO; using Tensorflow.Util; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Graphs/Graph.Import.cs b/src/TensorFlowNET.Core/Graphs/Graph.Import.cs index 298862ff..53c37218 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.Import.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.Import.cs @@ -31,8 +31,8 @@ namespace Tensorflow c_api.TF_GraphImportGraphDefWithReturnOutputs(_handle, graph_def.Handle, opts.Handle, return_output_handle, num_return_outputs, s.Handle); - var tf_output_ptr = (TF_Output*) return_output_handle; - for (int i = 0; i < num_return_outputs; i++) + var tf_output_ptr = (TF_Output*)return_output_handle; + for (int i = 0; i < num_return_outputs; i++) return_outputs[i] = *(tf_output_ptr + i); Marshal.FreeHGlobal(return_output_handle); diff --git a/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs b/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs index d17f6591..d79ca07c 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.Operation.cs @@ -18,7 +18,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; -using Tensorflow.Util; using static Tensorflow.Binding; namespace Tensorflow @@ -62,7 +61,7 @@ namespace Tensorflow /// public Operation OperationByName(string operName) { - if (operName == null) + if (operName == null) throw new ArgumentNullException(nameof(operName)); var handle = c_api.TF_GraphOperationByName(_handle, operName); @@ -90,7 +89,7 @@ namespace Tensorflow /// This method may be called concurrently from multiple threads. /// /// The name of the `Operation` to return. - public Operation get_operation_by_name(string name) + public Operation get_operation_by_name(string name) => as_graph_element(name, allow_tensor: false, allow_operation: true) as Operation; public ITensorOrOperation _get_operation_by_name_unsafe(string name) @@ -150,7 +149,7 @@ namespace Tensorflow .Select(c_op => _create_op_from_tf_operation(c_op, compute_device: compute_devices)) .ToArray(); - foreach(var op in new_ops) + foreach (var op in new_ops) { var new_control_inputs = _control_dependencies_for_inputs(op.inputs) .Select(x => x as Operation) diff --git a/src/TensorFlowNET.Core/Graphs/Graph.cs b/src/TensorFlowNET.Core/Graphs/Graph.cs index 35275d4e..e71c8779 100644 --- a/src/TensorFlowNET.Core/Graphs/Graph.cs +++ b/src/TensorFlowNET.Core/Graphs/Graph.cs @@ -19,7 +19,6 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; -using System.Runtime.InteropServices; using static Tensorflow.Binding; namespace Tensorflow @@ -553,7 +552,7 @@ namespace Tensorflow { return graph._handle; } - + public OrderedDictionary _captures => new OrderedDictionary(); public Tensor[] external_captures() @@ -563,7 +562,7 @@ namespace Tensorflow inner.CopyTo(captures, 0); return captures; } - + public Tensor[] internal_captures() { Tensor[] captures = new Tensor[this._captures.Count]; diff --git a/src/TensorFlowNET.Core/Graphs/ImportGraphDefOptions.cs b/src/TensorFlowNET.Core/Graphs/ImportGraphDefOptions.cs index 38e30343..a04cf55a 100644 --- a/src/TensorFlowNET.Core/Graphs/ImportGraphDefOptions.cs +++ b/src/TensorFlowNET.Core/Graphs/ImportGraphDefOptions.cs @@ -22,7 +22,7 @@ namespace Tensorflow { public SafeImportGraphDefOptionsHandle Handle { get; } - public int NumReturnOutputs + public int NumReturnOutputs => c_api.TF_ImportGraphDefOptionsNumReturnOutputs(Handle); public ImportGraphDefOptions() diff --git a/src/TensorFlowNET.Core/Graphs/NullContextmanager.cs b/src/TensorFlowNET.Core/Graphs/NullContextmanager.cs index a8b57ea3..7a2e2dc3 100644 --- a/src/TensorFlowNET.Core/Graphs/NullContextmanager.cs +++ b/src/TensorFlowNET.Core/Graphs/NullContextmanager.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Graphs/_ControlDependenciesController.cs b/src/TensorFlowNET.Core/Graphs/_ControlDependenciesController.cs index e3deb7f8..66f90d5c 100644 --- a/src/TensorFlowNET.Core/Graphs/_ControlDependenciesController.cs +++ b/src/TensorFlowNET.Core/Graphs/_ControlDependenciesController.cs @@ -16,7 +16,6 @@ using System.Collections.Generic; using Tensorflow.Operations; -using static Tensorflow.Binding; namespace Tensorflow { @@ -112,17 +111,17 @@ namespace Tensorflow public void Dispose() { - + } public void __init__() { - + } public void __del__() { - + } } } diff --git a/src/TensorFlowNET.Core/Graphs/c_api.graph.cs b/src/TensorFlowNET.Core/Graphs/c_api.graph.cs index 87d19917..280e4bb6 100644 --- a/src/TensorFlowNET.Core/Graphs/c_api.graph.cs +++ b/src/TensorFlowNET.Core/Graphs/c_api.graph.cs @@ -103,7 +103,7 @@ namespace Tensorflow /// TF_Status* [DllImport(TensorFlowLibName)] public static extern void TF_GraphImportGraphDef(IntPtr graph, SafeBufferHandle graph_def, SafeImportGraphDefOptionsHandle options, SafeStatusHandle status); - + /// /// Iterate through the operations of a graph. /// @@ -308,8 +308,8 @@ namespace Tensorflow /// const TF_DataType* /// TF_Status* [DllImport(TensorFlowLibName)] - public static extern void TF_GraphSetOutputHandleShapesAndTypes(IntPtr graph, TF_Output output, - int num_shapes_and_types, IntPtr[] shapes, int[] ranks, DataType[] types, + public static extern void TF_GraphSetOutputHandleShapesAndTypes(IntPtr graph, TF_Output output, + int num_shapes_and_types, IntPtr[] shapes, int[] ranks, DataType[] types, SafeStatusHandle status); /// @@ -320,7 +320,7 @@ namespace Tensorflow /// /// TF_Status* [DllImport(TensorFlowLibName)] - + public static extern void TF_UpdateEdge(IntPtr graph, TF_Output new_src, TF_Input dst, SafeStatusHandle status); } } diff --git a/src/TensorFlowNET.Core/Interfaces/IFlatten.cs b/src/TensorFlowNET.Core/Interfaces/IFlatten.cs index e7b076e9..ffabf1d0 100644 --- a/src/TensorFlowNET.Core/Interfaces/IFlatten.cs +++ b/src/TensorFlowNET.Core/Interfaces/IFlatten.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public interface ICanBeFlattened { diff --git a/src/TensorFlowNET.Core/Interfaces/IPackable.cs b/src/TensorFlowNET.Core/Interfaces/IPackable.cs index 94e31ece..8deffea9 100644 --- a/src/TensorFlowNET.Core/Interfaces/IPackable.cs +++ b/src/TensorFlowNET.Core/Interfaces/IPackable.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public interface IPackable { diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.Linear.cs b/src/TensorFlowNET.Core/Keras/Activations/Activations.Linear.cs index fd1ce7ab..acd4de6e 100644 --- a/src/TensorFlowNET.Core/Keras/Activations/Activations.Linear.cs +++ b/src/TensorFlowNET.Core/Keras/Activations/Activations.Linear.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; - -namespace Tensorflow.Keras +namespace Tensorflow.Keras { public partial class Activations { diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.Relu.cs b/src/TensorFlowNET.Core/Keras/Activations/Activations.Relu.cs index af6849e9..d4f08088 100644 --- a/src/TensorFlowNET.Core/Keras/Activations/Activations.Relu.cs +++ b/src/TensorFlowNET.Core/Keras/Activations/Activations.Relu.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Operations; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow.Keras { diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.Sigmoid.cs b/src/TensorFlowNET.Core/Keras/Activations/Activations.Sigmoid.cs index 90bfed35..67a7fa98 100644 --- a/src/TensorFlowNET.Core/Keras/Activations/Activations.Sigmoid.cs +++ b/src/TensorFlowNET.Core/Keras/Activations/Activations.Sigmoid.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Operations; using static Tensorflow.Binding; namespace Tensorflow.Keras diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.Tanh.cs b/src/TensorFlowNET.Core/Keras/Activations/Activations.Tanh.cs index a49bd2c1..fb74c539 100644 --- a/src/TensorFlowNET.Core/Keras/Activations/Activations.Tanh.cs +++ b/src/TensorFlowNET.Core/Keras/Activations/Activations.Tanh.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Operations; using static Tensorflow.Binding; namespace Tensorflow.Keras diff --git a/src/TensorFlowNET.Core/Keras/Activations/Activations.cs b/src/TensorFlowNET.Core/Keras/Activations/Activations.cs index ad4d8d59..b8f321e6 100644 --- a/src/TensorFlowNET.Core/Keras/Activations/Activations.cs +++ b/src/TensorFlowNET.Core/Keras/Activations/Activations.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; - -namespace Tensorflow.Keras +namespace Tensorflow.Keras { public delegate Tensor Activation(Tensor features, string name = null); } diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/BatchNormalizationArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/BatchNormalizationArgs.cs index 888082c7..56a69830 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/BatchNormalizationArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/BatchNormalizationArgs.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow.Keras.ArgsDefinition { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/Conv2DArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/Conv2DArgs.cs index 838954fc..767a5f80 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/Conv2DArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/Conv2DArgs.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class Conv2DArgs : ConvolutionalArgs { - + } } diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/ConvolutionalArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/ConvolutionalArgs.cs index 00d1706b..d70b7d67 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/ConvolutionalArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/ConvolutionalArgs.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow.Keras.ArgsDefinition diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/DataHandlerArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/DataHandlerArgs.cs index 585ca19b..23fa1d45 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/DataHandlerArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/DataHandlerArgs.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.Engine; +using Tensorflow.Keras.Engine; namespace Tensorflow.Keras.ArgsDefinition { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/DenseArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/DenseArgs.cs index e79a7c25..7ff89c94 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/DenseArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/DenseArgs.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Operations.Activation; using static Tensorflow.Binding; namespace Tensorflow.Keras.ArgsDefinition diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/DropoutArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/DropoutArgs.cs index 4317edf4..186281ea 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/DropoutArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/DropoutArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class DropoutArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/EmbeddingArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/EmbeddingArgs.cs index d40e7552..b1f4fddd 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/EmbeddingArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/EmbeddingArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class EmbeddingArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/FlattenArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/FlattenArgs.cs index 3f31d532..c2b48cc2 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/FlattenArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/FlattenArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class FlattenArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/InputLayerArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/InputLayerArgs.cs index f02a42b1..723109c2 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/InputLayerArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/InputLayerArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class InputLayerArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/LSTMArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/LSTMArgs.cs index c4951bf6..0a2555a6 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/LSTMArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/LSTMArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class LSTMArgs : RNNArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/LSTMCellArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/LSTMCellArgs.cs index aba0d268..62f9a0c4 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/LSTMCellArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/LSTMCellArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class LSTMCellArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/LayerArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/LayerArgs.cs index 182e616e..9b37f951 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/LayerArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/LayerArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/MaxPooling2D.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/MaxPooling2D.cs index c8c86b9a..c2eb9d3c 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/MaxPooling2D.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/MaxPooling2D.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.Layers; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class MaxPooling2DArgs : Pooling2DArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/ModelArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/ModelArgs.cs index b1f3569c..57b8bb69 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/ModelArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/ModelArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class ModelArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/NodeArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/NodeArgs.cs index a1448b5f..6c3284d3 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/NodeArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/NodeArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.Engine; -using Tensorflow.Keras.Layers; +using Tensorflow.Keras.Engine; namespace Tensorflow.Keras.ArgsDefinition { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/OptimizerV2Args.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/OptimizerV2Args.cs index c138f5d1..e2a0e43c 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/OptimizerV2Args.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/OptimizerV2Args.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class OptimizerV2Args { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/Pooling2DArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/Pooling2DArgs.cs index 3ff9092c..9fafb658 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/Pooling2DArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/Pooling2DArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class Pooling2DArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/RMSpropArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/RMSpropArgs.cs index cca1bf16..ac9a3d11 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/RMSpropArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/RMSpropArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class RMSpropArgs : OptimizerV2Args { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/RNNArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/RNNArgs.cs index 56a9a0dc..623cc68e 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/RNNArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/RNNArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class RNNArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/RescalingArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/RescalingArgs.cs index edbbc642..ec9b5315 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/RescalingArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/RescalingArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.ArgsDefinition +namespace Tensorflow.Keras.ArgsDefinition { public class RescalingArgs : LayerArgs { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/SequentialArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/SequentialArgs.cs index 925ceca5..fbdb378d 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/SequentialArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/SequentialArgs.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using Tensorflow.Keras.Engine; namespace Tensorflow.Keras.ArgsDefinition diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs index 80bcff88..6492780e 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorFlowOpLayerArgs.cs @@ -1,7 +1,5 @@ using NumSharp; -using System; using System.Collections.Generic; -using System.Text; namespace Tensorflow.Keras.ArgsDefinition { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorLikeDataAdapterArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorLikeDataAdapterArgs.cs index d8a4dba4..ed8d8bf1 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorLikeDataAdapterArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/TensorLikeDataAdapterArgs.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.Engine; +using Tensorflow.Keras.Engine; namespace Tensorflow.Keras.ArgsDefinition { diff --git a/src/TensorFlowNET.Core/Keras/ArgsDefinition/ZeroPadding2DArgs.cs b/src/TensorFlowNET.Core/Keras/ArgsDefinition/ZeroPadding2DArgs.cs index 5103839c..baf347e1 100644 --- a/src/TensorFlowNET.Core/Keras/ArgsDefinition/ZeroPadding2DArgs.cs +++ b/src/TensorFlowNET.Core/Keras/ArgsDefinition/ZeroPadding2DArgs.cs @@ -1,7 +1,4 @@ using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow.Keras.ArgsDefinition { diff --git a/src/TensorFlowNET.Core/Keras/BackendBase.cs b/src/TensorFlowNET.Core/Keras/BackendBase.cs index a53db62e..c29fa273 100644 --- a/src/TensorFlowNET.Core/Keras/BackendBase.cs +++ b/src/TensorFlowNET.Core/Keras/BackendBase.cs @@ -49,7 +49,7 @@ namespace Tensorflow.Keras else if (isinstance(value, typeof(string))) { ImageDataFormat dataFormat; - if(Enum.TryParse((string)value, true, out dataFormat)) + if (Enum.TryParse((string)value, true, out dataFormat)) { if (Enum.IsDefined(typeof(ImageDataFormat), dataFormat) | dataFormat.ToString().Contains(",")) return dataFormat; @@ -67,7 +67,7 @@ namespace Tensorflow.Keras else if (dim_ordering == ImageDimOrder.tf) _IMAGE_DATA_FORMAT = ImageDataFormat.channels_last; else - throw new Exception("Unknown dim_ordering:"+ dim_ordering); + throw new Exception("Unknown dim_ordering:" + dim_ordering); } public ImageDimOrder image_dim_ordering() diff --git a/src/TensorFlowNET.Core/Keras/Datasets/DatasetPass.cs b/src/TensorFlowNET.Core/Keras/Datasets/DatasetPass.cs index 48fb3b82..96ecaa19 100644 --- a/src/TensorFlowNET.Core/Keras/Datasets/DatasetPass.cs +++ b/src/TensorFlowNET.Core/Keras/Datasets/DatasetPass.cs @@ -1,7 +1,4 @@ using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow.Keras.Datasets { diff --git a/src/TensorFlowNET.Core/Keras/Datasets/KerasDataset.cs b/src/TensorFlowNET.Core/Keras/Datasets/KerasDataset.cs index 5aabfdf0..49f90e09 100644 --- a/src/TensorFlowNET.Core/Keras/Datasets/KerasDataset.cs +++ b/src/TensorFlowNET.Core/Keras/Datasets/KerasDataset.cs @@ -14,10 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using System.Text; - namespace Tensorflow.Keras.Datasets { public class KerasDataset diff --git a/src/TensorFlowNET.Core/Keras/Datasets/Mnist.cs b/src/TensorFlowNET.Core/Keras/Datasets/Mnist.cs index 37eae319..4cc4dbdb 100644 --- a/src/TensorFlowNET.Core/Keras/Datasets/Mnist.cs +++ b/src/TensorFlowNET.Core/Keras/Datasets/Mnist.cs @@ -16,10 +16,8 @@ using NumSharp; using System; -using System.Collections.Generic; using System.IO; using System.Net; -using System.Text; namespace Tensorflow.Keras.Datasets { diff --git a/src/TensorFlowNET.Core/Keras/Engine/CallContext.cs b/src/TensorFlowNET.Core/Keras/Engine/CallContext.cs index 7f63f088..3768ed52 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/CallContext.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/CallContext.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Engine +namespace Tensorflow.Keras.Engine { public class CallContext { diff --git a/src/TensorFlowNET.Core/Keras/Engine/CallContextManager.cs b/src/TensorFlowNET.Core/Keras/Engine/CallContextManager.cs index fca7404f..1d76cf02 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/CallContextManager.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/CallContextManager.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow.Keras.Engine { @@ -8,7 +6,7 @@ namespace Tensorflow.Keras.Engine { public void Dispose() { - + } } } diff --git a/src/TensorFlowNET.Core/Keras/Engine/Container.cs b/src/TensorFlowNET.Core/Keras/Engine/Container.cs index f8e6c0f4..baf5e662 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Container.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Container.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Engine +namespace Tensorflow.Keras.Engine { public class Container { diff --git a/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/DataHandler.cs b/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/DataHandler.cs index f744473d..de5f4a8c 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/DataHandler.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/DataHandler.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using static Tensorflow.Binding; @@ -27,7 +26,7 @@ namespace Tensorflow.Keras.Engine.DataAdapters public DataHandler(DataHandlerArgs args) { this.args = args; - if(args.StepsPerExecution == null) + if (args.StepsPerExecution == null) { _steps_per_execution = tf.Variable(1); _steps_per_execution_value = 1; @@ -54,7 +53,7 @@ namespace Tensorflow.Keras.Engine.DataAdapters _dataset = _adapter.GetDataset(); _inferred_steps = _infer_steps(args.StepsPerEpoch, _dataset); _current_step = 0; - _step_increment = args.StepsPerExecution.numpy() - 1; + _step_increment = args.StepsPerExecution.numpy() - 1; _insufficient_data = false; } @@ -84,7 +83,7 @@ namespace Tensorflow.Keras.Engine.DataAdapters public IEnumerable steps() { _current_step = 0; - while(_current_step < _inferred_steps) + while (_current_step < _inferred_steps) { if (_insufficient_data) break; diff --git a/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/IDataAdapter.cs b/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/IDataAdapter.cs index b39a9eaf..587ebfe0 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/IDataAdapter.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/IDataAdapter.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Engine.DataAdapters +namespace Tensorflow.Keras.Engine.DataAdapters { /// /// In TF 2.0, tf.data is the preferred API for user to feed in data. In order diff --git a/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/TensorLikeDataAdapter.cs b/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/TensorLikeDataAdapter.cs index 8797ba7c..d2e47966 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/TensorLikeDataAdapter.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/DataAdapters/TensorLikeDataAdapter.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Keras/Engine/Flatten.cs b/src/TensorFlowNET.Core/Keras/Engine/Flatten.cs index 2f1aae0d..53ce2b63 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Flatten.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Flatten.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Utils; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Keras/Engine/Functional.cs b/src/TensorFlowNET.Core/Keras/Engine/Functional.cs index b1223665..235a83d9 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Functional.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Functional.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Utils; using static Tensorflow.Binding; @@ -27,7 +26,7 @@ namespace Tensorflow.Keras.Engine Dictionary tensor_usage_count; public Dictionary TensorUsageCount => tensor_usage_count; - public Functional(Tensors inputs, Tensors outputs, string name = null) + public Functional(Tensors inputs, Tensors outputs, string name = null) : base(new ModelArgs { Name = name, @@ -68,7 +67,7 @@ namespace Tensorflow.Keras.Engine } // Build self._input_layers: - foreach(var x in inputs) + foreach (var x in inputs) { var (layer, node_index, tensor_index) = x.KerasHistory; _input_layers.append(layer); @@ -117,9 +116,9 @@ namespace Tensorflow.Keras.Engine { var available_tensors = inputs.Select(x => x.GetHashCode()).ToList(); var depth_keys = NodesByDepth.Keys.OrderBy(x => x).Reverse().Skip(1).ToArray(); - foreach(var depth in depth_keys) + foreach (var depth in depth_keys) { - foreach(var node in NodesByDepth[depth]) + foreach (var node in NodesByDepth[depth]) { var input_tensors = node.KerasInputs.Select(x => x.GetHashCode()).ToArray(); if (input_tensors.issubset(available_tensors)) @@ -178,7 +177,7 @@ namespace Tensorflow.Keras.Engine // Update the depth of inbound nodes. // The "depth" of a node is the max of the depths // of all nodes it is connected to + 1. - foreach(var node_dep in node.ParentNodes) + foreach (var node_dep in node.ParentNodes) { previous_depth = nodes_depths.Get(node_dep, 0); nodes_depths[node_dep] = Math.Max(depth + 1, previous_depth); @@ -188,7 +187,7 @@ namespace Tensorflow.Keras.Engine // Handle inputs that are not connected to outputs. // We do not error out here because the inputs may be used to compute losses // and metrics. - foreach(var input_t in inputs) + foreach (var input_t in inputs) { var (input_layer, _, _) = input_t.KerasHistory; if (!layers_depths.ContainsKey(input_layer)) @@ -222,7 +221,7 @@ namespace Tensorflow.Keras.Engine // Set self.layers ordered by depth. var layers = new List(); - foreach(var depth in depth_keys) + foreach (var depth in depth_keys) { var layers_for_depth = layers_by_depth[depth]; @@ -252,17 +251,17 @@ namespace Tensorflow.Keras.Engine var nodes_in_decreasing_depth = new List(); var layer_indices = new Dictionary(); foreach (var output in outputs) - BuildMapHelper(output, - finished_nodes, - nodes_in_progress, - nodes_in_decreasing_depth, + BuildMapHelper(output, + finished_nodes, + nodes_in_progress, + nodes_in_decreasing_depth, layer_indices); return (nodes_in_decreasing_depth, layer_indices); } - void BuildMapHelper(Tensor tensor, - List finished_nodes, + void BuildMapHelper(Tensor tensor, + List finished_nodes, List nodes_in_progress, List nodes_in_decreasing_depth, Dictionary layer_indices) @@ -325,10 +324,10 @@ namespace Tensorflow.Keras.Engine var depth_keys = NodesByDepth.Keys.OrderBy(x => x).Reverse().ToArray(); - foreach(var depth in depth_keys) + foreach (var depth in depth_keys) { var nodes = NodesByDepth[depth]; - foreach(var node in nodes) + foreach (var node in nodes) { // Input tensors already exist. if (node.IsInput) @@ -337,7 +336,7 @@ namespace Tensorflow.Keras.Engine var layer_inputs = node.MapArguments(tensor_dict); var outputs = node.Layer.Apply(layer_inputs, is_training: training); - + // Update tensor_dict for next input foreach (var (x_id, y) in zip(node.FlatOutputIds, outputs)) tensor_dict[x_id] = new Queue(Enumerable.Range(0, tensor_usage_count[x_id]).Select(x => y)); diff --git a/src/TensorFlowNET.Core/Keras/Engine/InputSpec.cs b/src/TensorFlowNET.Core/Keras/Engine/InputSpec.cs index cae054ce..4993fc2a 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/InputSpec.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/InputSpec.cs @@ -45,7 +45,7 @@ namespace Tensorflow.Keras.Engine if (ndim == null && shape != null) this.ndim = shape.ndim; - if(axes != null) + if (axes != null) AllAxisDim = axes.Select(x => x.Value).ToArray(); } diff --git a/src/TensorFlowNET.Core/Keras/Engine/KerasHistory.cs b/src/TensorFlowNET.Core/Keras/Engine/KerasHistory.cs index bdee38ce..0450c726 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/KerasHistory.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/KerasHistory.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Engine +namespace Tensorflow.Keras.Engine { /// /// Tracks the Layer call that created a Tensor, for Keras Graph Networks. diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.AddWeights.cs b/src/TensorFlowNET.Core/Keras/Engine/Layer.AddWeights.cs index f863dfdf..1edbd168 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Layer.AddWeights.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Layer.AddWeights.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.Utils; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.Apply.cs b/src/TensorFlowNET.Core/Keras/Engine/Layer.Apply.cs index 06897cb8..f04e5330 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Layer.Apply.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Layer.Apply.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using Tensorflow.Keras.Utils; +using System.Threading; using static Tensorflow.Binding; namespace Tensorflow.Keras.Engine diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.FlattenLayers.cs b/src/TensorFlowNET.Core/Keras/Engine/Layer.FlattenLayers.cs index 48720e6f..1759b17d 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Layer.FlattenLayers.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Layer.FlattenLayers.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Tensorflow.Keras.Engine { diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.FunctionalConstructionCall.cs b/src/TensorFlowNET.Core/Keras/Engine/Layer.FunctionalConstructionCall.cs index a11c8850..391d47de 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Layer.FunctionalConstructionCall.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Layer.FunctionalConstructionCall.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.Utils; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.Layers.cs b/src/TensorFlowNET.Core/Keras/Engine/Layer.Layers.cs index dd809f83..9a0520a0 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Layer.Layers.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Layer.Layers.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.ArgsDefinition; -using Tensorflow.Keras.Layers; -using Tensorflow.Operations.Activation; -using static Tensorflow.Binding; +using System.Collections.Generic; namespace Tensorflow.Keras.Engine { diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.LoadWeights.cs b/src/TensorFlowNET.Core/Keras/Engine/Layer.LoadWeights.cs index 99ced6a3..fa833da3 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Layer.LoadWeights.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Layer.LoadWeights.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Engine +namespace Tensorflow.Keras.Engine { public partial class Layer { @@ -12,7 +8,7 @@ namespace Tensorflow.Keras.Engine /// public void load_weights(string filepath) { - + } } } diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.State.cs b/src/TensorFlowNET.Core/Keras/Engine/Layer.State.cs index 947767e6..43a72c36 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Layer.State.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Layer.State.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; namespace Tensorflow.Keras.Engine { diff --git a/src/TensorFlowNET.Core/Keras/Engine/Layer.cs b/src/TensorFlowNET.Core/Keras/Engine/Layer.cs index 00cd858d..4e5dc45d 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Layer.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Layer.cs @@ -19,7 +19,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using Tensorflow.Keras.ArgsDefinition; -using Tensorflow.Keras.Layers; using Tensorflow.Keras.Utils; using Tensorflow.Train; using static Tensorflow.Binding; @@ -46,7 +45,7 @@ namespace Tensorflow.Keras.Engine protected bool built; public bool Trainable => args.Trainable; public TF_DataType DType => args.DType; - + /// /// A stateful layer is a layer whose updates are run during inference too, /// for instance stateful RNNs. @@ -68,7 +67,7 @@ namespace Tensorflow.Keras.Engine protected string name; protected string base_name; public string Name => name; - + protected bool computePreviousMask; protected List updates; public TensorShape BatchInputShape => args.BatchInputShape; @@ -113,7 +112,7 @@ namespace Tensorflow.Keras.Engine bool _in_functional_construction_mode(Tensors inputs) { - return tf.Context.executing_eagerly() + return tf.Context.executing_eagerly() && inputs.Count(x => !x.IsEagerTensor) == inputs.Count(); } @@ -179,7 +178,7 @@ namespace Tensorflow.Keras.Engine tf.Context.eager_mode(); build(inputs.shape); tf.Context.restore_mode(); - + built = true; } @@ -190,7 +189,7 @@ namespace Tensorflow.Keras.Engine protected virtual void add_loss(Func losses) { - + } /// @@ -203,7 +202,7 @@ namespace Tensorflow.Keras.Engine { add_loss(() => regularizer.Apply(new RegularizerArgs { - + })); } diff --git a/src/TensorFlowNET.Core/Keras/Engine/LossesContainer.cs b/src/TensorFlowNET.Core/Keras/Engine/LossesContainer.cs index 7e293ecc..ff34ca8e 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/LossesContainer.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/LossesContainer.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Tensorflow.Keras.ArgsDefinition; +using System.Collections.Generic; using Tensorflow.Keras.Losses; using Tensorflow.Keras.Metrics; -using Tensorflow.Keras.Utils; namespace Tensorflow.Keras.Engine { @@ -18,7 +13,7 @@ namespace Tensorflow.Keras.Engine Tensor[] _per_output_metrics; List loss_metric_values; - public LossesContainer(ILossFunc losses, string[] output_names = null) + public LossesContainer(ILossFunc losses, string[] output_names = null) : base(output_names) { _user_losses = losses; @@ -49,7 +44,7 @@ namespace Tensorflow.Keras.Engine loss_values.append(loss_value); loss_metric_values.append(loss_metric_value); - if(loss_values.Count > 0) + if (loss_values.Count > 0) { var total_loss_metric_value = math_ops.add_n(loss_metric_values.ToArray()); _loss_metric.update_state(total_loss_metric_value, batch_dim); diff --git a/src/TensorFlowNET.Core/Keras/Engine/MetricsContainer.cs b/src/TensorFlowNET.Core/Keras/Engine/MetricsContainer.cs index 5e8b4122..b8d734a9 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/MetricsContainer.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/MetricsContainer.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Engine +namespace Tensorflow.Keras.Engine { public class MetricsContainer : Container { diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Compile.cs b/src/TensorFlowNET.Core/Keras/Engine/Model.Compile.cs index 2b037103..003262d9 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Model.Compile.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Model.Compile.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Losses; using Tensorflow.Keras.Optimizers; -using Tensorflow.Keras.Utils; namespace Tensorflow.Keras.Engine { diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Fit.cs b/src/TensorFlowNET.Core/Keras/Engine/Model.Fit.cs index 09e66b54..7eb75d1e 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Model.Fit.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Model.Fit.cs @@ -1,10 +1,7 @@ using NumSharp; using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine.DataAdapters; -using Tensorflow.Keras.Utils; namespace Tensorflow.Keras.Engine { @@ -55,12 +52,12 @@ namespace Tensorflow.Keras.Engine stop_training = false; _train_counter.assign(0); - foreach(var (epoch, iterator) in data_handler.enumerate_epochs()) + foreach (var (epoch, iterator) in data_handler.enumerate_epochs()) { // reset_metrics(); // callbacks.on_epoch_begin(epoch) // data_handler.catch_stop_iteration(); - foreach(var step in data_handler.steps()) + foreach (var step in data_handler.steps()) { // callbacks.on_train_batch_begin(step) step_function(iterator); diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Predict.cs b/src/TensorFlowNET.Core/Keras/Engine/Model.Predict.cs index 61188697..eac84f91 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Model.Predict.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Model.Predict.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine.DataAdapters; -using Tensorflow.Keras.Utils; namespace Tensorflow.Keras.Engine { diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Summary.cs b/src/TensorFlowNET.Core/Keras/Engine/Model.Summary.cs index 97dde0aa..830aee96 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Model.Summary.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Model.Summary.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.Utils; +using Tensorflow.Keras.Utils; namespace Tensorflow.Keras.Engine { diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.Train.cs b/src/TensorFlowNET.Core/Keras/Engine/Model.Train.cs index 7bc9e9c6..6b9caa55 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Model.Train.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Model.Train.cs @@ -1,8 +1,5 @@ -using NumSharp; -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Gradients; using Tensorflow.Keras.Optimizers; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Keras/Engine/Model.cs b/src/TensorFlowNET.Core/Keras/Engine/Model.cs index bbbc5649..fe53d52a 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Model.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Model.cs @@ -1,12 +1,9 @@ -using static Tensorflow.Binding; -using System; +using System.Collections.Generic; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine.DataAdapters; using Tensorflow.Keras.Losses; using Tensorflow.Keras.Optimizers; -using NumSharp; -using System.Collections.Generic; -using System.Data.Common; +using static Tensorflow.Binding; namespace Tensorflow.Keras.Engine { @@ -37,7 +34,7 @@ namespace Tensorflow.Keras.Engine bool stop_training; DataHandler data_handler; - public Model(ModelArgs args) + public Model(ModelArgs args) : base(args) { _init_batch_counters(); @@ -58,8 +55,8 @@ namespace Tensorflow.Keras.Engine void _init_batch_counters() { - _train_counter = tf.Variable(0, - dtype: TF_DataType.TF_INT64, + _train_counter = tf.Variable(0, + dtype: TF_DataType.TF_INT64, aggregation: VariableAggregation.OnlyFirstReplica); _test_counter = tf.Variable(0, diff --git a/src/TensorFlowNET.Core/Keras/Engine/Node.IterateInbound.cs b/src/TensorFlowNET.Core/Keras/Engine/Node.IterateInbound.cs index 6a2ddf22..d18fc8cc 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Node.IterateInbound.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Node.IterateInbound.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Tensorflow.Keras.Engine { @@ -8,7 +6,7 @@ namespace Tensorflow.Keras.Engine { public IEnumerable<(Layer, int, int, Tensor)> iterate_inbound() { - foreach(var kt in KerasInputs) + foreach (var kt in KerasInputs) { var (layer, node_index, tensor_index) = kt.KerasHistory; yield return (layer, node_index, tensor_index, kt); diff --git a/src/TensorFlowNET.Core/Keras/Engine/Node.cs b/src/TensorFlowNET.Core/Keras/Engine/Node.cs index b99d1790..3c4d88ad 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Node.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Node.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using System.Collections.Generic; using System.Linq; using Tensorflow.Keras.ArgsDefinition; @@ -52,7 +51,7 @@ namespace Tensorflow.Keras.Engine get { var node_deps = new List(); - foreach(var kt in KerasInputs) + foreach (var kt in KerasInputs) { var (layer, node_index, _) = kt.KerasHistory; if (layer != null) @@ -60,7 +59,7 @@ namespace Tensorflow.Keras.Engine } return node_deps.ToArray(); } - } + } public Node(Layer layer, NodeArgs args) { @@ -70,7 +69,7 @@ namespace Tensorflow.Keras.Engine if (args.InputTensors != null) KerasInputs.AddRange(args.InputTensors); - foreach(var(i, ele) in enumerate(KerasInputs)) + foreach (var (i, ele) in enumerate(KerasInputs)) _keras_inputs_ids_and_indices[i] = ele.GetHashCode(); // Wire up Node to Layers. diff --git a/src/TensorFlowNET.Core/Keras/Engine/Sequential.cs b/src/TensorFlowNET.Core/Keras/Engine/Sequential.cs index a70a5799..f4b66896 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/Sequential.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/Sequential.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using System.Collections.Generic; -using System.Linq; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Layers; using static Tensorflow.Binding; @@ -42,9 +41,9 @@ namespace Tensorflow.Keras.Engine public TensorShape output_shape => outputs.TensorShape; bool built = false; - public Sequential(SequentialArgs args) - : base(new ModelArgs - { + public Sequential(SequentialArgs args) + : base(new ModelArgs + { Name = args.Name }) { diff --git a/src/TensorFlowNET.Core/Keras/Engine/TensorFlowOpLayer.cs b/src/TensorFlowNET.Core/Keras/Engine/TensorFlowOpLayer.cs index 6bdcc472..84ba57e2 100644 --- a/src/TensorFlowNET.Core/Keras/Engine/TensorFlowOpLayer.cs +++ b/src/TensorFlowNET.Core/Keras/Engine/TensorFlowOpLayer.cs @@ -1,8 +1,6 @@ using NumSharp; -using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Graphs; using Tensorflow.Keras.ArgsDefinition; using static Tensorflow.Binding; @@ -17,14 +15,14 @@ namespace Tensorflow.Keras.Engine static string TF_OP_LAYER_NAME_PREFIX = "tf_op_layer_"; public string OpType => node_def.Op; - public TensorFlowOpLayer(TensorFlowOpLayerArgs args) - : base(new LayerArgs - { - Name = TF_OP_LAYER_NAME_PREFIX + args.Name, - Trainable = args.Trainable, - DType = args.DType, - Autocast = false - }) + public TensorFlowOpLayer(TensorFlowOpLayerArgs args) + : base(new LayerArgs + { + Name = TF_OP_LAYER_NAME_PREFIX + args.Name, + Trainable = args.Trainable, + DType = args.DType, + Autocast = false + }) { this.args = args; built = true; @@ -38,7 +36,7 @@ namespace Tensorflow.Keras.Engine } [AutoGraph] - Tensors _defun_call(Tensors inputs) + Tensors _defun_call(Tensors inputs) => MakOp(inputs); Tensors MakOp(Tensors inputs) diff --git a/src/TensorFlowNET.Core/Keras/KerasApi.cs b/src/TensorFlowNET.Core/Keras/KerasApi.cs index 9d2731c8..7afebfac 100644 --- a/src/TensorFlowNET.Core/Keras/KerasApi.cs +++ b/src/TensorFlowNET.Core/Keras/KerasApi.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; +using System.Collections.Generic; using Tensorflow.Keras; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Datasets; @@ -9,7 +6,6 @@ using Tensorflow.Keras.Engine; using Tensorflow.Keras.Layers; using Tensorflow.Keras.Losses; using Tensorflow.Keras.Optimizers; -using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs b/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs index 1ac0e649..e61391f6 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/BatchNormalization.cs @@ -72,7 +72,7 @@ namespace Tensorflow.Keras.Layers } var axis_to_dim = new Dictionary(); - foreach(var x in axis) + foreach (var x in axis) axis_to_dim[x] = input_shape[x]; inputSpec = new InputSpec(ndim: ndims, axes: axis_to_dim); @@ -186,8 +186,8 @@ namespace Tensorflow.Keras.Layers { momentum_tensor = ops.convert_to_tensor(momentum); } - - if(training_value == null) + + if (training_value == null) { var mean_update = _assign_moving_average(moving_mean.AsTensor(), mean, momentum_tensor); var variance_update = _assign_moving_average(moving_variance.AsTensor(), variance, momentum_tensor); diff --git a/src/TensorFlowNET.Core/Keras/Layers/Conv2D.cs b/src/TensorFlowNET.Core/Keras/Layers/Conv2D.cs index 371d6cfd..c5c21015 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Conv2D.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Conv2D.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using Tensorflow.Keras.ArgsDefinition; -using Tensorflow.Operations.Activation; namespace Tensorflow.Keras.Layers { @@ -23,7 +22,7 @@ namespace Tensorflow.Keras.Layers { public Conv2D(Conv2DArgs args) : base(args) { - + } } } diff --git a/src/TensorFlowNET.Core/Keras/Layers/Convolutional.cs b/src/TensorFlowNET.Core/Keras/Layers/Convolutional.cs index f4bc77c0..1be8527c 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Convolutional.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Convolutional.cs @@ -20,7 +20,6 @@ using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; using Tensorflow.Keras.Utils; using Tensorflow.Operations; -using static Tensorflow.Binding; namespace Tensorflow.Keras.Layers { @@ -59,8 +58,8 @@ namespace Tensorflow.Keras.Layers protected override void build(TensorShape input_shape) { int channel_axis = data_format == "channels_first" ? 1 : -1; - int input_channel = channel_axis < 0 ? - input_shape.dims[input_shape.ndim + channel_axis] : + int input_channel = channel_axis < 0 ? + input_shape.dims[input_shape.ndim + channel_axis] : input_shape.dims[channel_axis]; TensorShape kernel_shape = kernel_size.dims.concat(new int[] { input_channel / args.Groups, filters }); kernel = add_weight(name: "kernel", @@ -108,7 +107,7 @@ namespace Tensorflow.Keras.Layers throw new NotImplementedException("call channels_first"); } else - { + { outputs = nn_ops.bias_add(outputs, bias.AsTensor(), data_format: "NHWC"); } } diff --git a/src/TensorFlowNET.Core/Keras/Layers/Dense.cs b/src/TensorFlowNET.Core/Keras/Layers/Dense.cs index e3e8b8e3..4c864ad1 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Dense.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Dense.cs @@ -19,7 +19,6 @@ using System.Collections.Generic; using System.Linq; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; -using Tensorflow.Operations.Activation; using static Tensorflow.Binding; namespace Tensorflow.Keras.Layers @@ -34,7 +33,7 @@ namespace Tensorflow.Keras.Layers IVariableV1 bias; Activation activation => args.Activation; - public Dense(DenseArgs args) : + public Dense(DenseArgs args) : base(args) { this.args = args; @@ -69,7 +68,7 @@ namespace Tensorflow.Keras.Layers { Tensor outputs = null; var rank = inputs.rank; - if(rank > 2) + if (rank > 2) { throw new NotImplementedException("call rank > 2"); } diff --git a/src/TensorFlowNET.Core/Keras/Layers/Dropout.cs b/src/TensorFlowNET.Core/Keras/Layers/Dropout.cs index 1b9f138f..2eba70c7 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Dropout.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Dropout.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.ArgsDefinition; +using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; using Tensorflow.Keras.Utils; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Keras/Layers/InputLayer.cs b/src/TensorFlowNET.Core/Keras/Layers/InputLayer.cs index 8cdaf101..f10a1a7b 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/InputLayer.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/InputLayer.cs @@ -14,8 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; using System.Linq; using Tensorflow.Framework.Models; using Tensorflow.Keras.ArgsDefinition; @@ -33,14 +31,14 @@ namespace Tensorflow.Keras.Layers bool isPlaceholder; TensorSpec typeSpec; - public InputLayer(InputLayerArgs args) : + public InputLayer(InputLayerArgs args) : base(args) { this.args = args; built = true; SupportsMasking = true; - if(BatchInputShape != null) + if (BatchInputShape != null) { args.BatchSize = BatchInputShape.dims[0]; args.InputShape = BatchInputShape.dims[1..]; @@ -52,8 +50,8 @@ namespace Tensorflow.Keras.Layers var prefix = "input"; name = prefix + '_' + tf.keras.backend.get_uid(prefix); } - - if(args.DType == TF_DataType.DtInvalid) + + if (args.DType == TF_DataType.DtInvalid) { args.DType = args.InputTensor == null ? tf.float32 : args.InputTensor.dtype; } @@ -63,7 +61,7 @@ namespace Tensorflow.Keras.Layers if (args.InputTensor == null) { - if(args.InputShape != null) + if (args.InputShape != null) { args.BatchInputShape = new int[] { args.BatchSize } .Concat(args.InputShape.dims) @@ -80,7 +78,7 @@ namespace Tensorflow.Keras.Layers name: Name, sparse: args.Sparse, ragged: args.Ragged); - + isPlaceholder = true; } diff --git a/src/TensorFlowNET.Core/Keras/Layers/LSTM.cs b/src/TensorFlowNET.Core/Keras/Layers/LSTM.cs index 87728fdf..3db6afba 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/LSTM.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/LSTM.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; diff --git a/src/TensorFlowNET.Core/Keras/Layers/LSTMCell.cs b/src/TensorFlowNET.Core/Keras/Layers/LSTMCell.cs index 09babb20..dda279a7 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/LSTMCell.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/LSTMCell.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Text; -using Tensorflow.Keras.ArgsDefinition; +using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; namespace Tensorflow.Keras.Layers diff --git a/src/TensorFlowNET.Core/Keras/Layers/LayersApi.cs b/src/TensorFlowNET.Core/Keras/Layers/LayersApi.cs index 9bd75578..1a529f44 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/LayersApi.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/LayersApi.cs @@ -1,7 +1,4 @@ using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs b/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs index 1c3c3920..c19030be 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/MaxPooling2D.cs @@ -5,7 +5,7 @@ namespace Tensorflow.Keras.Layers { public class MaxPooling2D : Pooling2D { - public MaxPooling2D(MaxPooling2DArgs args) + public MaxPooling2D(MaxPooling2DArgs args) : base(args) { args.PoolFunction = tf.nn.max_pool_fn; diff --git a/src/TensorFlowNET.Core/Keras/Layers/Pooling2D.cs b/src/TensorFlowNET.Core/Keras/Layers/Pooling2D.cs index daf57b1e..72285540 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Pooling2D.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Pooling2D.cs @@ -25,7 +25,7 @@ namespace Tensorflow.Keras.Layers Pooling2DArgs args; InputSpec input_spec; - public Pooling2D(Pooling2DArgs args) + public Pooling2D(Pooling2DArgs args) : base(args) { this.args = args; diff --git a/src/TensorFlowNET.Core/Keras/Layers/RNN.cs b/src/TensorFlowNET.Core/Keras/Layers/RNN.cs index 0f00058f..3d03abb1 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/RNN.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/RNN.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; diff --git a/src/TensorFlowNET.Core/Keras/Layers/Rescaling.cs b/src/TensorFlowNET.Core/Keras/Layers/Rescaling.cs index ba8f3901..f81ee161 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/Rescaling.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/Rescaling.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.ArgsDefinition; +using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; namespace Tensorflow.Keras.Layers diff --git a/src/TensorFlowNET.Core/Keras/Layers/ZeroPadding2D.cs b/src/TensorFlowNET.Core/Keras/Layers/ZeroPadding2D.cs index 07dc6b03..e0fb8ec1 100644 --- a/src/TensorFlowNET.Core/Keras/Layers/ZeroPadding2D.cs +++ b/src/TensorFlowNET.Core/Keras/Layers/ZeroPadding2D.cs @@ -1,7 +1,4 @@ using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; using Tensorflow.Keras.Utils; @@ -21,7 +18,7 @@ namespace Tensorflow.Keras.Layers NDArray padding; InputSpec input_spec; - public ZeroPadding2D(ZeroPadding2DArgs args, string data_format = null) + public ZeroPadding2D(ZeroPadding2DArgs args, string data_format = null) : base(args) { this.data_format = conv_utils.normalize_data_format(data_format); diff --git a/src/TensorFlowNET.Core/Keras/Losses/ILossFunc.cs b/src/TensorFlowNET.Core/Keras/Losses/ILossFunc.cs index 2ec58125..45c39dd2 100644 --- a/src/TensorFlowNET.Core/Keras/Losses/ILossFunc.cs +++ b/src/TensorFlowNET.Core/Keras/Losses/ILossFunc.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Losses +namespace Tensorflow.Keras.Losses { public interface ILossFunc { diff --git a/src/TensorFlowNET.Core/Keras/Losses/Loss.cs b/src/TensorFlowNET.Core/Keras/Losses/Loss.cs index f29a1ae1..07d629b6 100644 --- a/src/TensorFlowNET.Core/Keras/Losses/Loss.cs +++ b/src/TensorFlowNET.Core/Keras/Losses/Loss.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.Utils; -using static Tensorflow.Binding; namespace Tensorflow.Keras.Losses { diff --git a/src/TensorFlowNET.Core/Keras/Losses/LossFunctionWrapper.cs b/src/TensorFlowNET.Core/Keras/Losses/LossFunctionWrapper.cs index eeac4632..af352aa9 100644 --- a/src/TensorFlowNET.Core/Keras/Losses/LossFunctionWrapper.cs +++ b/src/TensorFlowNET.Core/Keras/Losses/LossFunctionWrapper.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Losses +namespace Tensorflow.Keras.Losses { public class LossFunctionWrapper : Loss { - public LossFunctionWrapper(string reduction = ReductionV2.AUTO, - string name = null) - : base(reduction: reduction, + public LossFunctionWrapper(string reduction = ReductionV2.AUTO, + string name = null) + : base(reduction: reduction, name: name) { } diff --git a/src/TensorFlowNET.Core/Keras/Losses/LossesApi.cs b/src/TensorFlowNET.Core/Keras/Losses/LossesApi.cs index 9ab1bd27..7fa47944 100644 --- a/src/TensorFlowNET.Core/Keras/Losses/LossesApi.cs +++ b/src/TensorFlowNET.Core/Keras/Losses/LossesApi.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Losses +namespace Tensorflow.Keras.Losses { public class LossesApi { diff --git a/src/TensorFlowNET.Core/Keras/Losses/ReductionV2.cs b/src/TensorFlowNET.Core/Keras/Losses/ReductionV2.cs index da4dca2e..afe2006d 100644 --- a/src/TensorFlowNET.Core/Keras/Losses/ReductionV2.cs +++ b/src/TensorFlowNET.Core/Keras/Losses/ReductionV2.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Losses +namespace Tensorflow.Keras.Losses { public class ReductionV2 { diff --git a/src/TensorFlowNET.Core/Keras/Losses/SparseCategoricalCrossentropy.cs b/src/TensorFlowNET.Core/Keras/Losses/SparseCategoricalCrossentropy.cs index c7ec060f..fe14e887 100644 --- a/src/TensorFlowNET.Core/Keras/Losses/SparseCategoricalCrossentropy.cs +++ b/src/TensorFlowNET.Core/Keras/Losses/SparseCategoricalCrossentropy.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow.Keras.Losses { @@ -10,8 +6,8 @@ namespace Tensorflow.Keras.Losses { public SparseCategoricalCrossentropy(bool from_logits = false, string reduction = ReductionV2.AUTO, - string name = "sparse_categorical_crossentropy") : - base(reduction: reduction, + string name = "sparse_categorical_crossentropy") : + base(reduction: reduction, name: name) { diff --git a/src/TensorFlowNET.Core/Keras/Metrics/Mean.cs b/src/TensorFlowNET.Core/Keras/Metrics/Mean.cs index b1f9c419..d3147fae 100644 --- a/src/TensorFlowNET.Core/Keras/Metrics/Mean.cs +++ b/src/TensorFlowNET.Core/Keras/Metrics/Mean.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.ArgsDefinition; - -namespace Tensorflow.Keras.Metrics +namespace Tensorflow.Keras.Metrics { /// /// Computes the (weighted) mean of the given values. diff --git a/src/TensorFlowNET.Core/Keras/Metrics/Metric.cs b/src/TensorFlowNET.Core/Keras/Metrics/Metric.cs index f5ae28bd..59cab031 100644 --- a/src/TensorFlowNET.Core/Keras/Metrics/Metric.cs +++ b/src/TensorFlowNET.Core/Keras/Metrics/Metric.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Engine; using static Tensorflow.Binding; @@ -23,14 +21,14 @@ namespace Tensorflow.Keras.Metrics built = true; } - protected override IVariableV1 add_weight(string name, - TensorShape shape = null, - TF_DataType dtype = TF_DataType.TF_FLOAT, - IInitializer initializer = null, - IRegularizer regularizer = null, - VariableSynchronization synchronization = VariableSynchronization.OnRead, - VariableAggregation aggregation = VariableAggregation.Sum, - bool trainable = true, + protected override IVariableV1 add_weight(string name, + TensorShape shape = null, + TF_DataType dtype = TF_DataType.TF_FLOAT, + IInitializer initializer = null, + IRegularizer regularizer = null, + VariableSynchronization synchronization = VariableSynchronization.OnRead, + VariableAggregation aggregation = VariableAggregation.Sum, + bool trainable = true, Func getter = null) { if (shape == null) diff --git a/src/TensorFlowNET.Core/Keras/Metrics/Reduce.cs b/src/TensorFlowNET.Core/Keras/Metrics/Reduce.cs index 99d1473e..15dcbf4b 100644 --- a/src/TensorFlowNET.Core/Keras/Metrics/Reduce.cs +++ b/src/TensorFlowNET.Core/Keras/Metrics/Reduce.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.ArgsDefinition; -using Tensorflow.Keras.Losses; +using Tensorflow.Keras.Losses; using Tensorflow.Keras.Utils; using static Tensorflow.Binding; @@ -34,7 +30,7 @@ namespace Tensorflow.Keras.Metrics public Tensor update_state(Tensor values, Tensor sample_weight = null) { - if(sample_weight != null) + if (sample_weight != null) { (values, sample_weight) = losses_utils.squeeze_or_expand_dimensions( values, sample_weight: sample_weight); @@ -59,7 +55,7 @@ namespace Tensorflow.Keras.Metrics num_values = math_ops.reduce_sum(sample_weight); } - return tf_with(ops.control_dependencies(new[] { update_total_op }), ctl + return tf_with(ops.control_dependencies(new[] { update_total_op }), ctl => count.assign_add(num_values)); } } diff --git a/src/TensorFlowNET.Core/Keras/Metrics/Sum.cs b/src/TensorFlowNET.Core/Keras/Metrics/Sum.cs index 10396867..bf69980c 100644 --- a/src/TensorFlowNET.Core/Keras/Metrics/Sum.cs +++ b/src/TensorFlowNET.Core/Keras/Metrics/Sum.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Metrics +namespace Tensorflow.Keras.Metrics { class Sum { diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/Adam.cs b/src/TensorFlowNET.Core/Keras/Optimizers/Adam.cs index a4df550b..fc5ee449 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/Adam.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/Adam.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Tensorflow.Eager; using Tensorflow.Keras.ArgsDefinition; namespace Tensorflow.Keras.Optimizers @@ -35,7 +33,7 @@ namespace Tensorflow.Keras.Optimizers protected override void _create_slots(IVariableV1[] var_list) { - foreach(var var in var_list) + foreach (var var in var_list) add_slot(var, "m"); foreach (var var in var_list) add_slot(var, "v"); diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/DeviceDType.cs b/src/TensorFlowNET.Core/Keras/Optimizers/DeviceDType.cs index d3aa5590..deaaf438 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/DeviceDType.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/DeviceDType.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Tensorflow.Keras.Optimizers { diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/IOptimizer.cs b/src/TensorFlowNET.Core/Keras/Optimizers/IOptimizer.cs index 0c1d411e..b6099baf 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/IOptimizer.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/IOptimizer.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras.Optimizers +namespace Tensorflow.Keras.Optimizers { public interface IOptimizer { diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/LearningRateSchedule.cs b/src/TensorFlowNET.Core/Keras/Optimizers/LearningRateSchedule.cs index 8bcbb58f..8d3f8b06 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/LearningRateSchedule.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/LearningRateSchedule.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tensorflow.Keras.Optimizers +namespace Tensorflow.Keras.Optimizers { public class LearningRateSchedule { diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerApi.cs b/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerApi.cs index 7ce23204..68010702 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerApi.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerApi.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Keras.ArgsDefinition; +using Tensorflow.Keras.ArgsDefinition; namespace Tensorflow.Keras.Optimizers { diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerV2.cs b/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerV2.cs index fd29ea92..7ad370ae 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerV2.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/OptimizerV2.cs @@ -1,13 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; +using Tensorflow.Keras.ArgsDefinition; using Tensorflow.Keras.Utils; using Tensorflow.Train; using static Tensorflow.Binding; -using Tensorflow; -using Tensorflow.Eager; -using Tensorflow.Keras.ArgsDefinition; namespace Tensorflow.Keras.Optimizers { @@ -89,8 +86,8 @@ namespace Tensorflow.Keras.Optimizers // return var.assign(var.constraint(var)) } - protected virtual Operation _resource_apply_dense(IVariableV1 var, - Tensor grad, + protected virtual Operation _resource_apply_dense(IVariableV1 var, + Tensor grad, Dictionary> _apply_state) { throw new NotImplementedException("_resource_apply_dense"); @@ -102,7 +99,7 @@ namespace Tensorflow.Keras.Optimizers { tf_with(ops.name_scope(name, "", new { skip_on_eager = true }), delegate { - foreach(var (grad, var) in grads_and_vars) + foreach (var (grad, var) in grads_and_vars) { tf_with(ops.name_scope("update"), delegate { @@ -139,7 +136,7 @@ namespace Tensorflow.Keras.Optimizers DType = x.dtype.as_base_dtype() }).Distinct(new DeviceDType()).ToArray(); - foreach(var device_dtype in keys) + foreach (var device_dtype in keys) { _apply_state[device_dtype] = new Dictionary(); _prepare_local(device_dtype, _apply_state); @@ -153,7 +150,7 @@ namespace Tensorflow.Keras.Optimizers throw new NotImplementedException(""); } - protected virtual void _prepare_local(DeviceDType device_dtype, + protected virtual void _prepare_local(DeviceDType device_dtype, Dictionary> _apply_state) { if (_hyper.ContainsKey("learning_rate")) @@ -166,7 +163,7 @@ namespace Tensorflow.Keras.Optimizers Tensor _decayed_lr(TF_DataType var_dtype) { var lr_t = _get_hyper("learning_rate", var_dtype); - if(_initial_decay > 0.0f) + if (_initial_decay > 0.0f) { throw new NotImplementedException(""); } @@ -181,12 +178,12 @@ namespace Tensorflow.Keras.Optimizers void _create_all_weights(IVariableV1[] var_list) { - if(_iterations == null) + if (_iterations == null) { - _iterations = add_weight("iter", - shape: new int[0], - dtype: TF_DataType.TF_INT64, - trainable: false, + _iterations = add_weight("iter", + shape: new int[0], + dtype: TF_DataType.TF_INT64, + trainable: false, aggregation: VariableAggregation.OnlyFirstReplica); _weights.Add(_iterations); } @@ -220,7 +217,7 @@ namespace Tensorflow.Keras.Optimizers protected virtual void _create_slots(IVariableV1[] var_list) { - if(_momentum) + if (_momentum) { /*for var in var_list: self.add_slot(var, "momentum")*/ diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/PolynomialDecay.cs b/src/TensorFlowNET.Core/Keras/Optimizers/PolynomialDecay.cs index 0d9c8306..6e7709ff 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/PolynomialDecay.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/PolynomialDecay.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Tensorflow.Binding; namespace Tensorflow.Keras.Optimizers @@ -47,7 +43,7 @@ namespace Tensorflow.Keras.Optimizers var global_step_recomp = math_ops.cast(step, dtype); var decay_steps_recomp = math_ops.cast(decay_steps, dtype); - if(cycle) + if (cycle) { throw new NotImplementedException("PolynomialDecay cycle"); } diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/RMSprop.cs b/src/TensorFlowNET.Core/Keras/Optimizers/RMSprop.cs index 39cc1f4d..51fffefc 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/RMSprop.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/RMSprop.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using Tensorflow.Keras.ArgsDefinition; namespace Tensorflow.Keras.Optimizers @@ -56,7 +55,7 @@ namespace Tensorflow.Keras.Optimizers break; } } - + var rms = get_slot(var, "rms"); if (_momentum) { diff --git a/src/TensorFlowNET.Core/Keras/Optimizers/SGD.cs b/src/TensorFlowNET.Core/Keras/Optimizers/SGD.cs index d207407f..f97f4b15 100644 --- a/src/TensorFlowNET.Core/Keras/Optimizers/SGD.cs +++ b/src/TensorFlowNET.Core/Keras/Optimizers/SGD.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Tensorflow.Eager; using Tensorflow.Keras.ArgsDefinition; namespace Tensorflow.Keras.Optimizers @@ -10,12 +8,12 @@ namespace Tensorflow.Keras.Optimizers public class SGD : OptimizerV2 { protected override string _name => "SGD"; - + #pragma warning disable CS0169 // The field 'SGD.nesterov' is never used bool nesterov; #pragma warning restore CS0169 // The field 'SGD.nesterov' is never used - public SGD(float learning_rate, + public SGD(float learning_rate, float momentum = 0.0f, bool nesterov = false, float decay = 0.0f) : base(new OptimizerV2Args { }) @@ -32,7 +30,7 @@ namespace Tensorflow.Keras.Optimizers #pragma warning restore CS1717 // Assignment made to same variable } - protected override void _prepare_local(DeviceDType device_dtype, + protected override void _prepare_local(DeviceDType device_dtype, Dictionary> _apply_state) { base._prepare_local(device_dtype, _apply_state); @@ -49,8 +47,8 @@ namespace Tensorflow.Keras.Optimizers } var device_dtype = _apply_state.Keys.FirstOrDefault(x => x.Device == var.Device && x.DType == var.dtype.as_base_dtype()); - return gen_training_ops.resource_apply_gradient_descent(var.Handle, - _apply_state[device_dtype]["lr_t"], + return gen_training_ops.resource_apply_gradient_descent(var.Handle, + _apply_state[device_dtype]["lr_t"], grad, use_locking: _use_locking); } diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.cs b/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.cs index 73b77490..bb17f594 100644 --- a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.cs +++ b/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow.Keras.Preprocessings @@ -12,7 +10,7 @@ namespace Tensorflow.Keras.Preprocessings var label_ds = tf.data.Dataset.from_tensor_slices(labels); if (label_mode == "binary") throw new NotImplementedException(""); - else if(label_mode == "categorical") + else if (label_mode == "categorical") throw new NotImplementedException(""); return label_ds; } diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs b/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs index a8c8d286..4e089fb6 100644 --- a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs +++ b/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.get_training_or_validation_split.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; namespace Tensorflow.Keras.Preprocessings { @@ -17,8 +13,8 @@ namespace Tensorflow.Keras.Preprocessings /// /// public (T1[], T2[]) get_training_or_validation_split(T1[] samples, - T2[] labels, - float validation_split, + T2[] labels, + float validation_split, string subset) { var num_val_samples = Convert.ToInt32(samples.Length * validation_split); diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.index_directory.cs b/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.index_directory.cs index d3548c23..33754b00 100644 --- a/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.index_directory.cs +++ b/src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.index_directory.cs @@ -1,9 +1,7 @@ using NumSharp; -using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; namespace Tensorflow.Keras.Preprocessings { @@ -54,7 +52,7 @@ namespace Tensorflow.Keras.Preprocessings rng.shuffle(random_index); var index = random_index.ToArray(); - for (int i = 0; i< labels.Count; i++) + for (int i = 0; i < labels.Count; i++) { return_labels[i] = labels[index[i]]; return_file_paths[i] = file_paths[index[i]]; diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs b/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs index 708d1660..6e1cfa73 100644 --- a/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs +++ b/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs @@ -1,5 +1,4 @@ -using System; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow.Keras { diff --git a/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs b/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs index c8300382..ad950fc9 100644 --- a/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs +++ b/src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs @@ -1,7 +1,4 @@ -using NumSharp; -using System; -using System.Globalization; -using System.Threading.Tasks; +using System; using static Tensorflow.Binding; namespace Tensorflow.Keras @@ -39,7 +36,7 @@ namespace Tensorflow.Keras img_ds = tf.data.Dataset.zip(img_ds, label_ds); } else*/ - throw new NotImplementedException(""); + throw new NotImplementedException(""); return img_ds; } diff --git a/src/TensorFlowNET.Core/Keras/Regularizers.cs b/src/TensorFlowNET.Core/Keras/Regularizers.cs index 1102b62b..98da27a7 100644 --- a/src/TensorFlowNET.Core/Keras/Regularizers.cs +++ b/src/TensorFlowNET.Core/Keras/Regularizers.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras +namespace Tensorflow.Keras { public class Regularizers { diff --git a/src/TensorFlowNET.Core/Keras/Regularizers/IRegularizer.cs b/src/TensorFlowNET.Core/Keras/Regularizers/IRegularizer.cs index a54a81c7..f4045c7b 100644 --- a/src/TensorFlowNET.Core/Keras/Regularizers/IRegularizer.cs +++ b/src/TensorFlowNET.Core/Keras/Regularizers/IRegularizer.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras +namespace Tensorflow.Keras { public interface IRegularizer { diff --git a/src/TensorFlowNET.Core/Keras/Regularizers/L2.cs b/src/TensorFlowNET.Core/Keras/Regularizers/L2.cs index c0fa7078..9e293e89 100644 --- a/src/TensorFlowNET.Core/Keras/Regularizers/L2.cs +++ b/src/TensorFlowNET.Core/Keras/Regularizers/L2.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow.Keras { diff --git a/src/TensorFlowNET.Core/Keras/Regularizers/RegularizerArgs.cs b/src/TensorFlowNET.Core/Keras/Regularizers/RegularizerArgs.cs index 18bf87a5..90100fe0 100644 --- a/src/TensorFlowNET.Core/Keras/Regularizers/RegularizerArgs.cs +++ b/src/TensorFlowNET.Core/Keras/Regularizers/RegularizerArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Keras +namespace Tensorflow.Keras { public class RegularizerArgs { diff --git a/src/TensorFlowNET.Core/Keras/Sequence.cs b/src/TensorFlowNET.Core/Keras/Sequence.cs index 077c4595..a428a568 100644 --- a/src/TensorFlowNET.Core/Keras/Sequence.cs +++ b/src/TensorFlowNET.Core/Keras/Sequence.cs @@ -34,7 +34,7 @@ namespace Tensorflow.Keras /// String, 'pre' or 'post' /// Float or String, padding value. /// - public NDArray pad_sequences(NDArray sequences, + public NDArray pad_sequences(NDArray sequences, int? maxlen = null, string dtype = "int32", string padding = "pre", @@ -54,7 +54,7 @@ namespace Tensorflow.Keras for (int i = 0; i < nd.shape[0]; i++) #pragma warning restore CS0162 // Unreachable code detected { - switch(sequences[i]) + switch (sequences[i]) { default: throw new NotImplementedException("pad_sequences"); diff --git a/src/TensorFlowNET.Core/Keras/Utils/layer_utils.cs b/src/TensorFlowNET.Core/Keras/Utils/layer_utils.cs index cbba92bf..71a417de 100644 --- a/src/TensorFlowNET.Core/Keras/Utils/layer_utils.cs +++ b/src/TensorFlowNET.Core/Keras/Utils/layer_utils.cs @@ -1,11 +1,9 @@ -using System; +using NumSharp; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using static Tensorflow.Binding; using Tensorflow.Keras.Engine; -using NumSharp; -using System.Security.Cryptography; +using static Tensorflow.Binding; namespace Tensorflow.Keras.Utils { @@ -38,12 +36,12 @@ namespace Tensorflow.Keras.Utils if (sequential_like) { // search for shared layers - foreach(var layer in model.Layers) + foreach (var layer in model.Layers) { var flag = false; - foreach(var node in layer.InboundNodes) + foreach (var node in layer.InboundNodes) { - if(nodes.Contains(node)) + if (nodes.Contains(node)) { if (flag) { @@ -86,20 +84,20 @@ namespace Tensorflow.Keras.Utils foreach (var v in model.NodesByDepth) relevant_nodes.AddRange(v.Value); } - + int[] positions_int = positions.Select(x => Convert.ToInt32(x)).ToArray(); print($"Model: {model.Name}"); print(string.Join("", range(line_length).Select(x => "_"))); print_row(to_display, positions_int); print(string.Join("", range(line_length).Select(x => "="))); - foreach(var (i, layer) in enumerate(model.Layers)) + foreach (var (i, layer) in enumerate(model.Layers)) { if (sequential_like) print_layer_summary(layer, positions_int); else print_layer_summary_with_connections(layer, positions_int, relevant_nodes); - if(i == model.Layers.Count - 1) + if (i == model.Layers.Count - 1) print(string.Join("", range(line_length).Select(x => "="))); else print(string.Join("", range(line_length).Select(x => "_"))); @@ -117,7 +115,7 @@ namespace Tensorflow.Keras.Utils static void print_row(string[] fields, int[] positions) { var line = ""; - foreach(var i in range(fields.Length)) + foreach (var i in range(fields.Length)) { if (i > 0) line = line[0..^1] + " "; @@ -136,7 +134,7 @@ namespace Tensorflow.Keras.Utils { var name = layer.Name; - var fields = new string[] + var fields = new string[] { $"{name} ({layer.GetType().Name})", $"{layer.output_shape}", @@ -173,9 +171,9 @@ namespace Tensorflow.Keras.Utils print_row(fields, positions); - if(connections.Count > 1) + if (connections.Count > 1) { - foreach(var i in range(1, connections.Count)) + foreach (var i in range(1, connections.Count)) { fields = new string[] { "", "", "", connections[i] }; print_row(fields, positions); diff --git a/src/TensorFlowNET.Core/Keras/Utils/losses_utils.cs b/src/TensorFlowNET.Core/Keras/Utils/losses_utils.cs index c0f420e7..8a1ebbc5 100644 --- a/src/TensorFlowNET.Core/Keras/Utils/losses_utils.cs +++ b/src/TensorFlowNET.Core/Keras/Utils/losses_utils.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using System; -using System.Linq; using Tensorflow.Keras.Losses; using static Tensorflow.Binding; diff --git a/src/TensorFlowNET.Core/Keras/Utils/tf_utils.cs b/src/TensorFlowNET.Core/Keras/Utils/tf_utils.cs index 01098e62..de542270 100644 --- a/src/TensorFlowNET.Core/Keras/Utils/tf_utils.cs +++ b/src/TensorFlowNET.Core/Keras/Utils/tf_utils.cs @@ -37,9 +37,9 @@ namespace Tensorflow.Keras.Utils return true; } - public static Tensor[] smart_cond(Tensor pred, + public static Tensor[] smart_cond(Tensor pred, Func true_fn = null, - Func false_fn = null, + Func false_fn = null, string name = null) { return smart_module.smart_cond(pred, diff --git a/src/TensorFlowNET.Core/Keras/defaultdict.cs b/src/TensorFlowNET.Core/Keras/defaultdict.cs index a87a38ca..9c1f2df6 100644 --- a/src/TensorFlowNET.Core/Keras/defaultdict.cs +++ b/src/TensorFlowNET.Core/Keras/defaultdict.cs @@ -23,7 +23,7 @@ namespace System.Collections.Generic get { TValue val; - if(!TryGetValue(key, out val)) + if (!TryGetValue(key, out val)) { val = default(TValue); Add(key, val); diff --git a/src/TensorFlowNET.Core/Layers/Layer.cs b/src/TensorFlowNET.Core/Layers/Layer.cs index d137a98e..9be4ff94 100644 --- a/src/TensorFlowNET.Core/Layers/Layer.cs +++ b/src/TensorFlowNET.Core/Layers/Layer.cs @@ -24,10 +24,10 @@ namespace Tensorflow.Layers public class Layer : Keras.Engine.Layer { protected Graph _graph; - + protected VariableScope _scope; protected VariableScope _current_scope; - + protected bool? _reuse; protected bool _use_resource_variables; protected bool _keras_style; @@ -102,7 +102,7 @@ namespace Tensorflow.Layers protected virtual void _add_elements_to_collection(Operation[] elements, string[] collection_list) { - foreach(var name in collection_list) + foreach (var name in collection_list) { var collection = ops.get_collection_ref(name); @@ -148,7 +148,7 @@ namespace Tensorflow.Layers existing_variables = variables.global_variables().ToArray(); } - if(dtype == TF_DataType.DtInvalid) + if (dtype == TF_DataType.DtInvalid) dtype = TF_DataType.TF_FLOAT; _set_scope(); @@ -174,8 +174,8 @@ namespace Tensorflow.Layers ); //if (init_graph != null) - //var trainable_variables = variables.trainable_variables(); - + //var trainable_variables = variables.trainable_variables(); + return variable; }); }); @@ -190,7 +190,7 @@ namespace Tensorflow.Layers { if (_scope == null) { - if(_reuse.HasValue && _reuse.Value) + if (_reuse.HasValue && _reuse.Value) { throw new NotImplementedException("_set_scope _reuse.HasValue"); /*with(tf.variable_scope(scope == null ? _base_name : scope), diff --git a/src/TensorFlowNET.Core/Operations/Activation/gen_nn_ops.activations.cs b/src/TensorFlowNET.Core/Operations/Activation/gen_nn_ops.activations.cs index 775fa9a8..df679bef 100644 --- a/src/TensorFlowNET.Core/Operations/Activation/gen_nn_ops.activations.cs +++ b/src/TensorFlowNET.Core/Operations/Activation/gen_nn_ops.activations.cs @@ -39,7 +39,8 @@ namespace Tensorflow.Operations.Activation { private readonly float _alpha; - public leakyrelu(float alpha = 0.3f) { + public leakyrelu(float alpha = 0.3f) + { _alpha = alpha; } @@ -156,7 +157,8 @@ namespace Tensorflow.Operations.Activation if (Math.Abs(_threshold) > 0.000001f) { negative_part = gen_ops.relu(-x + _threshold); - } else + } + else { negative_part = gen_ops.relu(-x + _threshold); } @@ -164,10 +166,12 @@ namespace Tensorflow.Operations.Activation if (Math.Abs(_threshold) > 0.000001f) { x = x * math_ops.cast(tf.greater(x, _threshold), TF_DataType.TF_FLOAT); - } else if (Math.Abs(_maxValue.Value - 6f) < 0.0001f) + } + else if (Math.Abs(_maxValue.Value - 6f) < 0.0001f) { x = gen_ops.relu6(x); - } else + } + else { x = gen_ops.relu(x); } diff --git a/src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs b/src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs index 444cac83..5d670779 100644 --- a/src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs +++ b/src/TensorFlowNET.Core/Operations/ControlFlows/CondContext.cs @@ -109,7 +109,7 @@ namespace Tensorflow.Operations _values.Add(result.name); _external_values[result.name] = result; } - + tf_with(ops.control_dependencies(null), ctrl => { var results = control_flow_ops._SwitchRefOrTensor(result, _pred); diff --git a/src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowContext.cs b/src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowContext.cs index e526a68f..0ee73815 100644 --- a/src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowContext.cs +++ b/src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowContext.cs @@ -18,8 +18,8 @@ using System; using System.Collections.Generic; using System.Linq; using Tensorflow.Operations.ControlFlows; -using static Tensorflow.ControlFlowContextDef; using static Tensorflow.Binding; +using static Tensorflow.ControlFlowContextDef; using util = Tensorflow.control_flow_util; namespace Tensorflow.Operations @@ -108,7 +108,7 @@ namespace Tensorflow.Operations foreach (var value in values_def.Values) _values.Add(value); var g = ops.get_default_graph(); - foreach(var value in values_def.ExternalValues) + foreach (var value in values_def.ExternalValues) { var k = ops.prepend_name_scope(value.Key, import_scope); var v = value.Value; @@ -149,7 +149,7 @@ namespace Tensorflow.Operations public void ExitResult(Tensor[] result) { - if(_outer_context != null) + if (_outer_context != null) { throw new NotImplementedException("ExitResult"); } @@ -203,13 +203,13 @@ namespace Tensorflow.Operations /// protected virtual void _AddOpInternal(Operation op) { - if(op == null) + if (op == null) { throw new NotImplementedException(""); } else { - foreach(var index in range(len(op.inputs))) + foreach (var index in range(len(op.inputs))) { var x = op.inputs[index]; var real_x = AddValue(x); @@ -260,7 +260,7 @@ namespace Tensorflow.Operations } else { - foreach(Operation x in op.control_inputs) + foreach (Operation x in op.control_inputs) { var ctxt = util.GetOutputContext(x); if (ctxt != null && ctxt.GetWhileContext() == while_ctxt) @@ -322,12 +322,12 @@ namespace Tensorflow.Operations public void __init__() { - + } public void __del__() { - + } } } diff --git a/src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowState.cs b/src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowState.cs index d04eefe2..da621999 100644 --- a/src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowState.cs +++ b/src/TensorFlowNET.Core/Operations/ControlFlows/ControlFlowState.cs @@ -15,10 +15,8 @@ ******************************************************************************/ using System; -using System.Linq; using System.Collections.Generic; using util = Tensorflow.control_flow_util; -using static Tensorflow.Binding; namespace Tensorflow.Operations.ControlFlows { @@ -78,11 +76,11 @@ namespace Tensorflow.Operations.ControlFlows public Tensor[] ProcessUnusedLoopExits(Dictionary pending_count, List to_ops_set) { var loop_exits = new List(); - foreach(var grad_state in _map.Values) + foreach (var grad_state in _map.Values) { - foreach(var y in grad_state.forward_loop_exits) + foreach (var y in grad_state.forward_loop_exits) { - if(!pending_count.ContainsKey(y.op.name)) + if (!pending_count.ContainsKey(y.op.name)) { grad_state.pending_exits_count -= 1; if (!to_ops_set.Contains(y.op)) @@ -92,7 +90,7 @@ namespace Tensorflow.Operations.ControlFlows } } - foreach(var y in grad_state.forward_context.loop_enters) + foreach (var y in grad_state.forward_context.loop_enters) { if (!pending_count.ContainsKey(y.op.name)) pending_count[y.op.name] = 1; @@ -146,7 +144,7 @@ namespace Tensorflow.Operations.ControlFlows { var forward_ctxt = op.GetWhileContext(); var grad_state = _map.ContainsKey(forward_ctxt) ? _map[forward_ctxt] : null; - if(grad_state == null) + if (grad_state == null) { GradLoopState outer_grad_state = null; var outer_forward_ctxt = forward_ctxt.outer_context; @@ -160,7 +158,7 @@ namespace Tensorflow.Operations.ControlFlows // We need to include all exits of a loop for backprop. foreach (var loop_exit in grad_state.forward_loop_exits) { - if(!between_ops.Contains(loop_exit.op)) + if (!between_ops.Contains(loop_exit.op)) { between_ops.add(loop_exit.op); between_op_list.append(loop_exit.op); @@ -290,11 +288,11 @@ namespace Tensorflow.Operations.ControlFlows public void PostProcessing() { - foreach(var grad_state in _map.Values) + foreach (var grad_state in _map.Values) { - foreach(var b_merge in grad_state.switch_map.Values) + foreach (var b_merge in grad_state.switch_map.Values) { - if(b_merge.op.inputs[0] == b_merge.op.inputs[1]) + if (b_merge.op.inputs[0] == b_merge.op.inputs[1]) { Tensor next_grad_val = null; // The value of this loop variable at iteration i+1 doesn't diff --git a/src/TensorFlowNET.Core/Operations/ControlFlows/GradLoopState.cs b/src/TensorFlowNET.Core/Operations/ControlFlows/GradLoopState.cs index 8c96761b..5b7bb919 100644 --- a/src/TensorFlowNET.Core/Operations/ControlFlows/GradLoopState.cs +++ b/src/TensorFlowNET.Core/Operations/ControlFlows/GradLoopState.cs @@ -17,7 +17,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using static Tensorflow.Binding; using util = Tensorflow.control_flow_util; @@ -83,7 +82,7 @@ namespace Tensorflow.Operations.ControlFlows { get { - if(_grad_sync == null) + if (_grad_sync == null) { tf_with(ops.control_dependencies(null), delegate { @@ -201,7 +200,7 @@ namespace Tensorflow.Operations.ControlFlows // Add the stack_push op in the context of value.op. var swap_enabled = forward_context.swap_memory; var value_ctxt = util.GetOutputContext(value.op); - if(value_ctxt == forward_context) + if (value_ctxt == forward_context) { // value is not nested in the forward context. forward_context.Enter(); @@ -238,14 +237,14 @@ namespace Tensorflow.Operations.ControlFlows // The current value (the top of the stack). // """ - public Tensor AddBackpropAccumulatedValue(Tensor history_value, Tensor value, bool dead_branch= false) + public Tensor AddBackpropAccumulatedValue(Tensor history_value, Tensor value, bool dead_branch = false) { var history_ctxt = history_value.op._get_control_flow_context(); // Find the cond context that controls history_value if any. CondContext cond_ctxt = null; Tensor pop = null; var value_ctxt = value.op._get_control_flow_context(); - while(value_ctxt != null && value_ctxt != history_ctxt) + while (value_ctxt != null && value_ctxt != history_ctxt) { if (value_ctxt is CondContext cc) cond_ctxt = cc; @@ -254,7 +253,7 @@ namespace Tensorflow.Operations.ControlFlows tf_with(ops.control_dependencies(null), delegate { grad_context.Enter(); - if(cond_ctxt != null) + if (cond_ctxt != null) { throw new NotImplementedException("AddBackpropAccumulatedValue"); } @@ -277,7 +276,7 @@ namespace Tensorflow.Operations.ControlFlows public Tensor GetRealValue(Tensor value) { Tensor real_value = null; - if(real_value == null) + if (real_value == null) { var cur_value = value; var cur_grad_state = this; @@ -285,12 +284,12 @@ namespace Tensorflow.Operations.ControlFlows while (true) { var enter_op = util.GetLoopConstantEnter(cur_value); - if(enter_op != null) + if (enter_op != null) { // Special case: cur_value comes from a constant Enter node. cur_value = enter_op.inputs[0]; cur_grad_state = cur_grad_state.outer_grad_state; - if(cur_grad_state == null) + if (cur_grad_state == null) { // We are now outside all nested loops for this gradient(), // so `value` is a loop invariant and there is no need to @@ -320,7 +319,7 @@ namespace Tensorflow.Operations.ControlFlows } } - if(real_value == null) + if (real_value == null) { // Add the stack pop op in the grad context. real_value = cur_grad_state.AddBackpropAccumulatedValue(history_value, cur_value); diff --git a/src/TensorFlowNET.Core/Operations/ControlFlows/LoopVar.cs b/src/TensorFlowNET.Core/Operations/ControlFlows/LoopVar.cs index 5359190c..7b18ee46 100644 --- a/src/TensorFlowNET.Core/Operations/ControlFlows/LoopVar.cs +++ b/src/TensorFlowNET.Core/Operations/ControlFlows/LoopVar.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; namespace Tensorflow.Operations { diff --git a/src/TensorFlowNET.Core/Operations/ControlFlows/MergeOutput.cs b/src/TensorFlowNET.Core/Operations/ControlFlows/MergeOutput.cs index 5b6ae944..55526b83 100644 --- a/src/TensorFlowNET.Core/Operations/ControlFlows/MergeOutput.cs +++ b/src/TensorFlowNET.Core/Operations/ControlFlows/MergeOutput.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Operations +namespace Tensorflow.Operations { public class MergeOutput { @@ -18,7 +14,7 @@ namespace Tensorflow.Operations { get { - switch(idx) + switch (idx) { case 0: return output; diff --git a/src/TensorFlowNET.Core/Operations/ControlFlows/WhileContext.cs b/src/TensorFlowNET.Core/Operations/ControlFlows/WhileContext.cs index 2e634a1c..8b584963 100644 --- a/src/TensorFlowNET.Core/Operations/ControlFlows/WhileContext.cs +++ b/src/TensorFlowNET.Core/Operations/ControlFlows/WhileContext.cs @@ -19,8 +19,8 @@ using System.Collections.Generic; using System.Linq; using Tensorflow.Operations.ControlFlows; using Tensorflow.Util; -using static Tensorflow.control_flow_ops; using static Tensorflow.Binding; +using static Tensorflow.control_flow_ops; namespace Tensorflow.Operations { @@ -29,8 +29,8 @@ namespace Tensorflow.Operations /// public class WhileContext : ControlFlowContext { - bool _back_prop=true; - GradLoopState _grad_state =null; + bool _back_prop = true; + GradLoopState _grad_state = null; Tensor _maximum_iterations; public Tensor maximum_iterations => _maximum_iterations; int _parallel_iterations; @@ -114,7 +114,7 @@ namespace Tensorflow.Operations /// /// Add the loop termination condition and body to the graph. /// - internal LoopVar BuildLoop(Func, Tensor> pred, + internal LoopVar BuildLoop(Func, Tensor> pred, Func, LoopVar> body, LoopVar loop_vars, TensorShape[] shape_invariants, @@ -133,7 +133,7 @@ namespace Tensorflow.Operations .ToArray(); Enter(); - var(original_body_result, exit_vars) = _BuildLoop( + var (original_body_result, exit_vars) = _BuildLoop( pred, body, original_loop_vars, loop_vars_tensors, shape_invariants); Exit(); @@ -236,7 +236,7 @@ namespace Tensorflow.Operations // Build the graph for pred. var merge_vars_with_tensor_arrays = _convert_flows_to_tensorarrays(flat_loop_vars, merge_vars); var packed_vars = new LoopVar( - (Tensor) merge_vars_with_tensor_arrays[0], + (Tensor)merge_vars_with_tensor_arrays[0], new TItem().FromMergeVars(merge_vars_with_tensor_arrays)); var pp = pred(packed_vars); var c = ops.convert_to_tensor(pp); @@ -278,12 +278,12 @@ namespace Tensorflow.Operations private void _FixControlInputsAndContext(Tensor[] enters) { var graph = ops.get_default_graph(); - foreach(var x in enters) + foreach (var x in enters) { var inp_op = x.op.inputs[0].op; var control_inputs = graph._control_dependencies_for_inputs(new[] { inp_op }); var outer_control_inputs = new List(); - foreach(Operation op in control_inputs) + foreach (Operation op in control_inputs) { // We need to keep control inputs that are in any ancestor // ControlFlowContext, and within outer WhileContext. @@ -320,7 +320,7 @@ namespace Tensorflow.Operations private void _InitializeValues(Tensor[] values) { _values = new HashSet(); - foreach(var x in values) + foreach (var x in values) _values.Add(x.name); } @@ -330,7 +330,7 @@ namespace Tensorflow.Operations { } - + Operation[] external_inputs = new Operation[0]; Operation[] control_inputs = new Operation[0]; if (op.inputs.Length == 0) @@ -421,16 +421,16 @@ namespace Tensorflow.Operations Enter(); AddName(n.name); - var enter_n = _Enter(n, - _name, - is_constant: false, - parallel_iterations: _parallel_iterations, + var enter_n = _Enter(n, + _name, + is_constant: false, + parallel_iterations: _parallel_iterations, name: "f_count"); _loop_enters.Add(enter_n); var m1 = merge(new[] { enter_n, enter_n }); var merge_n = m1[0]; - var switch_n = @switch (merge_n, _pivot); + var switch_n = @switch(merge_n, _pivot); var index = math_ops.add(switch_n[1], 1); var next_n = _NextIteration(index); @@ -471,7 +471,7 @@ namespace Tensorflow.Operations else { var value = op.inputs[0]; - if(outer_context is WhileContext wc) + if (outer_context is WhileContext wc) { // We are in a nested while loop. var forward_ctxt = grad_state.forward_context; @@ -567,7 +567,7 @@ namespace Tensorflow.Operations // before the pops of (i+1)-th execution of the same inner loop. if (outer_grad_state != null) throw new NotImplementedException("outer_grad_state"); - //outer_grad_state.grad_sync._add_control_input(final_zero.op); + //outer_grad_state.grad_sync._add_control_input(final_zero.op); ExitResult(new[] { final_zero }); Exit(); return next_count; @@ -591,7 +591,7 @@ namespace Tensorflow.Operations // use GetRealValue(), which adds the logic to save the history of // val in forward. var grad_ctxt = ops.get_default_graph()._get_control_flow_context(); - if(grad_ctxt != null) + if (grad_ctxt != null) { grad_ctxt = grad_ctxt.GetWhileContext(); if (grad_ctxt.grad_state != null) @@ -604,7 +604,7 @@ namespace Tensorflow.Operations forward_ctxt = forward_ctxt.GetWhileContext(); throw new NotImplementedException("control_flow_util.IsLoopExit"); } - if(forward_ctxt == grad_ctxt.grad_state.forward_context) + if (forward_ctxt == grad_ctxt.grad_state.forward_context) { var real_val = grad_ctxt.grad_state.GetRealValue(val); _external_values[val.name] = real_val; diff --git a/src/TensorFlowNET.Core/Operations/Distributions/DistributionEnum.cs b/src/TensorFlowNET.Core/Operations/Distributions/DistributionEnum.cs index b3a0c414..0139f033 100644 --- a/src/TensorFlowNET.Core/Operations/Distributions/DistributionEnum.cs +++ b/src/TensorFlowNET.Core/Operations/Distributions/DistributionEnum.cs @@ -2,7 +2,7 @@ { public enum DistributionEnum { - + } diff --git a/src/TensorFlowNET.Core/Operations/Distributions/distribution.py.cs b/src/TensorFlowNET.Core/Operations/Distributions/distribution.py.cs index 8f126b0c..615dc43d 100644 --- a/src/TensorFlowNET.Core/Operations/Distributions/distribution.py.cs +++ b/src/TensorFlowNET.Core/Operations/Distributions/distribution.py.cs @@ -34,13 +34,13 @@ namespace Tensorflow /// public class Distribution : _BaseDistribution { - public TF_DataType _dtype {get;set;} + public TF_DataType _dtype { get; set; } //public ReparameterizationType _reparameterization_type {get;set;} - public bool _validate_args {get;set;} - public bool _allow_nan_stats {get;set;} - public Dictionary _parameters {get;set;} - public List _graph_parents {get;set;} - public string _name {get;set;} + public bool _validate_args { get; set; } + public bool _allow_nan_stats { get; set; } + public Dictionary _parameters { get; set; } + public List _graph_parents { get; set; } + public string _name { get; set; } /// @@ -50,13 +50,13 @@ namespace Tensorflow /// Python `str` prepended to names of ops created by this function. /// log_prob: a `Tensor` of shape `sample_shape(x) + self.batch_shape` with values of type `self.dtype`. - + public Tensor log_prob(Tensor value, string name = "log_prob") { return _call_log_prob(value, name); } - private Tensor _call_log_prob (Tensor value, string name) + private Tensor _call_log_prob(Tensor value, string name) { return tf_with(ops.name_scope(name, "moments", new { value }), scope => { @@ -72,7 +72,8 @@ namespace Tensorflow { return math_ops.log(_prob(value)); #pragma warning disable CS0168 // Variable is declared but never used - } catch (Exception e2) + } + catch (Exception e2) #pragma warning restore CS0168 // Variable is declared but never used { throw new NotImplementedException(); @@ -95,7 +96,7 @@ namespace Tensorflow { return this._dtype; } - + /* /// @@ -165,10 +166,10 @@ namespace Tensorflow public void repr() { - Console.WriteLine($"" ); + Console.WriteLine($""); } - public bool eq (ReparameterizationType other) + public bool eq(ReparameterizationType other) { return this.Equals(other); } diff --git a/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs b/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs index c7483f96..e31f7909 100644 --- a/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs +++ b/src/TensorFlowNET.Core/Operations/Distributions/normal.py.cs @@ -42,7 +42,7 @@ namespace Tensorflow /// /// /// - public Normal (Tensor loc, Tensor scale, bool validate_args=false, bool allow_nan_stats=true, string name="Normal") + public Normal(Tensor loc, Tensor scale, bool validate_args = false, bool allow_nan_stats = true, string name = "Normal") { parameters.Add("name", name); parameters.Add("loc", loc); @@ -50,23 +50,23 @@ namespace Tensorflow parameters.Add("validate_args", validate_args); parameters.Add("allow_nan_stats", allow_nan_stats); - tf_with(ops.name_scope(name, "", new { loc, scale }), scope => + tf_with(ops.name_scope(name, "", new { loc, scale }), scope => { - tf_with(ops.control_dependencies(validate_args ? new Operation[] { scale.op} : new Operation[] { }), cd => - { - this._loc = array_ops.identity(loc, name); - this._scale = array_ops.identity(scale, name); - base._dtype = this._scale.dtype; + tf_with(ops.control_dependencies(validate_args ? new Operation[] { scale.op } : new Operation[] { }), cd => + { + this._loc = array_ops.identity(loc, name); + this._scale = array_ops.identity(scale, name); + base._dtype = this._scale.dtype; // base._reparameterization_type = new ReparameterizationType("FULLY_REPARAMETERIZED"); base._validate_args = validate_args; - base._allow_nan_stats = allow_nan_stats; - base._parameters = parameters; - base._graph_parents = new List(new Tensor[] { this._loc, this._scale }); - base._name = name; - }); + base._allow_nan_stats = allow_nan_stats; + base._parameters = parameters; + base._graph_parents = new List(new Tensor[] { this._loc, this._scale }); + base._name = name; + }); }); - + } /// /// Distribution parameter for the mean. @@ -102,7 +102,7 @@ namespace Tensorflow return tf.sub(log_prob, log_norm); } - private Tensor _log_unnormalized_prob (Tensor x) + private Tensor _log_unnormalized_prob(Tensor x) { return -0.5 * math_ops.square(_z(x)); } @@ -111,7 +111,7 @@ namespace Tensorflow /// /// /// - private Tensor _z (Tensor x) + private Tensor _z(Tensor x) { return tf.divide(tf.sub(x, this._loc), this._scale); } @@ -120,7 +120,7 @@ namespace Tensorflow { Tensor t1 = ops.convert_to_tensor(Math.Log(2.0 * Math.PI), TF_DataType.TF_FLOAT); Tensor t2 = tf.multiply(ops.convert_to_tensor(0.5, TF_DataType.TF_FLOAT), t1); - return tf.add(t2, math_ops.log(this._scale)); + return tf.add(t2, math_ops.log(this._scale)); } } } \ No newline at end of file diff --git a/src/TensorFlowNET.Core/Operations/Initializers/GlorotUniform.cs b/src/TensorFlowNET.Core/Operations/Initializers/GlorotUniform.cs index 8e59370a..d97d8830 100644 --- a/src/TensorFlowNET.Core/Operations/Initializers/GlorotUniform.cs +++ b/src/TensorFlowNET.Core/Operations/Initializers/GlorotUniform.cs @@ -22,10 +22,10 @@ namespace Tensorflow.Operations.Initializers string mode = "FAN_AVG", bool uniform = true, int? seed = null, - TF_DataType dtype = TF_DataType.TF_FLOAT) : base(factor: scale, - mode: mode, + TF_DataType dtype = TF_DataType.TF_FLOAT) : base(factor: scale, + mode: mode, uniform: uniform, - seed: seed, + seed: seed, dtype: dtype) { diff --git a/src/TensorFlowNET.Core/Operations/Initializers/InitializerArgs.cs b/src/TensorFlowNET.Core/Operations/Initializers/InitializerArgs.cs index 5e0227f9..10702ece 100644 --- a/src/TensorFlowNET.Core/Operations/Initializers/InitializerArgs.cs +++ b/src/TensorFlowNET.Core/Operations/Initializers/InitializerArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public class InitializerArgs { @@ -11,7 +7,7 @@ namespace Tensorflow public TF_DataType DType { get; set; } public bool? VerifyShape { get; set; } = null; - public InitializerArgs(TensorShape shape, + public InitializerArgs(TensorShape shape, TF_DataType dtype = TF_DataType.DtInvalid, bool? verify_shape = null, string name = null) diff --git a/src/TensorFlowNET.Core/Operations/Initializers/Orthogonal.cs b/src/TensorFlowNET.Core/Operations/Initializers/Orthogonal.cs index 27571671..254a7ee7 100644 --- a/src/TensorFlowNET.Core/Operations/Initializers/Orthogonal.cs +++ b/src/TensorFlowNET.Core/Operations/Initializers/Orthogonal.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow.Operations.Initializers { diff --git a/src/TensorFlowNET.Core/Operations/Initializers/RandomNormal.cs b/src/TensorFlowNET.Core/Operations/Initializers/RandomNormal.cs index 13635860..029b311b 100644 --- a/src/TensorFlowNET.Core/Operations/Initializers/RandomNormal.cs +++ b/src/TensorFlowNET.Core/Operations/Initializers/RandomNormal.cs @@ -14,10 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using System.Text; - namespace Tensorflow.Operations.Initializers { public class RandomNormal : IInitializer diff --git a/src/TensorFlowNET.Core/Operations/Initializers/RandomUniform.cs b/src/TensorFlowNET.Core/Operations/Initializers/RandomUniform.cs index 65c36611..41ddb5d7 100644 --- a/src/TensorFlowNET.Core/Operations/Initializers/RandomUniform.cs +++ b/src/TensorFlowNET.Core/Operations/Initializers/RandomUniform.cs @@ -39,10 +39,10 @@ namespace Tensorflow.Operations.Initializers if (args.DType == TF_DataType.DtInvalid) args.DType = dtype; - return random_ops.random_uniform(args.Shape, - minval: minval, - maxval: maxval, - dtype: dtype, + return random_ops.random_uniform(args.Shape, + minval: minval, + maxval: maxval, + dtype: dtype, seed: seed); } } diff --git a/src/TensorFlowNET.Core/Operations/Initializers/VarianceScaling.cs b/src/TensorFlowNET.Core/Operations/Initializers/VarianceScaling.cs index 12d6cb68..d313f4c9 100644 --- a/src/TensorFlowNET.Core/Operations/Initializers/VarianceScaling.cs +++ b/src/TensorFlowNET.Core/Operations/Initializers/VarianceScaling.cs @@ -16,7 +16,6 @@ using System; using System.Linq; -using static Tensorflow.Binding; namespace Tensorflow.Operations.Initializers { @@ -64,10 +63,10 @@ namespace Tensorflow.Operations.Initializers n = fan_in; else if (_mode == "FAN_OUT") n = fan_out; - else if(_mode == "FAN_AVG") + else if (_mode == "FAN_AVG") n = (fan_in + fan_out) / 2.0f; - if(_uniform) + if (_uniform) { var limit = Convert.ToSingle(Math.Sqrt(3.0f * _scale / n)); return random_ops.random_uniform(args.Shape, -limit, limit, args.DType); diff --git a/src/TensorFlowNET.Core/Operations/Losses/losses_impl.py.cs b/src/TensorFlowNET.Core/Operations/Losses/losses_impl.py.cs index f4770792..facb0aac 100644 --- a/src/TensorFlowNET.Core/Operations/Losses/losses_impl.py.cs +++ b/src/TensorFlowNET.Core/Operations/Losses/losses_impl.py.cs @@ -100,11 +100,11 @@ namespace Tensorflow }); } - public Tensor sparse_softmax_cross_entropy(Tensor labels, + public Tensor sparse_softmax_cross_entropy(Tensor labels, Tensor logits, float weights = 1.0f, string scope = null, - string loss_collection= "losses", + string loss_collection = "losses", string reduction = Reduction.SUM_BY_NONZERO_WEIGHTS) { return tf_with(ops.name_scope(scope, @@ -132,7 +132,7 @@ namespace Tensorflow (labels, predictions) = confusion_matrix.remove_squeezable_dimensions( labels, predictions, expected_rank_diff: expected_rank_diff); - if(weights > 0) + if (weights > 0) { var weights_tensor = ops.convert_to_tensor(weights); var labels_rank = labels.TensorShape.ndim; diff --git a/src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs b/src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs index ca4a7df2..a9c43eb0 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/BasicLSTMCell.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static Tensorflow.Binding; -using Tensorflow.Operations.Activation; using Tensorflow.Keras.Engine; using Tensorflow.Operations; +using Tensorflow.Operations.Activation; +using static Tensorflow.Binding; namespace Tensorflow { @@ -80,7 +77,7 @@ namespace Tensorflow // Parameters of gates are concatenated into one multiply for efficiency. Tensor c = null; Tensor h = null; - if(_state_is_tuple) + if (_state_is_tuple) (c, h) = ((Tensor)_state.c, (Tensor)_state.h); else { diff --git a/src/TensorFlowNET.Core/Operations/NnOps/BasicRNNCell.cs b/src/TensorFlowNET.Core/Operations/NnOps/BasicRNNCell.cs index 987f84c5..34867de4 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/BasicRNNCell.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/BasicRNNCell.cs @@ -16,7 +16,6 @@ using System; using Tensorflow.Keras.Engine; -using Tensorflow.Operations; using static Tensorflow.Binding; namespace Tensorflow @@ -37,8 +36,8 @@ namespace Tensorflow Func activation = null, bool? reuse = null, string name = null, - TF_DataType dtype = TF_DataType.DtInvalid) : base(_reuse: reuse, - name: name, + TF_DataType dtype = TF_DataType.DtInvalid) : base(_reuse: reuse, + name: name, dtype: dtype) { // Inputs must be 2-dimensional. diff --git a/src/TensorFlowNET.Core/Operations/NnOps/BodyItemInRnnWhileLoop.cs b/src/TensorFlowNET.Core/Operations/NnOps/BodyItemInRnnWhileLoop.cs index 3d055cb1..d8cc0c25 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/BodyItemInRnnWhileLoop.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/BodyItemInRnnWhileLoop.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Tensorflow.Operations { @@ -52,8 +50,8 @@ namespace Tensorflow.Operations public BodyItemInRnnWhileLoop FromMergeVars(ITensorOrTensorArray[] mergeVars) { - time = (Tensor) mergeVars[1]; - output_ta_t = new[] {(TensorArray) mergeVars[2]}; + time = (Tensor)mergeVars[1]; + output_ta_t = new[] { (TensorArray)mergeVars[2] }; state = (Tensor)mergeVars[3]; return this; } diff --git a/src/TensorFlowNET.Core/Operations/NnOps/ConvolutionInternal.cs b/src/TensorFlowNET.Core/Operations/NnOps/ConvolutionInternal.cs index c25f7da3..487b2612 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/ConvolutionInternal.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/ConvolutionInternal.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Xml; using Tensorflow.Keras.ArgsDefinition; using static Tensorflow.Binding; @@ -26,7 +25,7 @@ namespace Tensorflow.Operations internal class ConvolutionInternal { ConvolutionalArgs args; - + string data_format => args.DataFormat; string name; string padding => args.Padding; diff --git a/src/TensorFlowNET.Core/Operations/NnOps/FusedBatchNormParams.cs b/src/TensorFlowNET.Core/Operations/NnOps/FusedBatchNormParams.cs index 689fa5fe..5826ad8b 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/FusedBatchNormParams.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/FusedBatchNormParams.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Operations +namespace Tensorflow.Operations { public class FusedBatchNormParams { diff --git a/src/TensorFlowNET.Core/Operations/NnOps/LSTMStateTuple.cs b/src/TensorFlowNET.Core/Operations/NnOps/LSTMStateTuple.cs index f6bf5c6e..a8623366 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/LSTMStateTuple.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/LSTMStateTuple.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Operations +namespace Tensorflow.Operations { /// /// Tuple used by LSTM Cells for `state_size`, `zero_state`, and output state. diff --git a/src/TensorFlowNET.Core/Operations/NnOps/MaxPoolFunction.cs b/src/TensorFlowNET.Core/Operations/NnOps/MaxPoolFunction.cs index e28557c7..92bd95a5 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/MaxPoolFunction.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/MaxPoolFunction.cs @@ -30,7 +30,7 @@ namespace Tensorflow.Operations string data_format = "NHWC", string name = null) { - return tf_with(ops.name_scope(name, "MaxPool", value), scope => + return tf_with(ops.name_scope(name, "MaxPool", value), scope => { name = scope; value = ops.convert_to_tensor(value, name: "input"); diff --git a/src/TensorFlowNET.Core/Operations/NnOps/RNNCell.cs b/src/TensorFlowNET.Core/Operations/NnOps/RNNCell.cs index 61d97cb9..b04dc152 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/RNNCell.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/RNNCell.cs @@ -56,8 +56,8 @@ namespace Tensorflow public RnnCell(bool trainable = true, string name = null, TF_DataType dtype = TF_DataType.DtInvalid, - bool? _reuse = null) : base(trainable: trainable, - name: name, + bool? _reuse = null) : base(trainable: trainable, + name: name, dtype: dtype, _reuse: _reuse) { @@ -91,7 +91,7 @@ namespace Tensorflow private Tensor _zero_state_tensors(object state_size, Tensor batch_size, TF_DataType dtype) { - if(state_size is int state_size_int) + if (state_size is int state_size_int) { var output = nest.map_structure(s => { diff --git a/src/TensorFlowNET.Core/Operations/NnOps/gen_nn_ops.cs b/src/TensorFlowNET.Core/Operations/NnOps/gen_nn_ops.cs index 41cd88b8..c110eb22 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/gen_nn_ops.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/gen_nn_ops.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using System.Linq; using static Tensorflow.Binding; @@ -49,9 +48,9 @@ namespace Tensorflow.Operations null, parameters.Input, parameters.Filter, "strides", parameters.Strides, - "use_cudnn_on_gpu", parameters.UseCudnnOnGpu, + "use_cudnn_on_gpu", parameters.UseCudnnOnGpu, "padding", parameters.Padding, - "explicit_paddings", parameters.ExplicitPaddings, + "explicit_paddings", parameters.ExplicitPaddings, "data_format", parameters.DataFormat, "dilations", parameters.Dilations); @@ -127,10 +126,10 @@ namespace Tensorflow.Operations /// /// /// - public static Tensor conv2d_backprop_input(Tensor input_sizes, Tensor filter, Tensor out_backprop, - int[] strides, string padding, bool use_cudnn_on_gpu = true, - int[] explicit_paddings = null, - string data_format= "NHWC", + public static Tensor conv2d_backprop_input(Tensor input_sizes, Tensor filter, Tensor out_backprop, + int[] strides, string padding, bool use_cudnn_on_gpu = true, + int[] explicit_paddings = null, + string data_format = "NHWC", int[] dilations = null, string name = null) { @@ -145,10 +144,10 @@ namespace Tensorflow.Operations "Conv2DBackpropInput", name, null, input_sizes, filter, out_backprop, - "strides", strides, - "use_cudnn_on_gpu", use_cudnn_on_gpu, + "strides", strides, + "use_cudnn_on_gpu", use_cudnn_on_gpu, "padding", padding, - "explicit_paddings", explicit_paddings, + "explicit_paddings", explicit_paddings, "data_format", data_format, "dilations", dilations); @@ -411,7 +410,8 @@ namespace Tensorflow.Operations public static Tensor leaky_relu(Tensor features, float alpha = 0.2f, string name = null) => tf.Context.RunInAutoMode(() => tf.OpDefLib._apply_op_helper("LeakyRelu", name: name, - args: new { + args: new + { features, alpha }).output, () @@ -435,9 +435,9 @@ namespace Tensorflow.Operations "MaxPool", name, null, input, - "ksize", ksize, + "ksize", ksize, "strides", strides, - "padding", padding, + "padding", padding, "data_format", data_format); return results[0]; @@ -455,8 +455,8 @@ namespace Tensorflow.Operations return _op.outputs[0]; } - public static Tensor max_pool_grad(Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, - string data_format= "NHWC", string name= null) + public static Tensor max_pool_grad(Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, + string data_format = "NHWC", string name = null) { if (tf.executing_eagerly()) { @@ -465,8 +465,8 @@ namespace Tensorflow.Operations null, orig_input, orig_output, grad, "ksize", ksize, - "strides", strides, - "padding", padding, + "strides", strides, + "padding", padding, "data_format", data_format); return results[0]; @@ -626,7 +626,7 @@ namespace Tensorflow.Operations if (tf.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Relu", name, + "Relu", name, null, features); @@ -642,7 +642,7 @@ namespace Tensorflow.Operations if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Tanh", name, + "Tanh", name, null, x); diff --git a/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs b/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs index 842cc33e..bd9513e2 100644 --- a/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs +++ b/src/TensorFlowNET.Core/Operations/NnOps/rnn.cs @@ -29,7 +29,7 @@ namespace Tensorflow.Operations /// /// Creates a bidirectional recurrent neural network. /// - public static (Tensor[], LSTMStateTuple, LSTMStateTuple) static_bidirectional_rnn(BasicLstmCell cell_fw, + public static (Tensor[], LSTMStateTuple, LSTMStateTuple) static_bidirectional_rnn(BasicLstmCell cell_fw, BasicLstmCell cell_bw, Tensor[] inputs, Tensor initial_state_fw = null, @@ -173,7 +173,7 @@ namespace Tensorflow.Operations } public static (Tensor, Tensor) dynamic_rnn(RnnCell cell, Tensor inputs_tensor, - Tensor sequence_length = null, Tensor initial_state = null, + Tensor sequence_length = null, Tensor initial_state = null, TF_DataType dtype = TF_DataType.DtInvalid, int? parallel_iterations = null, bool swap_memory = false, bool time_major = false) { @@ -248,7 +248,7 @@ namespace Tensorflow.Operations var dims = inputs_got_shape[0].dims.Take(2).ToArray(); var (const_time_steps, const_batch_size) = (dims[0], dims[1]); - foreach(var shape in inputs_got_shape) + foreach (var shape in inputs_got_shape) { if (shape.dims[2] == -1) throw new ValueError("Input size (depth of inputs) must be accessible via shape inference," + @@ -374,7 +374,7 @@ namespace Tensorflow.Operations output_ta_t = zip(output_ta_t, outputs).Select(x => { - var(ta, @out) = (x.Item1, x.Item2); + var (ta, @out) = (x.Item1, x.Item2); return ta.write(item.time, @out); }).ToArray(); @@ -453,7 +453,7 @@ namespace Tensorflow.Operations /// private static Tensor _best_effort_input_batch_size(List flat_input) { - foreach(var input_ in flat_input) + foreach (var input_ in flat_input) { var shape = input_.TensorShape; if (shape.ndim < 0) @@ -464,7 +464,7 @@ namespace Tensorflow.Operations var batch_size = shape.dims[1]; if (batch_size > -1) throw new ValueError("_best_effort_input_batch_size batch_size > -1"); - //return batch_size; + //return batch_size; } return array_ops.shape(flat_input[0]).slice(1); diff --git a/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs b/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs index 5ab4457b..c350ec7a 100644 --- a/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs +++ b/src/TensorFlowNET.Core/Operations/OpDefLibrary.cs @@ -14,12 +14,12 @@ limitations under the License. ******************************************************************************/ +using Google.Protobuf; using System; using System.Collections.Generic; using System.Linq; -using static Tensorflow.OpDef.Types; using static Tensorflow.Binding; -using Google.Protobuf; +using static Tensorflow.OpDef.Types; namespace Tensorflow { @@ -70,7 +70,7 @@ namespace Tensorflow foreach (var input_arg in op_def.InputArg) { var input_name = input_arg.Name; - + if (keywords.ContainsKey(input_name)) values = keywords[input_name]; else if (keywords.ContainsKey(input_name + "_")) @@ -80,7 +80,7 @@ namespace Tensorflow } else throw new TypeError("No argument for input " + input_name); - + // Goals: // * Convert values to Tensors if it contains constants. // * Verify that values is a list if that matches the input_arg's @@ -100,7 +100,7 @@ namespace Tensorflow { if (!_IsListValue(values)) throw new TypeError($"Expected list for '{input_name}' argument to '{op_type_name}' Op, not {values}."); - if(input_arg.Type != DataType.DtInvalid) + if (input_arg.Type != DataType.DtInvalid) dtype = input_arg.Type; else if (!String.IsNullOrEmpty(input_arg.NumberAttr)) { @@ -113,8 +113,8 @@ namespace Tensorflow dtype = values1[0].dtype.as_datatype_enum(); break; case object[] values1: - foreach(var t in values1) - if(t is Tensor tensor) + foreach (var t in values1) + if (t is Tensor tensor) { dtype = tensor.dtype.as_datatype_enum(); break; @@ -128,13 +128,13 @@ namespace Tensorflow default_dtype = (DataType)default_type_attr_map[input_arg.TypeAttr]; } - if(!input_arg.IsRef && dtype != DataType.DtInvalid) + if (!input_arg.IsRef && dtype != DataType.DtInvalid) dtype = dtype.as_base_dtype(); - values = ops.internal_convert_n_to_tensor(values, - name: input_arg.Name, - dtype: dtype.as_tf_dtype(), - preferred_dtype: default_dtype.as_tf_dtype(), + values = ops.internal_convert_n_to_tensor(values, + name: input_arg.Name, + dtype: dtype.as_tf_dtype(), + preferred_dtype: default_dtype.as_tf_dtype(), as_ref: input_arg.IsRef); } else @@ -148,14 +148,14 @@ namespace Tensorflow else if (default_type_attr_map.ContainsKey(input_arg.TypeAttr)) default_dtype = (DataType)default_type_attr_map[input_arg.TypeAttr]; - var value = ops.internal_convert_to_tensor(values, - name: input_name, + var value = ops.internal_convert_to_tensor(values, + name: input_name, dtype: dtype.as_tf_dtype(), as_ref: input_arg.IsRef, preferred_dtype: default_dtype.as_tf_dtype()); //if (!String.IsNullOrEmpty(input_arg.TypeAttr)) - //attrs[input_arg.TypeAttr] = values.dtype; + //attrs[input_arg.TypeAttr] = values.dtype; values = new Tensor[] { value }; } @@ -168,8 +168,8 @@ namespace Tensorflow } else throw new NotImplementedException("_IsListParameter"); - SetAttrs(op_type_name, - input_arg, + SetAttrs(op_type_name, + input_arg, op_def, attrs, inferred_from, @@ -239,8 +239,8 @@ namespace Tensorflow _MaybeColocateWith(must_colocate_inputs); // Add Op to graph - var op = g.create_op(op_type_name, - inputs.ToArray(), + var op = g.create_op(op_type_name, + inputs.ToArray(), output_types.ToArray(), name: _scope_name, input_types: input_types.ToArray(), @@ -256,10 +256,10 @@ namespace Tensorflow } - private void SetAttrs(string op_type_name, - ArgDef input_arg, - OpDef op_def, - Dictionary attrs, + private void SetAttrs(string op_type_name, + ArgDef input_arg, + OpDef op_def, + Dictionary attrs, Dictionary inferred_from, List types, List base_types, @@ -386,9 +386,9 @@ namespace Tensorflow if (value == null && attr_def.DefaultValue != null) attr_value.Shape = attr_def.DefaultValue.Shape; - if(value is TensorShape val1) + if (value is TensorShape val1) attr_value.Shape = val1.as_proto(); - else if(value is long[] val2) + else if (value is long[] val2) attr_value.Shape = tensor_util.as_shape(val2); else if (value is int[] val3) attr_value.Shape = tensor_util.as_shape(val3); diff --git a/src/TensorFlowNET.Core/Operations/Operation.Control.cs b/src/TensorFlowNET.Core/Operations/Operation.Control.cs index e2e83fa8..5c10f59e 100644 --- a/src/TensorFlowNET.Core/Operations/Operation.Control.cs +++ b/src/TensorFlowNET.Core/Operations/Operation.Control.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using Tensorflow.Operations; -using static Tensorflow.Binding; namespace Tensorflow { @@ -31,7 +30,7 @@ namespace Tensorflow /// public void _control_flow_post_processing() { - foreach(Tensor input_tensor in inputs) + foreach (Tensor input_tensor in inputs) control_flow_util.CheckInputFromValidContext(this, input_tensor.op); if (_control_flow_context != null) diff --git a/src/TensorFlowNET.Core/Operations/Operation.Implicit.cs b/src/TensorFlowNET.Core/Operations/Operation.Implicit.cs index 289c69ad..5ac0cff5 100644 --- a/src/TensorFlowNET.Core/Operations/Operation.Implicit.cs +++ b/src/TensorFlowNET.Core/Operations/Operation.Implicit.cs @@ -24,14 +24,14 @@ namespace Tensorflow public partial class Operation { // make sure the new op is in the same graph instance - public static implicit operator Operation(IntPtr handle) + public static implicit operator Operation(IntPtr handle) => new Operation(handle); - public static implicit operator IntPtr(Operation op) + public static implicit operator IntPtr(Operation op) => op._handle; - public static implicit operator Tensor(Operation op) + public static implicit operator Tensor(Operation op) => op.output; - public static implicit operator RefVariable(Operation op) + public static implicit operator RefVariable(Operation op) => new RefVariable(op); public override string ToString() diff --git a/src/TensorFlowNET.Core/Operations/Operation.Instance.cs b/src/TensorFlowNET.Core/Operations/Operation.Instance.cs index b99e29b1..e6e59fe1 100644 --- a/src/TensorFlowNET.Core/Operations/Operation.Instance.cs +++ b/src/TensorFlowNET.Core/Operations/Operation.Instance.cs @@ -15,8 +15,6 @@ ******************************************************************************/ using System; -using System.Linq; -using System.Collections.Generic; using static Tensorflow.Binding; namespace Tensorflow @@ -31,7 +29,7 @@ namespace Tensorflow public Operation GetOperation(IntPtr handle) { var nodes = tf.get_default_graph()._nodes_by_name; - foreach(var node in nodes.Values) + foreach (var node in nodes.Values) { if (node is Operation op) { diff --git a/src/TensorFlowNET.Core/Operations/Operation.Output.cs b/src/TensorFlowNET.Core/Operations/Operation.Output.cs index 0235cafc..921403ee 100644 --- a/src/TensorFlowNET.Core/Operations/Operation.Output.cs +++ b/src/TensorFlowNET.Core/Operations/Operation.Output.cs @@ -63,7 +63,7 @@ namespace Tensorflow var handle = Marshal.AllocHGlobal(Marshal.SizeOf()); int num = c_api.TF_OperationOutputConsumers(new TF_Output(_handle, index), handle, max_consumers); var consumers = new TF_Input[num]; - var inputptr = (TF_Input*) handle; + var inputptr = (TF_Input*)handle; for (int i = 0; i < num; i++) consumers[i] = *(inputptr + i); diff --git a/src/TensorFlowNET.Core/Operations/Operation.cs b/src/TensorFlowNET.Core/Operations/Operation.cs index 17cd2c58..e6f6d346 100644 --- a/src/TensorFlowNET.Core/Operations/Operation.cs +++ b/src/TensorFlowNET.Core/Operations/Operation.cs @@ -14,11 +14,9 @@ limitations under the License. ******************************************************************************/ -using Google.Protobuf.Collections; using NumSharp; using System; using System.Collections.Generic; -using System.IO; using System.Linq; using Tensorflow.Util; using static Tensorflow.Binding; @@ -88,7 +86,7 @@ namespace Tensorflow _outputs = new Tensor[NumOutputs]; for (int i = 0; i < NumOutputs; i++) _outputs[i] = new Tensor(this, i, OutputType(i)); - + // Dict mapping op name to file and line information for op colocation // context managers. _control_flow_context = _graph._get_control_flow_context(); diff --git a/src/TensorFlowNET.Core/Operations/Queues/FIFOQueue.cs b/src/TensorFlowNET.Core/Operations/Queues/FIFOQueue.cs index b4d2e638..4d594fc0 100644 --- a/src/TensorFlowNET.Core/Operations/Queues/FIFOQueue.cs +++ b/src/TensorFlowNET.Core/Operations/Queues/FIFOQueue.cs @@ -14,10 +14,7 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; namespace Tensorflow.Queues { diff --git a/src/TensorFlowNET.Core/Operations/Queues/PaddingFIFOQueue.cs b/src/TensorFlowNET.Core/Operations/Queues/PaddingFIFOQueue.cs index d8b93ff2..a6c92a41 100644 --- a/src/TensorFlowNET.Core/Operations/Queues/PaddingFIFOQueue.cs +++ b/src/TensorFlowNET.Core/Operations/Queues/PaddingFIFOQueue.cs @@ -14,12 +14,7 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using Tensorflow.Framework; -using static Tensorflow.Binding; namespace Tensorflow.Queues { @@ -28,9 +23,9 @@ namespace Tensorflow.Queues /// public class PaddingFIFOQueue : QueueBase { - public PaddingFIFOQueue(int capacity, - TF_DataType[] dtypes, - TensorShape[] shapes, + public PaddingFIFOQueue(int capacity, + TF_DataType[] dtypes, + TensorShape[] shapes, string[] names = null, string shared_name = null, string name = "padding_fifo_queue") diff --git a/src/TensorFlowNET.Core/Operations/Queues/PriorityQueue.cs b/src/TensorFlowNET.Core/Operations/Queues/PriorityQueue.cs index c2a2b70d..421b90b5 100644 --- a/src/TensorFlowNET.Core/Operations/Queues/PriorityQueue.cs +++ b/src/TensorFlowNET.Core/Operations/Queues/PriorityQueue.cs @@ -14,10 +14,8 @@ limitations under the License. ******************************************************************************/ -using System; using System.Collections.Generic; using System.Linq; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow.Queues @@ -54,7 +52,7 @@ namespace Tensorflow.Queues { return tf_with(ops.name_scope(name, $"{_name}_EnqueueMany", vals), scope => { - var vals_tensor1 = _check_enqueue_dtypes(indexes); + var vals_tensor1 = _check_enqueue_dtypes(indexes); var vals_tensor2 = _check_enqueue_dtypes(vals); var tensors = new List(); diff --git a/src/TensorFlowNET.Core/Operations/Queues/QueueBase.cs b/src/TensorFlowNET.Core/Operations/Queues/QueueBase.cs index b420d2c9..727cbf95 100644 --- a/src/TensorFlowNET.Core/Operations/Queues/QueueBase.cs +++ b/src/TensorFlowNET.Core/Operations/Queues/QueueBase.cs @@ -16,8 +16,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow.Queues diff --git a/src/TensorFlowNET.Core/Operations/Queues/RandomShuffleQueue.cs b/src/TensorFlowNET.Core/Operations/Queues/RandomShuffleQueue.cs index 6846f478..fcbf2c88 100644 --- a/src/TensorFlowNET.Core/Operations/Queues/RandomShuffleQueue.cs +++ b/src/TensorFlowNET.Core/Operations/Queues/RandomShuffleQueue.cs @@ -14,10 +14,7 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; namespace Tensorflow.Queues { @@ -36,7 +33,7 @@ namespace Tensorflow.Queues string name = "random_shuffle_queue") : base(dtypes: dtypes, shapes: shapes, names: names) { - var(seed1, seed2) = random_seed.get_seed(seed); + var (seed1, seed2) = random_seed.get_seed(seed); if (!seed1.HasValue && !seed2.HasValue) (seed1, seed2) = (0, 0); diff --git a/src/TensorFlowNET.Core/Operations/_GraphTensorArray.cs b/src/TensorFlowNET.Core/Operations/_GraphTensorArray.cs index ea701afc..19443db9 100644 --- a/src/TensorFlowNET.Core/Operations/_GraphTensorArray.cs +++ b/src/TensorFlowNET.Core/Operations/_GraphTensorArray.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow.Operations @@ -47,8 +46,8 @@ namespace Tensorflow.Operations internal Tensor _flow; public _GraphTensorArray(TF_DataType dtype, Tensor size, bool? dynamic_size = null, - bool? clear_after_read = null, string tensor_array_name = null, Tensor handle = null, Tensor flow = null, - bool infer_shape = true, TensorShape element_shape = null, + bool? clear_after_read = null, string tensor_array_name = null, Tensor handle = null, Tensor flow = null, + bool infer_shape = true, TensorShape element_shape = null, bool colocate_with_first_write_call = true, string name = null) { clear_after_read = clear_after_read ?? true; @@ -64,7 +63,7 @@ namespace Tensorflow.Operations // shape is defined either by `element_shape` or the shape of the tensor // of the first write. If `infer_shape` is true, all writes checks for // shape equality. - if(element_shape == null) + if (element_shape == null) { _infer_shape = infer_shape; _element_shape = new List { }; @@ -77,7 +76,7 @@ namespace Tensorflow.Operations tf_with(ops.name_scope(name, "TensorArray", new { handle, size, flow }), scope => { - if(handle != null) + if (handle != null) { _handle = handle; _flow = flow; @@ -138,13 +137,13 @@ namespace Tensorflow.Operations name: name); var ta = new TensorArray(_dtype, - infer_shape:_infer_shape, + infer_shape: _infer_shape, element_shape: _element_shape[0], dynamic_size: _dynamic_size, handle: _handle, flow: flow_out, colocate_with_first_write_call: _colocate_with_first_write_call); - + return ta; }); @@ -222,7 +221,7 @@ namespace Tensorflow.Operations element_shape: element_shape); //if (element_shape != null) - //value.set_shape(-1, element_shape.dims); + //value.set_shape(-1, element_shape.dims); return value; } diff --git a/src/TensorFlowNET.Core/Operations/_UserDeviceSpec.cs b/src/TensorFlowNET.Core/Operations/_UserDeviceSpec.cs index 5e0edad5..0ffead37 100644 --- a/src/TensorFlowNET.Core/Operations/_UserDeviceSpec.cs +++ b/src/TensorFlowNET.Core/Operations/_UserDeviceSpec.cs @@ -48,7 +48,7 @@ namespace Tensorflow if (variable == null) return ""; - if(!IsFunction) + if (!IsFunction) { return variable.ToString(); } @@ -70,7 +70,7 @@ namespace Tensorflow public _UserDeviceSpec(StringOrFunction device_name_or_function) { - + _device_name_or_function = device_name_or_function; display_name = device_name_or_function.ToString(); } diff --git a/src/TensorFlowNET.Core/Operations/array_ops.cs b/src/TensorFlowNET.Core/Operations/array_ops.cs index 5ef191da..ece3baf8 100644 --- a/src/TensorFlowNET.Core/Operations/array_ops.cs +++ b/src/TensorFlowNET.Core/Operations/array_ops.cs @@ -18,9 +18,7 @@ using NumSharp; using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Tensorflow.Contexts; -using Tensorflow.Eager; using Tensorflow.Framework; using static Tensorflow.Binding; @@ -28,7 +26,7 @@ namespace Tensorflow { public class array_ops { - public static Tensor placeholder_with_default(T input, int[] shape, string name = null) + public static Tensor placeholder_with_default(T input, int[] shape, string name = null) => gen_array_ops.placeholder_with_default(input, shape, name); /// @@ -64,7 +62,7 @@ namespace Tensorflow var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, "PreventGradient", name, null, - input, + input, "message", message); return results[0]; } @@ -134,7 +132,7 @@ namespace Tensorflow } }); } - } + } public static Tensor boolean_mask(T1 tensor, T2 mask, string name = "boolean_mask", int axis = 0) { @@ -193,7 +191,7 @@ namespace Tensorflow default: throw new TypeError("can't find type for zeros"); } - + }); } @@ -230,7 +228,7 @@ namespace Tensorflow { TF_DataType dtype = TF_DataType.DtInvalid; - foreach(var obj in list_or_tuple) + foreach (var obj in list_or_tuple) { switch (obj) { @@ -265,7 +263,7 @@ namespace Tensorflow must_pack = true; } - if(must_pack) + if (must_pack) { var elems_as_tensors = new List(); foreach (var (i, elem) in enumerate(converted_elems)) @@ -288,10 +286,10 @@ namespace Tensorflow }); } - public static Tensor expand_dims(Tensor input, int axis = -1, string name = null, int dim = -1) + public static Tensor expand_dims(Tensor input, int axis = -1, string name = null, int dim = -1) => expand_dims_v2(input, axis, name); - private static Tensor expand_dims_v2(Tensor input, int axis, string name = null) + private static Tensor expand_dims_v2(Tensor input, int axis, string name = null) => gen_array_ops.expand_dims(input, axis, name); /// @@ -400,7 +398,7 @@ namespace Tensorflow { dtype = dtype.as_base_dtype(); name = scope; - + Tensor ones = null; switch (dtype) { @@ -417,12 +415,12 @@ namespace Tensorflow if (shape.ndim == 0) return ones; - + var shape_tensor = constant_op._tensor_shape_tensor_conversion_function(shape); return fill(shape_tensor, ones, name: name); }); - public static Tensor one_hot(Tensor indices, Tensor depth, + public static Tensor one_hot(Tensor indices, Tensor depth, Tensor on_value = null, Tensor off_value = null, TF_DataType dtype = TF_DataType.DtInvalid, @@ -440,7 +438,7 @@ namespace Tensorflow if (dtype == TF_DataType.DtInvalid) dtype = TF_DataType.TF_FLOAT; - if(!on_exists) + if (!on_exists) { on_value = ops.convert_to_tensor(1, dtype, name: "on_value"); on_dtype = dtype; @@ -477,7 +475,7 @@ namespace Tensorflow public static Tensor[] unstack(Tensor value, int? num = null, int axis = 0, string name = "unstack") { - if(num == null) + if (num == null) { value = ops.convert_to_tensor(value); var value_shape = value.TensorShape; @@ -489,7 +487,7 @@ namespace Tensorflow public static Tensor where(Tensor condition, object x = null, object y = null, string name = null) { - if( x == null && y == null) + if (x == null && y == null) { return tf_with(ops.name_scope(name, "Where", new { condition }), scope => { @@ -498,7 +496,7 @@ namespace Tensorflow return gen_array_ops.where(condition: condition, name: name); }); } - else if(x != null && y != null) + else if (x != null && y != null) { return gen_array_ops.select(condition, x, y, name); } @@ -567,7 +565,7 @@ namespace Tensorflow return gen_array_ops.size(input, name: name, out_type: out_type); }); } - + public static Tensor tile(Tensor input, Tensor multiples, string name = null) { throw new NotImplementedException("tile"); @@ -586,7 +584,7 @@ namespace Tensorflow } - if(dtype != TF_DataType.DtInvalid && dtype != tensor.dtype && dtype != TF_DataType.TF_VARIANT) + if (dtype != TF_DataType.DtInvalid && dtype != tensor.dtype && dtype != TF_DataType.TF_VARIANT) { throw new NotImplementedException("zeros_like"); // return zeros(shape_internal(tensor, optimize: optimize), dtype: dtype, name: name); @@ -610,7 +608,7 @@ namespace Tensorflow /// /// public static Tensor stop_gradient(Tensor input, string name = null) - => gen_array_ops.stop_gradient(input, name); + => gen_array_ops.stop_gradient(input, name); /// /// Extracts a strided slice of a tensor (generalized python array indexing). @@ -626,7 +624,7 @@ namespace Tensorflow /// /// /// - public static Tensor strided_slice(Tensor input_, Tensor begin, Tensor end, + public static Tensor strided_slice(Tensor input_, Tensor begin, Tensor end, Tensor strides = null, int begin_mask = 0, int end_mask = 0, @@ -747,9 +745,10 @@ namespace Tensorflow /// public static Tensor concat(Tensor[] values, int axis, string name = "concat") { - if(values.Length == 1) // Degenerate case of one tensor. + if (values.Length == 1) // Degenerate case of one tensor. { - return tf_with(ops.name_scope(name), scope => { + return tf_with(ops.name_scope(name), scope => + { var t = ops.convert_to_tensor(axis, name: "concat_dim", dtype: TF_DataType.TF_INT32); return identity(values[0], name: scope); }); @@ -788,7 +787,7 @@ namespace Tensorflow }); } - public static Tensor[] split(Tensor value, int num_split, T axis, + public static Tensor[] split(Tensor value, int num_split, T axis, string name = "split") { var size_splits = ops.convert_to_tensor(num_split); @@ -829,7 +828,7 @@ namespace Tensorflow { Tensor result = null; mode = mode.ToUpper(); - if(mode == "CONSTANT") + if (mode == "CONSTANT") { if (constant_values != 0) throw new NotImplementedException("gen_array_ops.pad_v2"); diff --git a/src/TensorFlowNET.Core/Operations/bitwise_ops.cs b/src/TensorFlowNET.Core/Operations/bitwise_ops.cs index 61b9e330..4b4e0f5e 100644 --- a/src/TensorFlowNET.Core/Operations/bitwise_ops.cs +++ b/src/TensorFlowNET.Core/Operations/bitwise_ops.cs @@ -14,9 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow.Operations diff --git a/src/TensorFlowNET.Core/Operations/check_ops.cs b/src/TensorFlowNET.Core/Operations/check_ops.cs index 6312aa9e..3c4aa535 100644 --- a/src/TensorFlowNET.Core/Operations/check_ops.cs +++ b/src/TensorFlowNET.Core/Operations/check_ops.cs @@ -56,35 +56,35 @@ namespace Tensorflow return control_flow_ops.Assert(condition, data); }); } - + public static Operation assert_greater_equal(Tensor x, Tensor y, object[] data = null, string message = null, string name = null) { if (message == null) message = ""; - return tf_with(ops.name_scope(name, "assert_greater_equal", new {x, y, data}), delegate - { - x = ops.convert_to_tensor(x, name: "x"); - y = ops.convert_to_tensor(y, name: "y"); - string x_name = x.name; - string y_name = y.name; - if (data == null) - { - data = new object[] - { + return tf_with(ops.name_scope(name, "assert_greater_equal", new { x, y, data }), delegate + { + x = ops.convert_to_tensor(x, name: "x"); + y = ops.convert_to_tensor(y, name: "y"); + string x_name = x.name; + string y_name = y.name; + if (data == null) + { + data = new object[] + { message, "Condition x >= y did not hold element-wise:", $"x (%s) = {x_name}", x, $"y (%s) = {y_name}", y - }; - } + }; + } - var condition = math_ops.reduce_all(gen_math_ops.greater_equal(x, y)); - return control_flow_ops.Assert(condition, data); - }); + var condition = math_ops.reduce_all(gen_math_ops.greater_equal(x, y)); + return control_flow_ops.Assert(condition, data); + }); } diff --git a/src/TensorFlowNET.Core/Operations/clip_ops.cs b/src/TensorFlowNET.Core/Operations/clip_ops.cs index 018949c0..62eb8410 100644 --- a/src/TensorFlowNET.Core/Operations/clip_ops.cs +++ b/src/TensorFlowNET.Core/Operations/clip_ops.cs @@ -14,11 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Operations/confusion_matrix.py.cs b/src/TensorFlowNET.Core/Operations/confusion_matrix.py.cs index b48139e0..8d457147 100644 --- a/src/TensorFlowNET.Core/Operations/confusion_matrix.py.cs +++ b/src/TensorFlowNET.Core/Operations/confusion_matrix.py.cs @@ -42,7 +42,7 @@ namespace Tensorflow var predictions_rank = predictions_shape.ndim; var labels_shape = labels.TensorShape; var labels_rank = labels_shape.ndim; - if(labels_rank > -1 && predictions_rank > -1) + if (labels_rank > -1 && predictions_rank > -1) { // Use static rank. var rank_diff = predictions_rank - labels_rank; diff --git a/src/TensorFlowNET.Core/Operations/control_flow_ops.cs b/src/TensorFlowNET.Core/Operations/control_flow_ops.cs index c97475e1..119c4b35 100644 --- a/src/TensorFlowNET.Core/Operations/control_flow_ops.cs +++ b/src/TensorFlowNET.Core/Operations/control_flow_ops.cs @@ -19,10 +19,9 @@ using System.Collections.Generic; using System.Linq; using Tensorflow.Operations; using Tensorflow.Operations.ControlFlows; -using util = Tensorflow.control_flow_util; -using static Tensorflow.Binding; using Tensorflow.Util; -using System.Data; +using static Tensorflow.Binding; +using util = Tensorflow.control_flow_util; namespace Tensorflow { @@ -72,7 +71,7 @@ namespace Tensorflow { if (condition == null) throw new InvalidArgumentError(""); - + return null; } @@ -164,7 +163,7 @@ namespace Tensorflow ControlFlowState loop_state = null; int pos = 0; - while(pos < between_op_list.Count) + while (pos < between_op_list.Count) { var op = between_op_list[pos]; if (IsLoopExit(op)) @@ -188,7 +187,7 @@ namespace Tensorflow public static bool IsLoopSwitch(Operation op) { - if(IsSwitch(op)) + if (IsSwitch(op)) { var ctxt = op._get_control_flow_context(); return ctxt != null && ctxt.IsWhileContext() && !IsCondSwitch(op); @@ -211,7 +210,7 @@ namespace Tensorflow name = scope; var gating_ops = tensors.Where(x => x != null).Select(x => x.op).ToList(); - if(control_inputs != null) + if (control_inputs != null) { foreach (var c in control_inputs) gating_ops.Add(c); @@ -223,7 +222,7 @@ namespace Tensorflow var gate = group(gating_ops.ToArray()); var tpl = new List(); - foreach(var t in tensors) + foreach (var t in tensors) { if (t != null) tpl.Add(with_dependencies(new Operation[] { gate }, t)); @@ -273,7 +272,7 @@ namespace Tensorflow exclusive, name, allow_python_preds: false//, - //strict: strict + //strict: strict ); /// @@ -373,7 +372,7 @@ namespace Tensorflow return gen_control_flow_ops.ref_switch(data, pred, name: name); } return @switch(data, pred, name: name); - } + } } /// @@ -434,8 +433,8 @@ namespace Tensorflow } // Add the Switch to the graph. - var switch_result= @switch(pred, pred); - var (p_2, p_1 )= (switch_result[0], switch_result[1]); + var switch_result = @switch(pred, pred); + var (p_2, p_1) = (switch_result[0], switch_result[1]); var pivot_1 = array_ops.identity(p_1, name: "switch_t"); var pivot_2 = array_ops.identity(p_2, name: "switch_f"); pred = array_ops.identity(pred, name: "pred_id"); @@ -489,7 +488,7 @@ namespace Tensorflow } - if(context_t.outer_context == null) + if (context_t.outer_context == null) { ops.add_to_collection(tf.GraphKeys.COND_CONTEXT, context_t); ops.add_to_collection(tf.GraphKeys.COND_CONTEXT, context_f); @@ -545,7 +544,7 @@ namespace Tensorflow var res_f_flat = res_f; var merges = zip(res_f_flat, res_t_flat) - .Select(pair => merge(new [] { pair.Item1, pair.Item2 })[0]) + .Select(pair => merge(new[] { pair.Item1, pair.Item2 })[0]) .ToArray(); if (orig_res_t is Tensor[] orig_res_tensor) @@ -561,7 +560,7 @@ namespace Tensorflow } - if(context_t.outer_context == null) + if (context_t.outer_context == null) { ops.add_to_collection(tf.GraphKeys.COND_CONTEXT, context_t); ops.add_to_collection(tf.GraphKeys.COND_CONTEXT, context_f); @@ -621,9 +620,9 @@ namespace Tensorflow /// /// /// - public static Tensor[] @switch(Tensor data, - Tensor pred, - TF_DataType dtype = TF_DataType.DtInvalid, + public static Tensor[] @switch(Tensor data, + Tensor pred, + TF_DataType dtype = TF_DataType.DtInvalid, string name = null) { return tf_with(ops.name_scope(name, "Switch", new { data, pred }), scope => @@ -652,7 +651,7 @@ namespace Tensorflow else { var op_ctxt = op._get_control_flow_context(); - if(op_ctxt != null) + if (op_ctxt != null) { // We are in a cond context. Use a switch to create zeros only when needed. var pred = op_ctxt.pred; @@ -771,9 +770,9 @@ namespace Tensorflow return_same_structure); //if (maximum_iterations != null) - return results.Item; + return results.Item; //else - //return results; + //return results; }); } diff --git a/src/TensorFlowNET.Core/Operations/control_flow_util.py.cs b/src/TensorFlowNET.Core/Operations/control_flow_util.py.cs index f9571a8a..c8891119 100644 --- a/src/TensorFlowNET.Core/Operations/control_flow_util.py.cs +++ b/src/TensorFlowNET.Core/Operations/control_flow_util.py.cs @@ -17,7 +17,6 @@ using System; using System.Linq; using Tensorflow.Operations; -using static Tensorflow.Binding; namespace Tensorflow { @@ -78,14 +77,14 @@ namespace Tensorflow // cond switch or not. A switch is a cond switch iff all its consumers are in // cond contexts. var is_cond_switch = true; - foreach(var o in op.outputs) + foreach (var o in op.outputs) { - foreach(var c in o.consumers()) + foreach (var c in o.consumers()) { var ctxt = c._get_control_flow_context(); if (IsLoopEnter(c)) ctxt = ctxt.outer_context; - is_cond_switch = is_cond_switch &&(ctxt != null && ctxt.IsCondContext()); + is_cond_switch = is_cond_switch && (ctxt != null && ctxt.IsCondContext()); } } @@ -178,7 +177,7 @@ namespace Tensorflow public static bool IsContainingContext(WhileContext ctxt, WhileContext maybe_containing_ctxt) { - while(ctxt != maybe_containing_ctxt) + while (ctxt != maybe_containing_ctxt) { if (ctxt == null) return false; diff --git a/src/TensorFlowNET.Core/Operations/ctc_ops.cs b/src/TensorFlowNET.Core/Operations/ctc_ops.cs index 07ed811d..348f4e1a 100644 --- a/src/TensorFlowNET.Core/Operations/ctc_ops.cs +++ b/src/TensorFlowNET.Core/Operations/ctc_ops.cs @@ -14,11 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Linq; -using Tensorflow.Operations; -using static Tensorflow.Binding; - namespace Tensorflow { public class ctc_ops diff --git a/src/TensorFlowNET.Core/Operations/dataset_ops.cs b/src/TensorFlowNET.Core/Operations/dataset_ops.cs index 231a18f8..2ccff1c0 100644 --- a/src/TensorFlowNET.Core/Operations/dataset_ops.cs +++ b/src/TensorFlowNET.Core/Operations/dataset_ops.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Framework.Models; using Tensorflow.Functions; using static Tensorflow.Binding; @@ -41,8 +39,8 @@ namespace Tensorflow var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, "TensorSliceDataset", name, null, - new object[] - { + new object[] + { components, "output_shapes", output_shapes }); @@ -89,7 +87,7 @@ namespace Tensorflow } public Tensor shard_dataset(Tensor input_dataset, Tensor num_shards, Tensor index, - TF_DataType[] output_types, TensorShape[] output_shapes, + TF_DataType[] output_types, TensorShape[] output_shapes, bool require_non_empty = false, string name = null) { if (tf.Context.executing_eagerly()) @@ -108,8 +106,8 @@ namespace Tensorflow } public Tensor zip_dataset(Tensor[] input_datasets, - TF_DataType[] output_types, - TensorShape[] output_shapes, + TF_DataType[] output_types, + TensorShape[] output_shapes, string name = null) { if (tf.Context.executing_eagerly()) @@ -129,9 +127,9 @@ namespace Tensorflow throw new NotImplementedException(""); } - public Tensor shuffle_dataset_v3(Tensor input_dataset, Tensor buffer_size, + public Tensor shuffle_dataset_v3(Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, Tensor seed_generator, - TF_DataType[] output_types, TensorShape[] output_shapes, + TF_DataType[] output_types, TensorShape[] output_shapes, bool reshuffle_each_iteration = true, string name = null) { @@ -272,10 +270,10 @@ namespace Tensorflow var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, "PrefetchDataset", name, null, - input_dataset, buffer_size, + input_dataset, buffer_size, "output_types", output_types, "output_shapes", output_shapes, - "slack_period", slack_period, + "slack_period", slack_period, "legacy_autotune", legacy_autotune); return results[0]; } @@ -363,8 +361,8 @@ namespace Tensorflow var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, "ModelDataset", name, null, - input_dataset, - "algorithm", algorithm, + input_dataset, + "algorithm", algorithm, "cpu_budget", cpu_budget, "output_types", output_types, "output_shapes", output_shapes); @@ -424,7 +422,7 @@ namespace Tensorflow /// /// /// - public Tensor map_dataset(Tensor dataset, ConcreteFunction f, TF_DataType[] output_types, TensorShape[] output_shapes, + public Tensor map_dataset(Tensor dataset, ConcreteFunction f, TF_DataType[] output_types, TensorShape[] output_shapes, bool use_inter_op_parallelism = true, bool preserve_cardinality = false, string name = null) { if (tf.Context.executing_eagerly()) @@ -434,7 +432,7 @@ namespace Tensorflow null, dataset, new Tensor[0], "f", f, - "output_types", output_types, + "output_types", output_types, "output_shapes", output_shapes, "use_inter_op_parallelism", use_inter_op_parallelism, "preserve_cardinality", preserve_cardinality); @@ -482,8 +480,8 @@ namespace Tensorflow /// /// /// - public Tensor parallel_map_dataset_v2(Tensor dataset, Tensor num_parallel_calls, ConcreteFunction f, - TF_DataType[] output_types, TensorShape[] output_shapes, + public Tensor parallel_map_dataset_v2(Tensor dataset, Tensor num_parallel_calls, ConcreteFunction f, + TF_DataType[] output_types, TensorShape[] output_shapes, bool use_inter_op_parallelism = true, string deterministic = "default", bool preserve_cardinality = false, diff --git a/src/TensorFlowNET.Core/Operations/embedding_ops.cs b/src/TensorFlowNET.Core/Operations/embedding_ops.cs index f9ba150a..fe79e006 100644 --- a/src/TensorFlowNET.Core/Operations/embedding_ops.cs +++ b/src/TensorFlowNET.Core/Operations/embedding_ops.cs @@ -40,7 +40,7 @@ namespace Tensorflow name = scope; int np = 1; ids = ops.convert_to_tensor(ids, name: "ids"); - if(np == 1) + if (np == 1) { var gather = array_ops.gather(@params, ids, name: name); var result = _clip(gather, ids, max_norm); @@ -118,8 +118,8 @@ namespace Tensorflow throw new NotImplementedException("_clip"); } - public static Tensor embedding_lookup(Tensor[] @params, Tensor ids, - string partition_strategy = "mod", + public static Tensor embedding_lookup(Tensor[] @params, Tensor ids, + string partition_strategy = "mod", string name = null, bool validate_indices = true, string max_norm = null) diff --git a/src/TensorFlowNET.Core/Operations/functional_ops.cs b/src/TensorFlowNET.Core/Operations/functional_ops.cs index 37f1b07e..67450c74 100644 --- a/src/TensorFlowNET.Core/Operations/functional_ops.cs +++ b/src/TensorFlowNET.Core/Operations/functional_ops.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; using System.Linq; -using NumSharp; using Tensorflow.Framework; using Tensorflow.Util; using static Tensorflow.Binding; @@ -39,7 +38,7 @@ namespace Tensorflow { bool input_is_sequence = nest.is_sequence(elems); - Tensor[] input_flatten(Tensor x) => input_is_sequence ? nest.flatten(x).ToArray() : new [] {x}; + Tensor[] input_flatten(Tensor x) => input_is_sequence ? nest.flatten(x).ToArray() : new[] { x }; Tensor input_pack(Tensor[] x) => input_is_sequence ? (Tensor)nest.pack_sequence_as(elems, x) : x[0]; bool output_is_sequence; @@ -54,7 +53,7 @@ namespace Tensorflow else { output_is_sequence = nest.is_sequence(initializer); - output_flatten = (x) => output_is_sequence ? nest.flatten(x).ToArray() : new [] {x}; + output_flatten = (x) => output_is_sequence ? nest.flatten(x).ToArray() : new[] { x }; output_pack = (x) => output_is_sequence ? (Tensor)nest.pack_sequence_as(initializer, x) : x[0]; } @@ -171,7 +170,7 @@ namespace Tensorflow var results_flat = bodyItem.Accs_ta.Select(r => r.stack()).ToArray(); var n_static = new Dimension(tensor_shape.dimension_value(elems_flat[0].TensorShape.with_rank_at_least(1).dims[0])); - + foreach (var elem in elems_flat.Skip(1)) { n_static.merge_with(new Dimension(tensor_shape.dimension_value(elem.TensorShape.with_rank_at_least(1).dims[0]))); @@ -211,25 +210,25 @@ namespace Tensorflow public object[] Flatten() { var elements = new List { I }; - elements.AddRange(A_Flat); - elements.AddRange(Accs_ta); + elements.AddRange(A_Flat); + elements.AddRange(Accs_ta); return elements.ToArray(); } public BodyItem Pack(object[] sequences) { I = sequences[0] as Tensor; - A_Flat = new [] { sequences[1] as Tensor }; - Accs_ta = new [] { sequences[2] as TensorArray }; - + A_Flat = new[] { sequences[1] as Tensor }; + Accs_ta = new[] { sequences[2] as TensorArray }; + return new BodyItem(I, A_Flat, Accs_ta); } public BodyItem FromMergeVars(ITensorOrTensorArray[] merge_vars) { I = (Tensor)merge_vars[1]; - A_Flat = new [] {(Tensor) merge_vars[2]}; - Accs_ta = new [] {(TensorArray) merge_vars[3]}; + A_Flat = new[] { (Tensor)merge_vars[2] }; + Accs_ta = new[] { (TensorArray)merge_vars[3] }; return this; } } diff --git a/src/TensorFlowNET.Core/Operations/gen_array_ops.cs b/src/TensorFlowNET.Core/Operations/gen_array_ops.cs index c35ff349..d252e077 100644 --- a/src/TensorFlowNET.Core/Operations/gen_array_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_array_ops.cs @@ -14,12 +14,9 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using static Tensorflow.Binding; -using Tensorflow.Eager; using System.Linq; using Tensorflow.Contexts; +using static Tensorflow.Binding; namespace Tensorflow { @@ -31,7 +28,7 @@ namespace Tensorflow return _op.output; } - + public static Tensor check_numerics(Tensor tensor, string message, string name = null) { var _op = tf.OpDefLib._apply_op_helper("CheckNumerics", name: name, args: new { tensor, message }); @@ -51,7 +48,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "ConcatV2", name, + "ConcatV2", name, null, values, axis); @@ -75,7 +72,7 @@ namespace Tensorflow public static Tensor concat_v2(Tensor[] values, int axis, string name = null) => tf.Context.RunInAutoMode(() - => tf.OpDefLib._apply_op_helper("ConcatV2", name: name, + => tf.OpDefLib._apply_op_helper("ConcatV2", name: name, args: new { values, axis }).output, () => tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, "ConcatV2", name, @@ -191,9 +188,9 @@ namespace Tensorflow public static Tensor pack(Tensor[] values, int axis = 0, string name = null) { - if(tf.Context.executing_eagerly()) + if (tf.Context.executing_eagerly()) { - var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, + var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, "Pack", name, null, values, @@ -293,10 +290,10 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "BroadcastGradientArgs", name, + "BroadcastGradientArgs", name, null, - s0,s1); - + s0, s1); + return (results[0], results[1]); } @@ -356,7 +353,7 @@ namespace Tensorflow public static Tensor one_hot(Tensor indices, Tensor depth, Tensor on_value = null, Tensor off_value = null, - TF_DataType dtype = TF_DataType.DtInvalid, + TF_DataType dtype = TF_DataType.DtInvalid, int axis = -1, string name = null) { @@ -412,7 +409,7 @@ namespace Tensorflow public static Tensor shape(Tensor input, TF_DataType out_type = TF_DataType.TF_INT32, string name = null) => tf.Context.RunInAutoMode(() - => tf.OpDefLib._apply_op_helper("Shape", name, + => tf.OpDefLib._apply_op_helper("Shape", name, new { input, out_type }).output, () => tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, "Shape", name, @@ -630,7 +627,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Squeeze", name, + "Squeeze", name, null, input, "squeeze_dims", axis); diff --git a/src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs b/src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs index c4c2d441..2901e5fc 100644 --- a/src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_control_flow_ops.cs @@ -157,7 +157,7 @@ namespace Tensorflow #pragma warning restore CS0219 // Variable is assigned but its value is never used // TODO: missing original code //_execute.record_gradient("Switch", _inputs_flat, _attrs, _result, name); - return new []{_op.outputs[0], _op.outputs[1]}; + return new[] { _op.outputs[0], _op.outputs[1] }; } public static MergeOutput ref_merge(Tensor[] inputs, string name = null) diff --git a/src/TensorFlowNET.Core/Operations/gen_data_flow_ops.cs b/src/TensorFlowNET.Core/Operations/gen_data_flow_ops.cs index beaebce0..233d1344 100644 --- a/src/TensorFlowNET.Core/Operations/gen_data_flow_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_data_flow_ops.cs @@ -27,11 +27,11 @@ namespace Tensorflow return _op.output; } - public static Tensor[] dynamic_partition(Tensor data, Tensor partitions, int num_partitions, + public static Tensor[] dynamic_partition(Tensor data, Tensor partitions, int num_partitions, string name = null) { - var _op = tf.OpDefLib._apply_op_helper("DynamicPartition", name, new - { + var _op = tf.OpDefLib._apply_op_helper("DynamicPartition", name, new + { data, partitions, num_partitions @@ -40,8 +40,8 @@ namespace Tensorflow return _op.outputs; } - public static (Tensor, Tensor) tensor_array_v3(T size, TF_DataType dtype = TF_DataType.DtInvalid, - TensorShape element_shape = null, bool dynamic_size = false, bool clear_after_read = true, + public static (Tensor, Tensor) tensor_array_v3(T size, TF_DataType dtype = TF_DataType.DtInvalid, + TensorShape element_shape = null, bool dynamic_size = false, bool clear_after_read = true, bool identical_element_shapes = false, string tensor_array_name = "", string name = null) { var _op = tf.OpDefLib._apply_op_helper("TensorArrayV3", name, new @@ -58,7 +58,7 @@ namespace Tensorflow return (_op.outputs[0], _op.outputs[1]); } - public static Tensor tensor_array_scatter_v3(Tensor handle, Tensor indices, Tensor value, + public static Tensor tensor_array_scatter_v3(Tensor handle, Tensor indices, Tensor value, Tensor flow_in, string name = null) { var _op = tf.OpDefLib._apply_op_helper("TensorArrayScatterV3", name, new @@ -72,8 +72,8 @@ namespace Tensorflow return _op.output; } - public static Tensor padding_fifo_queue_v2(TF_DataType[] component_types, TensorShape[] shapes, - int capacity = -1, string container = "", string shared_name = "", + public static Tensor padding_fifo_queue_v2(TF_DataType[] component_types, TensorShape[] shapes, + int capacity = -1, string container = "", string shared_name = "", string name = null) { var _op = tf.OpDefLib._apply_op_helper("PaddingFIFOQueueV2", name, new @@ -258,7 +258,7 @@ namespace Tensorflow return _op.output; } - public static Tensor tensor_array_gather_v3(Tensor handle, Tensor indices, Tensor flow_in, + public static Tensor tensor_array_gather_v3(Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, TensorShape element_shape = null, string name = null) { var _op = tf.OpDefLib._apply_op_helper("TensorArrayGatherV3", name, new @@ -273,7 +273,7 @@ namespace Tensorflow return _op.output; } - public static Tensor stack_v2(Tensor max_size, TF_DataType elem_type, string stack_name = "", + public static Tensor stack_v2(Tensor max_size, TF_DataType elem_type, string stack_name = "", string name = null) { var _op = tf.OpDefLib._apply_op_helper("StackV2", name, new @@ -286,7 +286,7 @@ namespace Tensorflow return _op.output; } - public static Tensor stack_push_v2(Tensor handle, Tensor elem, bool swap_memory = false, + public static Tensor stack_push_v2(Tensor handle, Tensor elem, bool swap_memory = false, string name = null) { var _op = tf.OpDefLib._apply_op_helper("StackPushV2", name, new diff --git a/src/TensorFlowNET.Core/Operations/gen_image_ops.cs b/src/TensorFlowNET.Core/Operations/gen_image_ops.cs index 17c3031c..eed9e572 100644 --- a/src/TensorFlowNET.Core/Operations/gen_image_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_image_ops.cs @@ -16,7 +16,6 @@ using System; using System.Linq; -using Tensorflow.Contexts; using static Tensorflow.Binding; namespace Tensorflow @@ -29,7 +28,7 @@ namespace Tensorflow throw new NotImplementedException("combined_non_max_suppression"); } - public static Tensor convert_image_dtype(Tensor image, TF_DataType dtype, bool saturate = false, string name= null) + public static Tensor convert_image_dtype(Tensor image, TF_DataType dtype, bool saturate = false, string name = null) { if (dtype == image.dtype) return array_ops.identity(image, name: name); @@ -41,7 +40,7 @@ namespace Tensorflow if (image.dtype.is_integer() && dtype.is_integer()) { throw new NotImplementedException("convert_image_dtype is_integer"); - } + } else if (image.dtype.is_floating() && dtype.is_floating()) { throw new NotImplementedException("convert_image_dtype is_floating"); @@ -82,7 +81,7 @@ namespace Tensorflow "channels", channels, "ratio", ratio, "fancy_upscaling", fancy_upscaling, - "try_recover_truncated", try_recover_truncated, + "try_recover_truncated", try_recover_truncated, "acceptable_fraction", acceptable_fraction, "dct_method", dct_method); return results[0]; @@ -221,7 +220,7 @@ namespace Tensorflow return _op.outputs[0]; } - public static Tensor resize_nearest_neighbor(Tensor images, Tsize size, bool align_corners = false, + public static Tensor resize_nearest_neighbor(Tensor images, Tsize size, bool align_corners = false, bool half_pixel_centers = false, string name = null) => tf.Context.RunInAutoMode(() => tf.OpDefLib._apply_op_helper("ResizeNearestNeighbor", name: name, args: new diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs index 2666f4dd..bb9cc1c9 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.cs @@ -16,9 +16,7 @@ using System; using System.Linq; -using System.Runtime.InteropServices; using Tensorflow.Contexts; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow @@ -86,7 +84,7 @@ namespace Tensorflow /// /// /// - public static Tensor arg_min(Tensor input, int dimension, TF_DataType output_type= TF_DataType.TF_INT64, string name= null) + public static Tensor arg_min(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null) => tf.OpDefLib._apply_op_helper("ArgMin", name, args: new { input, dimension, output_type }).outputs[0]; /// @@ -139,7 +137,7 @@ namespace Tensorflow /// An optional `bool`. Defaults to `False`. If true, retain reduced dimensions with length 1. /// A name for the operation (optional). /// A `Tensor`. Has the same type as `input`. - public static Tensor mean(T1 input, T2 axis, bool keep_dims= false, string name = null) + public static Tensor mean(T1 input, T2 axis, bool keep_dims = false, string name = null) { if (tf.Context.executing_eagerly()) { @@ -186,7 +184,7 @@ namespace Tensorflow try { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Prod", name, + "Prod", name, null, input, axis, "keep_dims", keep_dims); @@ -232,7 +230,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Add", name, null, + "Add", name, null, x, y); return results[0]; } @@ -247,7 +245,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Add", name, + "Add", name, null, x, y); @@ -265,7 +263,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "AddV2", name, + "AddV2", name, null, x, y); return results[0]; @@ -295,7 +293,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Sin", name, + "Sin", name, null, x); @@ -366,7 +364,7 @@ namespace Tensorflow public static Tensor sign(T x, string name = "Sign") { - var op = tf.OpDefLib._apply_op_helper("Sign", name: name, args: new {x}); + var op = tf.OpDefLib._apply_op_helper("Sign", name: name, args: new { x }); return op.outputs[0]; } @@ -418,7 +416,7 @@ namespace Tensorflow if (tf.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Tan", name, + "Tan", name, null, x); @@ -459,7 +457,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "TanhGrad", name, + "TanhGrad", name, null, y, dy); @@ -492,7 +490,7 @@ namespace Tensorflow "Greater", name, null, x, y); - + return results[0]; } @@ -524,7 +522,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "GreaterEqual", name, + "GreaterEqual", name, null, x, y); @@ -544,7 +542,7 @@ namespace Tensorflow "Less", name, null, x, y); - + return results[0]; } @@ -561,7 +559,7 @@ namespace Tensorflow "LessEqual", name, null, x, y); - + return results[0]; } @@ -626,7 +624,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Square", name, + "Square", name, null, x); @@ -684,7 +682,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Log", name, + "Log", name, null, x); @@ -696,7 +694,7 @@ namespace Tensorflow return _op.outputs[0]; } - public static Tensor cast(Tensor x, TF_DataType DstT, bool Truncate= false, string name= null) + public static Tensor cast(Tensor x, TF_DataType DstT, bool Truncate = false, string name = null) => tf.Context.RunInAutoMode(() => tf.OpDefLib._apply_op_helper("Cast", name, args: new { x, DstT, Truncate }).output, () => tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, @@ -711,7 +709,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Neg", name, + "Neg", name, null, x); @@ -728,7 +726,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Sqrt", name, + "Sqrt", name, null, x); @@ -745,7 +743,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Sub", name, + "Sub", name, null, x, y); return results[0]; @@ -761,7 +759,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Sub", name, + "Sub", name, null, x, y); @@ -785,7 +783,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Equal", name, + "Equal", name, null, x, y); @@ -810,7 +808,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "NotEqual", name, + "NotEqual", name, null, x, y); @@ -827,7 +825,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Atan2", name, + "Atan2", name, null, y, x); @@ -843,7 +841,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Mul", name, + "Mul", name, null, x, y); return results[0]; @@ -859,7 +857,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Mul", name, + "Mul", name, null, x, y); @@ -883,7 +881,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "RealDiv", name, + "RealDiv", name, null, x, y); return results[0]; @@ -916,7 +914,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "FloorMod", name, + "FloorMod", name, null, x, y); @@ -933,7 +931,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "FloorDiv", name, + "FloorDiv", name, null, x, y); @@ -1077,13 +1075,13 @@ namespace Tensorflow return _op.outputs[0]; } - + public static Tensor pow(Tx x, Ty y, string name = null) { if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "Pow", name, + "Pow", name, null, x, y); diff --git a/src/TensorFlowNET.Core/Operations/gen_math_ops.eager.cs b/src/TensorFlowNET.Core/Operations/gen_math_ops.eager.cs index dc86c1e5..f80b5f0f 100644 --- a/src/TensorFlowNET.Core/Operations/gen_math_ops.eager.cs +++ b/src/TensorFlowNET.Core/Operations/gen_math_ops.eager.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Operations/gen_ops.cs b/src/TensorFlowNET.Core/Operations/gen_ops.cs index 072e9739..a1e26d7f 100644 --- a/src/TensorFlowNET.Core/Operations/gen_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_ops.cs @@ -1,6 +1,6 @@ using System; -using System.Linq; using System.Collections.Generic; +using System.Linq; using static Tensorflow.Binding; namespace Tensorflow.Operations @@ -27,7 +27,7 @@ namespace Tensorflow.Operations /// /// Returns nothing but an exception. /// - public static Operation abort (string error_msg = null, bool? exit_without_error = null, string name = "Abort") + public static Operation abort(string error_msg = null, bool? exit_without_error = null, string name = "Abort") { var dict = new Dictionary(); if (error_msg != null) @@ -54,7 +54,7 @@ namespace Tensorflow.Operations /// value of each element in x. For example, if x is an input element and y is /// an output element, this operation computes \\(y = |x|\\). /// - public static Tensor abs (Tensor x, string name = "Abs") + public static Tensor abs(Tensor x, string name = "Abs") { var dict = new Dictionary(); dict["x"] = x; @@ -88,7 +88,7 @@ namespace Tensorflow.Operations /// /// Returns a Tensor of same shape and type as the elements of inputs. /// - public static Tensor accumulate_n_v2 (Tensor[] inputs, TensorShape shape, string name = "AccumulateNV2") + public static Tensor accumulate_n_v2(Tensor[] inputs, TensorShape shape, string name = "AccumulateNV2") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -118,7 +118,7 @@ namespace Tensorflow.Operations /// /// Does not add if local_step is lesser than the accumulator's global_step. /// - public static Operation accumulator_apply_gradient (Tensor handle, Tensor local_step, Tensor gradient, string name = "AccumulatorApplyGradient") + public static Operation accumulator_apply_gradient(Tensor handle, Tensor local_step, Tensor gradient, string name = "AccumulatorApplyGradient") { var dict = new Dictionary(); dict["handle"] = handle; @@ -141,7 +141,7 @@ namespace Tensorflow.Operations /// The number of gradients aggregated in the given accumulator. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor accumulator_num_accumulated (Tensor handle, string name = "AccumulatorNumAccumulated") + public static Tensor accumulator_num_accumulated(Tensor handle, string name = "AccumulatorNumAccumulated") { var dict = new Dictionary(); dict["handle"] = handle; @@ -168,7 +168,7 @@ namespace Tensorflow.Operations /// Logs warning if the accumulator's value is already higher than /// new_global_step. /// - public static Operation accumulator_set_global_step (Tensor handle, Tensor new_global_step, string name = "AccumulatorSetGlobalStep") + public static Operation accumulator_set_global_step(Tensor handle, Tensor new_global_step, string name = "AccumulatorSetGlobalStep") { var dict = new Dictionary(); dict["handle"] = handle; @@ -205,7 +205,7 @@ namespace Tensorflow.Operations /// the accumulated gradients. Also automatically increments the recorded /// global_step in the accumulator by 1, and resets the aggregate to 0. /// - public static Tensor accumulator_take_gradient (Tensor handle, Tensor num_required, TF_DataType dtype, string name = "AccumulatorTakeGradient") + public static Tensor accumulator_take_gradient(Tensor handle, Tensor num_required, TF_DataType dtype, string name = "AccumulatorTakeGradient") { var dict = new Dictionary(); dict["handle"] = handle; @@ -226,7 +226,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor acos (Tensor x, string name = "Acos") + public static Tensor acos(Tensor x, string name = "Acos") { var dict = new Dictionary(); dict["x"] = x; @@ -245,7 +245,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor acosh (Tensor x, string name = "Acosh") + public static Tensor acosh(Tensor x, string name = "Acosh") { var dict = new Dictionary(); dict["x"] = x; @@ -270,7 +270,7 @@ namespace Tensorflow.Operations /// *NOTE*: Add supports broadcasting. AddN does not. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor add (Tensor x, Tensor y, string name = "Add") + public static Tensor add(Tensor x, Tensor y, string name = "Add") { var dict = new Dictionary(); dict["x"] = x; @@ -334,7 +334,7 @@ namespace Tensorflow.Operations /// AddManySparseToTensorsMap as the shared_name passed to /// TakeManySparseFromTensorsMap. Ensure the Operations are colocated. /// - public static Tensor add_many_sparse_to_tensors_map (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape, string container = null, string shared_name = null, string name = "AddManySparseToTensorsMap") + public static Tensor add_many_sparse_to_tensors_map(Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape, string container = null, string shared_name = null, string name = "AddManySparseToTensorsMap") { var dict = new Dictionary(); dict["sparse_indices"] = sparse_indices; @@ -360,7 +360,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor add_n (Tensor[] inputs, string name = "AddN") + public static Tensor add_n(Tensor[] inputs, string name = "AddN") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -411,7 +411,7 @@ namespace Tensorflow.Operations /// AddSparseToTensorsMap as the shared_name passed to /// TakeManySparseFromTensorsMap. Ensure the Operations are colocated. /// - public static Tensor add_sparse_to_tensors_map (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape, string container = null, string shared_name = null, string name = "AddSparseToTensorsMap") + public static Tensor add_sparse_to_tensors_map(Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape, string container = null, string shared_name = null, string name = "AddSparseToTensorsMap") { var dict = new Dictionary(); dict["sparse_indices"] = sparse_indices; @@ -442,7 +442,7 @@ namespace Tensorflow.Operations /// *NOTE*: Add supports broadcasting. AddN does not. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor add_v2 (Tensor x, Tensor y, string name = "AddV2") + public static Tensor add_v2(Tensor x, Tensor y, string name = "AddV2") { var dict = new Dictionary(); dict["x"] = x; @@ -468,7 +468,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor adjust_contrast (Tensor images, Tensor contrast_factor, Tensor min_value, Tensor max_value, string name = "AdjustContrast") + public static Tensor adjust_contrast(Tensor images, Tensor contrast_factor, Tensor min_value, Tensor max_value, string name = "AdjustContrast") { var dict = new Dictionary(); dict["images"] = images; @@ -506,7 +506,7 @@ namespace Tensorflow.Operations /// channel and then adjusts each component of each pixel to /// (x - mean) * contrast_factor + mean. /// - public static Tensor adjust_contrastv2 (Tensor images, Tensor contrast_factor, string name = "AdjustContrastv2") + public static Tensor adjust_contrastv2(Tensor images, Tensor contrast_factor, string name = "AdjustContrastv2") { var dict = new Dictionary(); dict["images"] = images; @@ -539,7 +539,7 @@ namespace Tensorflow.Operations /// colors are first mapped into HSV. A delta is then applied all the hue values, /// and then remapped back to RGB colorspace. /// - public static Tensor adjust_hue (Tensor images, Tensor delta, string name = "AdjustHue") + public static Tensor adjust_hue(Tensor images, Tensor delta, string name = "AdjustHue") { var dict = new Dictionary(); dict["images"] = images; @@ -572,7 +572,7 @@ namespace Tensorflow.Operations /// colors are first mapped into HSV. A scale is then applied all the saturation /// values, and then remapped back to RGB colorspace. /// - public static Tensor adjust_saturation (Tensor images, Tensor scale, string name = "AdjustSaturation") + public static Tensor adjust_saturation(Tensor images, Tensor scale, string name = "AdjustSaturation") { var dict = new Dictionary(); dict["images"] = images; @@ -607,7 +607,7 @@ namespace Tensorflow.Operations /// axis. If keep_dims is true, the reduced dimensions are /// retained with length 1. /// - public static Tensor all (Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "All") + public static Tensor all(Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "All") { var dict = new Dictionary(); dict["input"] = input; @@ -674,7 +674,7 @@ namespace Tensorflow.Operations /// the sampled candidates must be chosen independently of the context and of the /// true labels. /// - public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) all_candidate_sampler (Tensor true_classes, int num_true, int num_sampled, bool unique, int? seed = null, int? seed2 = null, string name = "AllCandidateSampler") + public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) all_candidate_sampler(Tensor true_classes, int num_true, int num_sampled, bool unique, int? seed = null, int? seed2 = null, string name = "AllCandidateSampler") { var dict = new Dictionary(); dict["true_classes"] = true_classes; @@ -725,7 +725,7 @@ namespace Tensorflow.Operations /// Equivalent to np.angle. /// @end_compatibility /// - public static Tensor angle (Tensor input, TF_DataType? Tout = null, string name = "Angle") + public static Tensor angle(Tensor input, TF_DataType? Tout = null, string name = "Angle") { var dict = new Dictionary(); dict["input"] = input; @@ -754,7 +754,7 @@ namespace Tensorflow.Operations /// container. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor anonymous_iterator (TF_DataType[] output_types, TensorShape[] output_shapes, string name = "AnonymousIterator") + public static Tensor anonymous_iterator(TF_DataType[] output_types, TensorShape[] output_shapes, string name = "AnonymousIterator") { var dict = new Dictionary(); dict["output_types"] = output_types; @@ -789,7 +789,7 @@ namespace Tensorflow.Operations /// axis. If keep_dims is true, the reduced dimensions are /// retained with length 1. /// - public static Tensor any (Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Any") + public static Tensor any(Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Any") { var dict = new Dictionary(); dict["input"] = input; @@ -847,7 +847,7 @@ namespace Tensorflow.Operations /// v_t &lt;- max(beta2 * v_{t-1}, abs(g)) /// variable &lt;- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon) /// - public static Tensor apply_ada_max (Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ApplyAdaMax") + public static Tensor apply_ada_max(Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ApplyAdaMax") { var dict = new Dictionary(); dict["var"] = var; @@ -906,7 +906,7 @@ namespace Tensorflow.Operations /// update_accum = rho() * update_accum + (1 - rho()) * update.square(); /// var -= update; /// - public static Tensor apply_adadelta (Tensor var, Tensor accum, Tensor accum_update, Tensor lr, Tensor rho, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ApplyAdadelta") + public static Tensor apply_adadelta(Tensor var, Tensor accum, Tensor accum_update, Tensor lr, Tensor rho, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ApplyAdadelta") { var dict = new Dictionary(); dict["var"] = var; @@ -955,7 +955,7 @@ namespace Tensorflow.Operations /// accum += grad * grad /// var -= lr * grad * (1 / sqrt(accum)) /// - public static Tensor apply_adagrad (Tensor var, Tensor accum, Tensor lr, Tensor grad, bool? use_locking = null, bool? update_slots = null, string name = "ApplyAdagrad") + public static Tensor apply_adagrad(Tensor var, Tensor accum, Tensor lr, Tensor grad, bool? use_locking = null, bool? update_slots = null, string name = "ApplyAdagrad") { var dict = new Dictionary(); dict["var"] = var; @@ -1008,7 +1008,7 @@ namespace Tensorflow.Operations /// Same as "var". /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor apply_adagrad_d_a (Tensor var, Tensor gradient_accumulator, Tensor gradient_squared_accumulator, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor global_step, bool? use_locking = null, string name = "ApplyAdagradDA") + public static Tensor apply_adagrad_d_a(Tensor var, Tensor gradient_accumulator, Tensor gradient_squared_accumulator, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor global_step, bool? use_locking = null, string name = "ApplyAdagradDA") { var dict = new Dictionary(); dict["var"] = var; @@ -1079,7 +1079,7 @@ namespace Tensorflow.Operations /// $$v_t := beta_2 * v_{t-1} + (1 - beta_2) * g * g$$ /// $$variable := variable - lr_t * m_t / (\sqrt{v_t} + \epsilon)$$ /// - public static Tensor apply_adam (Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor beta2_power, Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool? use_locking = null, bool? use_nesterov = null, string name = "ApplyAdam") + public static Tensor apply_adam(Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor beta2_power, Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool? use_locking = null, bool? use_nesterov = null, string name = "ApplyAdam") { var dict = new Dictionary(); dict["var"] = var; @@ -1141,7 +1141,7 @@ namespace Tensorflow.Operations /// update &lt;- (alpha + sign_decay * sign(g) *sign(m)) * g /// variable &lt;- variable - lr_t * update /// - public static Tensor apply_add_sign (Tensor var, Tensor m, Tensor lr, Tensor alpha, Tensor sign_decay, Tensor beta, Tensor grad, bool? use_locking = null, string name = "ApplyAddSign") + public static Tensor apply_add_sign(Tensor var, Tensor m, Tensor lr, Tensor alpha, Tensor sign_decay, Tensor beta, Tensor grad, bool? use_locking = null, string name = "ApplyAddSign") { var dict = new Dictionary(); dict["var"] = var; @@ -1218,7 +1218,7 @@ namespace Tensorflow.Operations /// mom &lt;- momentum * mom_{t-1} + lr * grad / sqrt(ms - mg * mg + epsilon) /// var &lt;- var - mom /// - public static Tensor apply_centered_r_m_s_prop (Tensor var, Tensor mg, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ApplyCenteredRMSProp") + public static Tensor apply_centered_r_m_s_prop(Tensor var, Tensor mg, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ApplyCenteredRMSProp") { var dict = new Dictionary(); dict["var"] = var; @@ -1282,7 +1282,7 @@ namespace Tensorflow.Operations /// var = (sign(linear) * l1 - linear) / quadratic if |linear| &gt; l1 else 0.0 /// accum = accum_new /// - public static Tensor apply_ftrl (Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor lr_power, bool? use_locking = null, string name = "ApplyFtrl") + public static Tensor apply_ftrl(Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor lr_power, bool? use_locking = null, string name = "ApplyFtrl") { var dict = new Dictionary(); dict["var"] = var; @@ -1349,7 +1349,7 @@ namespace Tensorflow.Operations /// var = (sign(linear) * l1 - linear) / quadratic if |linear| &gt; l1 else 0.0 /// accum = accum_new /// - public static Tensor apply_ftrl_v2 (Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor l2_shrinkage, Tensor lr_power, bool? use_locking = null, string name = "ApplyFtrlV2") + public static Tensor apply_ftrl_v2(Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor l2_shrinkage, Tensor lr_power, bool? use_locking = null, string name = "ApplyFtrlV2") { var dict = new Dictionary(); dict["var"] = var; @@ -1390,7 +1390,7 @@ namespace Tensorflow.Operations /// Same as "var". /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor apply_gradient_descent (Tensor var, Tensor alpha, Tensor delta, bool? use_locking = null, string name = "ApplyGradientDescent") + public static Tensor apply_gradient_descent(Tensor var, Tensor alpha, Tensor delta, bool? use_locking = null, string name = "ApplyGradientDescent") { var dict = new Dictionary(); dict["var"] = var; @@ -1443,7 +1443,7 @@ namespace Tensorflow.Operations /// accum = accum * momentum + grad /// var -= lr * accum /// - public static Tensor apply_momentum (Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor momentum, bool? use_locking = null, bool? use_nesterov = null, string name = "ApplyMomentum") + public static Tensor apply_momentum(Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor momentum, bool? use_locking = null, bool? use_nesterov = null, string name = "ApplyMomentum") { var dict = new Dictionary(); dict["var"] = var; @@ -1500,7 +1500,7 @@ namespace Tensorflow.Operations /// update &lt;- exp(logbase * sign_decay * sign(g) * sign(m_t)) * g /// variable &lt;- variable - lr_t * update /// - public static Tensor apply_power_sign (Tensor var, Tensor m, Tensor lr, Tensor logbase, Tensor sign_decay, Tensor beta, Tensor grad, bool? use_locking = null, string name = "ApplyPowerSign") + public static Tensor apply_power_sign(Tensor var, Tensor m, Tensor lr, Tensor logbase, Tensor sign_decay, Tensor beta, Tensor grad, bool? use_locking = null, string name = "ApplyPowerSign") { var dict = new Dictionary(); dict["var"] = var; @@ -1553,7 +1553,7 @@ namespace Tensorflow.Operations /// prox_v = var - lr * grad * (1 / sqrt(accum)) /// var = sign(prox_v)/(1+lr*l2) * max{|prox_v|-lr*l1,0} /// - public static Tensor apply_proximal_adagrad (Tensor var, Tensor accum, Tensor lr, Tensor l1, Tensor l2, Tensor grad, bool? use_locking = null, string name = "ApplyProximalAdagrad") + public static Tensor apply_proximal_adagrad(Tensor var, Tensor accum, Tensor lr, Tensor l1, Tensor l2, Tensor grad, bool? use_locking = null, string name = "ApplyProximalAdagrad") { var dict = new Dictionary(); dict["var"] = var; @@ -1601,7 +1601,7 @@ namespace Tensorflow.Operations /// prox_v = var - alpha * delta /// var = sign(prox_v)/(1+alpha*l2) * max{|prox_v|-alpha*l1,0} /// - public static Tensor apply_proximal_gradient_descent (Tensor var, Tensor alpha, Tensor l1, Tensor l2, Tensor delta, bool? use_locking = null, string name = "ApplyProximalGradientDescent") + public static Tensor apply_proximal_gradient_descent(Tensor var, Tensor alpha, Tensor l1, Tensor l2, Tensor delta, bool? use_locking = null, string name = "ApplyProximalGradientDescent") { var dict = new Dictionary(); dict["var"] = var; @@ -1665,7 +1665,7 @@ namespace Tensorflow.Operations /// mom &lt;- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon) /// var &lt;- var - mom /// - public static Tensor apply_r_m_s_prop (Tensor var, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ApplyRMSProp") + public static Tensor apply_r_m_s_prop(Tensor var, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ApplyRMSProp") { var dict = new Dictionary(); dict["var"] = var; @@ -1697,7 +1697,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor approximate_equal (Tensor x, Tensor y, float? tolerance = null, string name = "ApproximateEqual") + public static Tensor approximate_equal(Tensor x, Tensor y, float? tolerance = null, string name = "ApproximateEqual") { var dict = new Dictionary(); dict["x"] = x; @@ -1729,7 +1729,7 @@ namespace Tensorflow.Operations /// /// Note that in case of ties the identity of the return value is not guaranteed. /// - public static Tensor arg_max (Tensor input, Tensor dimension, TF_DataType? output_type = null, string name = "ArgMax") + public static Tensor arg_max(Tensor input, Tensor dimension, TF_DataType? output_type = null, string name = "ArgMax") { var dict = new Dictionary(); dict["input"] = input; @@ -1761,7 +1761,7 @@ namespace Tensorflow.Operations /// /// Note that in case of ties the identity of the return value is not guaranteed. /// - public static Tensor arg_min (Tensor input, Tensor dimension, TF_DataType? output_type = null, string name = "ArgMin") + public static Tensor arg_min(Tensor input, Tensor dimension, TF_DataType? output_type = null, string name = "ArgMin") { var dict = new Dictionary(); dict["input"] = input; @@ -1806,7 +1806,7 @@ namespace Tensorflow.Operations /// /// types and boolean. /// - public static Tensor as_string (Tensor input, int? precision = null, bool? scientific = null, bool? shortest = null, int? width = null, string fill = null, string name = "AsString") + public static Tensor as_string(Tensor input, int? precision = null, bool? scientific = null, bool? shortest = null, int? width = null, string fill = null, string name = "AsString") { var dict = new Dictionary(); dict["input"] = input; @@ -1835,7 +1835,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor asin (Tensor x, string name = "Asin") + public static Tensor asin(Tensor x, string name = "Asin") { var dict = new Dictionary(); dict["x"] = x; @@ -1854,7 +1854,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor asinh (Tensor x, string name = "Asinh") + public static Tensor asinh(Tensor x, string name = "Asinh") { var dict = new Dictionary(); dict["x"] = x; @@ -1884,7 +1884,7 @@ namespace Tensorflow.Operations /// If condition evaluates to false, print the list of tensors in data. /// summarize determines how many entries of the tensors to print. /// - public static Operation assert (Tensor condition, Tensor[] data, int? summarize = null, string name = "Assert") + public static Operation assert(Tensor condition, Tensor[] data, int? summarize = null, string name = "Assert") { var dict = new Dictionary(); dict["condition"] = condition; @@ -1925,7 +1925,7 @@ namespace Tensorflow.Operations /// This operation outputs "ref" after the assignment is done. /// This makes it easier to chain operations that need to use the reset value. /// - public static Tensor assign (Tensor referecne, Tensor value, bool? validate_shape = null, bool? use_locking = null, string name = "Assign") + public static Tensor assign(Tensor referecne, Tensor value, bool? validate_shape = null, bool? use_locking = null, string name = "Assign") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -1963,7 +1963,7 @@ namespace Tensorflow.Operations /// This operation outputs "ref" after the update is done. /// This makes it easier to chain operations that need to use the reset value. /// - public static Tensor assign_add (Tensor referecne, Tensor value, bool? use_locking = null, string name = "AssignAdd") + public static Tensor assign_add(Tensor referecne, Tensor value, bool? use_locking = null, string name = "AssignAdd") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -1993,7 +1993,7 @@ namespace Tensorflow.Operations /// Any ReadVariableOp with a control dependency on this op is guaranteed to /// see the incremented value or a subsequent newer one. /// - public static Operation assign_add_variable_op (Tensor resource, Tensor value, string name = "AssignAddVariableOp") + public static Operation assign_add_variable_op(Tensor resource, Tensor value, string name = "AssignAddVariableOp") { var dict = new Dictionary(); dict["resource"] = resource; @@ -2027,7 +2027,7 @@ namespace Tensorflow.Operations /// This operation outputs "ref" after the update is done. /// This makes it easier to chain operations that need to use the reset value. /// - public static Tensor assign_sub (Tensor referecne, Tensor value, bool? use_locking = null, string name = "AssignSub") + public static Tensor assign_sub(Tensor referecne, Tensor value, bool? use_locking = null, string name = "AssignSub") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -2057,7 +2057,7 @@ namespace Tensorflow.Operations /// Any ReadVariableOp with a control dependency on this op is guaranteed to /// see the decremented value or a subsequent newer one. /// - public static Operation assign_sub_variable_op (Tensor resource, Tensor value, string name = "AssignSubVariableOp") + public static Operation assign_sub_variable_op(Tensor resource, Tensor value, string name = "AssignSubVariableOp") { var dict = new Dictionary(); dict["resource"] = resource; @@ -2085,7 +2085,7 @@ namespace Tensorflow.Operations /// Any ReadVariableOp with a control dependency on this op is guaranteed to return /// this value or a subsequent newer value of the variable. /// - public static Operation assign_variable_op (Tensor resource, Tensor value, string name = "AssignVariableOp") + public static Operation assign_variable_op(Tensor resource, Tensor value, string name = "AssignVariableOp") { var dict = new Dictionary(); dict["resource"] = resource; @@ -2105,7 +2105,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor atan (Tensor x, string name = "Atan") + public static Tensor atan(Tensor x, string name = "Atan") { var dict = new Dictionary(); dict["x"] = x; @@ -2133,7 +2133,7 @@ namespace Tensorflow.Operations /// \[ y = r \sin(\theta) \] /// where \(r = \sqrt(x^2 + y^2) \). /// - public static Tensor atan2 (Tensor y, Tensor x, string name = "Atan2") + public static Tensor atan2(Tensor y, Tensor x, string name = "Atan2") { var dict = new Dictionary(); dict["y"] = y; @@ -2153,7 +2153,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor atanh (Tensor x, string name = "Atanh") + public static Tensor atanh(Tensor x, string name = "Atanh") { var dict = new Dictionary(); dict["x"] = x; @@ -2214,7 +2214,7 @@ namespace Tensorflow.Operations /// tensorflow/examples/wav_to_spectrogram to read in an audio file and save out the /// resulting spectrogram as a PNG image. /// - public static Tensor audio_spectrogram (Tensor input, int window_size, int stride, bool? magnitude_squared = null, string name = "AudioSpectrogram") + public static Tensor audio_spectrogram(Tensor input, int window_size, int stride, bool? magnitude_squared = null, string name = "AudioSpectrogram") { var dict = new Dictionary(); dict["input"] = input; @@ -2262,7 +2262,7 @@ namespace Tensorflow.Operations /// * If max_outputs is greater than 1, the summary value tags are /// generated sequentially as '*tag*/audio/0', '*tag*/audio/1', etc. /// - public static Tensor audio_summary (Tensor tag, Tensor tensor, float sample_rate, int? max_outputs = null, string name = "AudioSummary") + public static Tensor audio_summary(Tensor tag, Tensor tensor, float sample_rate, int? max_outputs = null, string name = "AudioSummary") { var dict = new Dictionary(); dict["tag"] = tag; @@ -2309,7 +2309,7 @@ namespace Tensorflow.Operations /// * If max_outputs is greater than 1, the summary value tags are /// generated sequentially as '*tag*/audio/0', '*tag*/audio/1', etc. /// - public static Tensor audio_summary_v2 (Tensor tag, Tensor tensor, Tensor sample_rate, int? max_outputs = null, string name = "AudioSummaryV2") + public static Tensor audio_summary_v2(Tensor tag, Tensor tensor, Tensor sample_rate, int? max_outputs = null, string name = "AudioSummaryV2") { var dict = new Dictionary(); dict["tag"] = tag; @@ -2357,7 +2357,7 @@ namespace Tensorflow.Operations /// Each entry in output is the mean of the corresponding size ksize /// window in value. /// - public static Tensor avg_pool (Tensor value, int[] ksize, int[] strides, string padding, string data_format = null, string name = "AvgPool") + public static Tensor avg_pool(Tensor value, int[] ksize, int[] strides, string padding, string data_format = null, string name = "AvgPool") { var dict = new Dictionary(); dict["value"] = value; @@ -2404,7 +2404,7 @@ namespace Tensorflow.Operations /// The average pooled output tensor. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor avg_pool3d (Tensor input, int[] ksize, int[] strides, string padding, string data_format = null, string name = "AvgPool3D") + public static Tensor avg_pool3d(Tensor input, int[] ksize, int[] strides, string padding, string data_format = null, string name = "AvgPool3D") { var dict = new Dictionary(); dict["input"] = input; @@ -2454,7 +2454,7 @@ namespace Tensorflow.Operations /// The backprop for input. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor avg_pool3d_grad (Tensor orig_input_shape, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "AvgPool3DGrad") + public static Tensor avg_pool3d_grad(Tensor orig_input_shape, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "AvgPool3DGrad") { var dict = new Dictionary(); dict["orig_input_shape"] = orig_input_shape; @@ -2504,7 +2504,7 @@ namespace Tensorflow.Operations /// 4-D. Gradients w.r.t. the input of avg_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor avg_pool_grad (Tensor orig_input_shape, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "AvgPoolGrad") + public static Tensor avg_pool_grad(Tensor orig_input_shape, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "AvgPoolGrad") { var dict = new Dictionary(); dict["orig_input_shape"] = orig_input_shape; @@ -2559,7 +2559,7 @@ namespace Tensorflow.Operations /// incomplete element has some undefined components in its value tuple, /// and may be updated using BarrierInsertMany. /// - public static Tensor barrier (TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "Barrier") + public static Tensor barrier(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "Barrier") { var dict = new Dictionary(); dict["component_types"] = component_types; @@ -2600,7 +2600,7 @@ namespace Tensorflow.Operations /// continue to succeed if sufficient completed elements remain in the barrier. /// Subsequent TakeMany operations that would block will fail immediately. /// - public static Operation barrier_close (Tensor handle, bool? cancel_pending_enqueues = null, string name = "BarrierClose") + public static Operation barrier_close(Tensor handle, bool? cancel_pending_enqueues = null, string name = "BarrierClose") { var dict = new Dictionary(); dict["handle"] = handle; @@ -2624,7 +2624,7 @@ namespace Tensorflow.Operations /// components not set) in the barrier. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor barrier_incomplete_size (Tensor handle, string name = "BarrierIncompleteSize") + public static Tensor barrier_incomplete_size(Tensor handle, string name = "BarrierIncompleteSize") { var dict = new Dictionary(); dict["handle"] = handle; @@ -2661,7 +2661,7 @@ namespace Tensorflow.Operations /// already has a value at component_index, this operation will fail with /// INVALID_ARGUMENT, and leave the barrier in an undefined state. /// - public static Operation barrier_insert_many (Tensor handle, Tensor keys, Tensor values, int component_index, string name = "BarrierInsertMany") + public static Operation barrier_insert_many(Tensor handle, Tensor keys, Tensor values, int component_index, string name = "BarrierInsertMany") { var dict = new Dictionary(); dict["handle"] = handle; @@ -2686,7 +2686,7 @@ namespace Tensorflow.Operations /// components set) in the barrier. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor barrier_ready_size (Tensor handle, string name = "BarrierReadySize") + public static Tensor barrier_ready_size(Tensor handle, string name = "BarrierReadySize") { var dict = new Dictionary(); dict["handle"] = handle; @@ -2741,7 +2741,7 @@ namespace Tensorflow.Operations /// information about the batch in which each element was originally inserted /// into the barrier. /// - public static (Tensor indices, Tensor keys, Tensor[] values) barrier_take_many (Tensor handle, Tensor num_elements, TF_DataType[] component_types, bool? allow_small_batch = null, bool? wait_for_incomplete = null, int? timeout_ms = null, string name = "BarrierTakeMany") + public static (Tensor indices, Tensor keys, Tensor[] values) barrier_take_many(Tensor handle, Tensor num_elements, TF_DataType[] component_types, bool? allow_small_batch = null, bool? wait_for_incomplete = null, int? timeout_ms = null, string name = "BarrierTakeMany") { var dict = new Dictionary(); dict["handle"] = handle; @@ -2836,7 +2836,7 @@ namespace Tensorflow.Operations /// empty, the op name will be used as the shared name. /// T: the types of tensors to be batched. /// - public static (Tensor[] batched_tensors, Tensor batch_index, Tensor id) batch (Tensor[] in_tensors, int num_batch_threads, int max_batch_size, int batch_timeout_micros, int grad_timeout_micros, int? max_enqueued_batches = null, int[] allowed_batch_sizes = null, string container = null, string shared_name = null, string batching_queue = null, string name = "Batch") + public static (Tensor[] batched_tensors, Tensor batch_index, Tensor id) batch(Tensor[] in_tensors, int num_batch_threads, int max_batch_size, int batch_timeout_micros, int grad_timeout_micros, int? max_enqueued_batches = null, int[] allowed_batch_sizes = null, string container = null, string shared_name = null, string batching_queue = null, string name = "Batch") { var dict = new Dictionary(); dict["in_tensors"] = in_tensors; @@ -2883,7 +2883,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor batch_dataset (Tensor input_dataset, Tensor batch_size, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BatchDataset") + public static Tensor batch_dataset(Tensor input_dataset, Tensor batch_size, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BatchDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -2918,7 +2918,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor batch_dataset_v2 (Tensor input_dataset, Tensor batch_size, Tensor drop_remainder, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BatchDatasetV2") + public static Tensor batch_dataset_v2(Tensor input_dataset, Tensor batch_size, Tensor drop_remainder, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BatchDatasetV2") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -2972,7 +2972,7 @@ namespace Tensorflow.Operations /// /// output[..., :, :] = matrix(x[..., :, :]) * matrix(y[..., :, :]) /// - public static Tensor batch_mat_mul (Tensor x, Tensor y, bool? adj_x = null, bool? adj_y = null, string name = "BatchMatMul") + public static Tensor batch_mat_mul(Tensor x, Tensor y, bool? adj_x = null, bool? adj_y = null, string name = "BatchMatMul") { var dict = new Dictionary(); dict["x"] = x; @@ -3028,7 +3028,7 @@ namespace Tensorflow.Operations /// /// This op is deprecated. Prefer tf.nn.batch_normalization. /// - public static Tensor batch_norm_with_global_normalization (Tensor t, Tensor m, Tensor v, Tensor beta, Tensor gamma, float variance_epsilon, bool scale_after_normalization, string name = "BatchNormWithGlobalNormalization") + public static Tensor batch_norm_with_global_normalization(Tensor t, Tensor m, Tensor v, Tensor beta, Tensor gamma, float variance_epsilon, bool scale_after_normalization, string name = "BatchNormWithGlobalNormalization") { var dict = new Dictionary(); dict["t"] = t; @@ -3090,7 +3090,7 @@ namespace Tensorflow.Operations /// /// This op is deprecated. See tf.nn.batch_normalization. /// - public static (Tensor dx, Tensor dm, Tensor dv, Tensor db, Tensor dg) batch_norm_with_global_normalization_grad (Tensor t, Tensor m, Tensor v, Tensor gamma, Tensor backprop, float variance_epsilon, bool scale_after_normalization, string name = "BatchNormWithGlobalNormalizationGrad") + public static (Tensor dx, Tensor dm, Tensor dv, Tensor db, Tensor dg) batch_norm_with_global_normalization_grad(Tensor t, Tensor m, Tensor v, Tensor gamma, Tensor backprop, float variance_epsilon, bool scale_after_normalization, string name = "BatchNormWithGlobalNormalizationGrad") { var dict = new Dictionary(); dict["t"] = t; @@ -3211,7 +3211,7 @@ namespace Tensorflow.Operations /// dimension are moved in spatial blocks to the height and width dimensions, /// followed by cropping along the height and width dimensions. /// - public static Tensor batch_to_space (Tensor input, Tensor crops, int block_size, string name = "BatchToSpace") + public static Tensor batch_to_space(Tensor input, Tensor crops, int block_size, string name = "BatchToSpace") { var dict = new Dictionary(); dict["input"] = input; @@ -3356,7 +3356,7 @@ namespace Tensorflow.Operations /// optionally cropped according to crops to produce the output. This is the /// reverse of SpaceToBatch. See below for a precise description. /// - public static Tensor batch_to_space_n_d (Tensor input, Tensor block_shape, Tensor crops, string name = "BatchToSpaceND") + public static Tensor batch_to_space_n_d(Tensor input, Tensor block_shape, Tensor crops, string name = "BatchToSpaceND") { var dict = new Dictionary(); dict["input"] = input; @@ -3383,7 +3383,7 @@ namespace Tensorflow.Operations /// /// This function is faster and numerically stabler than bessel_i0(x). /// - public static Tensor bessel_i0e (Tensor x, string name = "BesselI0e") + public static Tensor bessel_i0e(Tensor x, string name = "BesselI0e") { var dict = new Dictionary(); dict["x"] = x; @@ -3408,7 +3408,7 @@ namespace Tensorflow.Operations /// /// This function is faster and numerically stabler than bessel_i1(x). /// - public static Tensor bessel_i1e (Tensor x, string name = "BesselI1e") + public static Tensor bessel_i1e(Tensor x, string name = "BesselI1e") { var dict = new Dictionary(); dict["x"] = x; @@ -3446,7 +3446,7 @@ namespace Tensorflow.Operations /// is the incomplete beta function and \\(B(a, b)\\) is the *complete* /// beta function. /// - public static Tensor betainc (Tensor a, Tensor b, Tensor x, string name = "Betainc") + public static Tensor betainc(Tensor a, Tensor b, Tensor x, string name = "Betainc") { var dict = new Dictionary(); dict["a"] = a; @@ -3485,7 +3485,7 @@ namespace Tensorflow.Operations /// This is a special case of tf.add where bias is restricted to be 1-D. /// Broadcasting is supported, so value may have any number of dimensions. /// - public static Tensor bias_add (Tensor value, Tensor bias, string data_format = null, string name = "BiasAdd") + public static Tensor bias_add(Tensor value, Tensor bias, string data_format = null, string name = "BiasAdd") { var dict = new Dictionary(); dict["value"] = value; @@ -3523,7 +3523,7 @@ namespace Tensorflow.Operations /// For NHWC data format, the feature dimension is the last. For NCHW data format, /// the feature dimension is the third-to-last. /// - public static Tensor bias_add_grad (Tensor out_backprop, string data_format = null, string name = "BiasAddGrad") + public static Tensor bias_add_grad(Tensor out_backprop, string data_format = null, string name = "BiasAddGrad") { var dict = new Dictionary(); dict["out_backprop"] = out_backprop; @@ -3555,7 +3555,7 @@ namespace Tensorflow.Operations /// This is a special case of tf.add where bias is restricted to be 1-D. /// Broadcasting is supported, so value may have any number of dimensions. /// - public static Tensor bias_add_v1 (Tensor value, Tensor bias, string name = "BiasAddV1") + public static Tensor bias_add_v1(Tensor value, Tensor bias, string name = "BiasAddV1") { var dict = new Dictionary(); dict["value"] = value; @@ -3595,7 +3595,7 @@ namespace Tensorflow.Operations /// /// Values in arr outside of the range [0, size) are ignored. /// - public static Tensor bincount (Tensor arr, Tensor size, Tensor weights, string name = "Bincount") + public static Tensor bincount(Tensor arr, Tensor size, Tensor weights, string name = "Bincount") { var dict = new Dictionary(); dict["arr"] = arr; @@ -3633,7 +3633,7 @@ namespace Tensorflow.Operations /// *NOTE*: Bitcast is implemented as a low-level cast, so machines with different /// endian orderings will give different results. /// - public static Tensor bitcast (Tensor input, TF_DataType type, string name = "Bitcast") + public static Tensor bitcast(Tensor input, TF_DataType type, string name = "Bitcast") { var dict = new Dictionary(); dict["input"] = input; @@ -3659,7 +3659,7 @@ namespace Tensorflow.Operations /// The result will have those bits set, that are set in both x and y. The /// computation is performed on the underlying representations of x and y. /// - public static Tensor bitwise_and (Tensor x, Tensor y, string name = "BitwiseAnd") + public static Tensor bitwise_and(Tensor x, Tensor y, string name = "BitwiseAnd") { var dict = new Dictionary(); dict["x"] = x; @@ -3685,7 +3685,7 @@ namespace Tensorflow.Operations /// The result will have those bits set, that are set in x, y or both. The /// computation is performed on the underlying representations of x and y. /// - public static Tensor bitwise_or (Tensor x, Tensor y, string name = "BitwiseOr") + public static Tensor bitwise_or(Tensor x, Tensor y, string name = "BitwiseOr") { var dict = new Dictionary(); dict["x"] = x; @@ -3711,7 +3711,7 @@ namespace Tensorflow.Operations /// The result will have those bits set, that are different in x and y. The /// computation is performed on the underlying representations of x and y. /// - public static Tensor bitwise_xor (Tensor x, Tensor y, string name = "BitwiseXor") + public static Tensor bitwise_xor(Tensor x, Tensor y, string name = "BitwiseXor") { var dict = new Dictionary(); dict["x"] = x; @@ -3767,7 +3767,7 @@ namespace Tensorflow.Operations /// The length of output lists are all of the same length, num_features. /// The output shapes are compatible in a way that the first dimension of all tensors of all lists are the same and equal to the number of possible split nodes for each feature. /// - public static (Tensor[] node_ids_list, Tensor[] gains_list, Tensor[] thresholds_list, Tensor[] left_node_contribs_list, Tensor[] right_node_contribs_list) boosted_trees_calculate_best_gains_per_feature (Tensor node_id_range, Tensor[] stats_summary_list, Tensor l1, Tensor l2, Tensor tree_complexity, Tensor min_node_weight, int max_splits, string name = "BoostedTreesCalculateBestGainsPerFeature") + public static (Tensor[] node_ids_list, Tensor[] gains_list, Tensor[] thresholds_list, Tensor[] left_node_contribs_list, Tensor[] right_node_contribs_list) boosted_trees_calculate_best_gains_per_feature(Tensor node_id_range, Tensor[] stats_summary_list, Tensor l1, Tensor l2, Tensor tree_complexity, Tensor min_node_weight, int max_splits, string name = "BoostedTreesCalculateBestGainsPerFeature") { var dict = new Dictionary(); dict["node_id_range"] = node_id_range; @@ -3812,7 +3812,7 @@ namespace Tensorflow.Operations /// Bool, whether to continue bias centering. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor boosted_trees_center_bias (Tensor tree_ensemble_handle, Tensor mean_gradients, Tensor mean_hessians, Tensor l1, Tensor l2, string name = "BoostedTreesCenterBias") + public static Tensor boosted_trees_center_bias(Tensor tree_ensemble_handle, Tensor mean_gradients, Tensor mean_hessians, Tensor l1, Tensor l2, string name = "BoostedTreesCenterBias") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -3842,7 +3842,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation boosted_trees_create_ensemble (Tensor tree_ensemble_handle, Tensor stamp_token, Tensor tree_ensemble_serialized, string name = "BoostedTreesCreateEnsemble") + public static Operation boosted_trees_create_ensemble(Tensor tree_ensemble_handle, Tensor stamp_token, Tensor tree_ensemble_serialized, string name = "BoostedTreesCreateEnsemble") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -3873,7 +3873,7 @@ namespace Tensorflow.Operations /// /// ensemble. /// - public static Operation boosted_trees_deserialize_ensemble (Tensor tree_ensemble_handle, Tensor stamp_token, Tensor tree_ensemble_serialized, string name = "BoostedTreesDeserializeEnsemble") + public static Operation boosted_trees_deserialize_ensemble(Tensor tree_ensemble_handle, Tensor stamp_token, Tensor tree_ensemble_serialized, string name = "BoostedTreesDeserializeEnsemble") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -3896,7 +3896,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor boosted_trees_ensemble_resource_handle_op (string container = null, string shared_name = null, string name = "BoostedTreesEnsembleResourceHandleOp") + public static Tensor boosted_trees_ensemble_resource_handle_op(string container = null, string shared_name = null, string name = "BoostedTreesEnsembleResourceHandleOp") { var dict = new Dictionary(); if (container != null) @@ -3933,7 +3933,7 @@ namespace Tensorflow.Operations /// such as getting split feature ids and logits after each split along the decision /// path used to compute directional feature contributions. /// - public static Tensor boosted_trees_example_debug_outputs (Tensor tree_ensemble_handle, Tensor[] bucketized_features, int logits_dimension, string name = "BoostedTreesExampleDebugOutputs") + public static Tensor boosted_trees_example_debug_outputs(Tensor tree_ensemble_handle, Tensor[] bucketized_features, int logits_dimension, string name = "BoostedTreesExampleDebugOutputs") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -3962,7 +3962,7 @@ namespace Tensorflow.Operations /// layer. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor stamp_token, Tensor num_trees, Tensor num_finalized_trees, Tensor num_attempted_layers, Tensor last_layer_nodes_range) boosted_trees_get_ensemble_states (Tensor tree_ensemble_handle, string name = "BoostedTreesGetEnsembleStates") + public static (Tensor stamp_token, Tensor num_trees, Tensor num_finalized_trees, Tensor num_attempted_layers, Tensor last_layer_nodes_range) boosted_trees_get_ensemble_states(Tensor tree_ensemble_handle, string name = "BoostedTreesGetEnsembleStates") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -4009,7 +4009,7 @@ namespace Tensorflow.Operations /// /// The summary stats contains gradients and hessians accumulated into the corresponding node and bucket for each example. /// - public static Tensor boosted_trees_make_stats_summary (Tensor node_ids, Tensor gradients, Tensor hessians, Tensor[] bucketized_features_list, int max_splits, int num_buckets, string name = "BoostedTreesMakeStatsSummary") + public static Tensor boosted_trees_make_stats_summary(Tensor node_ids, Tensor gradients, Tensor hessians, Tensor[] bucketized_features_list, int max_splits, int num_buckets, string name = "BoostedTreesMakeStatsSummary") { var dict = new Dictionary(); dict["node_ids"] = node_ids; @@ -4047,7 +4047,7 @@ namespace Tensorflow.Operations /// computes the logits. It is designed to be used during prediction. /// It traverses all the trees and calculates the final score for each instance. /// - public static Tensor boosted_trees_predict (Tensor tree_ensemble_handle, Tensor[] bucketized_features, int logits_dimension, string name = "BoostedTreesPredict") + public static Tensor boosted_trees_predict(Tensor tree_ensemble_handle, Tensor[] bucketized_features, int logits_dimension, string name = "BoostedTreesPredict") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -4072,7 +4072,7 @@ namespace Tensorflow.Operations /// tree_ensemble_serialized : Serialized proto of the ensemble. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor stamp_token, Tensor tree_ensemble_serialized) boosted_trees_serialize_ensemble (Tensor tree_ensemble_handle, string name = "BoostedTreesSerializeEnsemble") + public static (Tensor stamp_token, Tensor tree_ensemble_serialized) boosted_trees_serialize_ensemble(Tensor tree_ensemble_handle, string name = "BoostedTreesSerializeEnsemble") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -4121,7 +4121,7 @@ namespace Tensorflow.Operations /// It traverses the trees starting from cached tree id and cached node id and /// calculates the updates to be pushed to the cache. /// - public static (Tensor partial_logits, Tensor tree_ids, Tensor node_ids) boosted_trees_training_predict (Tensor tree_ensemble_handle, Tensor cached_tree_ids, Tensor cached_node_ids, Tensor[] bucketized_features, int logits_dimension, string name = "BoostedTreesTrainingPredict") + public static (Tensor partial_logits, Tensor tree_ids, Tensor node_ids) boosted_trees_training_predict(Tensor tree_ensemble_handle, Tensor cached_tree_ids, Tensor cached_node_ids, Tensor[] bucketized_features, int logits_dimension, string name = "BoostedTreesTrainingPredict") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -4188,7 +4188,7 @@ namespace Tensorflow.Operations /// /// or by starting a new tree. /// - public static Operation boosted_trees_update_ensemble (Tensor tree_ensemble_handle, Tensor feature_ids, Tensor[] node_ids, Tensor[] gains, Tensor[] thresholds, Tensor[] left_node_contribs, Tensor[] right_node_contribs, Tensor max_depth, Tensor learning_rate, int pruning_mode, string name = "BoostedTreesUpdateEnsemble") + public static Operation boosted_trees_update_ensemble(Tensor tree_ensemble_handle, Tensor feature_ids, Tensor[] node_ids, Tensor[] gains, Tensor[] thresholds, Tensor[] left_node_contribs, Tensor[] right_node_contribs, Tensor max_depth, Tensor learning_rate, int pruning_mode, string name = "BoostedTreesUpdateEnsemble") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -4222,7 +4222,7 @@ namespace Tensorflow.Operations /// Given s0 and s1, tensors that represent shapes, compute r0, the /// broadcasted shape. s0, s1 and r0 are all integer vectors. /// - public static Tensor broadcast_args (Tensor s0, Tensor s1, string name = "BroadcastArgs") + public static Tensor broadcast_args(Tensor s0, Tensor s1, string name = "BroadcastArgs") { var dict = new Dictionary(); dict["s0"] = s0; @@ -4250,7 +4250,7 @@ namespace Tensorflow.Operations /// /// This is typically used by gradient computations for a broadcasting operation. /// - public static (Tensor r0, Tensor r1) broadcast_gradient_args (Tensor s0, Tensor s1, string name = "BroadcastGradientArgs") + public static (Tensor r0, Tensor r1) broadcast_gradient_args(Tensor s0, Tensor s1, string name = "BroadcastGradientArgs") { var dict = new Dictionary(); dict["s0"] = s0; @@ -4297,7 +4297,7 @@ namespace Tensorflow.Operations /// In the above example, the input Tensor with the shape of [1, 3] /// is broadcasted to output Tensor with shape of [3, 3]. /// - public static Tensor broadcast_to (Tensor input, Tensor shape, string name = "BroadcastTo") + public static Tensor broadcast_to(Tensor input, Tensor shape, string name = "BroadcastTo") { var dict = new Dictionary(); dict["input"] = input; @@ -4339,7 +4339,7 @@ namespace Tensorflow.Operations /// [3, 2] /// [1, 3]] /// - public static Tensor bucketize (Tensor input, float[] boundaries, string name = "Bucketize") + public static Tensor bucketize(Tensor input, float[] boundaries, string name = "Bucketize") { var dict = new Dictionary(); dict["input"] = input; @@ -4367,7 +4367,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor bytes_produced_stats_dataset (Tensor input_dataset, Tensor tag, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BytesProducedStatsDataset") + public static Tensor bytes_produced_stats_dataset(Tensor input_dataset, Tensor tag, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BytesProducedStatsDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -4423,7 +4423,7 @@ namespace Tensorflow.Operations /// "A B" is returned if merge_repeated = True but "A B B B B" is /// returned if merge_repeated = False. /// - public static (Tensor[] decoded_indices, Tensor[] decoded_values, Tensor[] decoded_shape, Tensor log_probability) c_t_c_beam_search_decoder (Tensor inputs, Tensor sequence_length, int beam_width, int top_paths, bool? merge_repeated = null, string name = "CTCBeamSearchDecoder") + public static (Tensor[] decoded_indices, Tensor[] decoded_values, Tensor[] decoded_shape, Tensor log_probability) c_t_c_beam_search_decoder(Tensor inputs, Tensor sequence_length, int beam_width, int top_paths, bool? merge_repeated = null, string name = "CTCBeamSearchDecoder") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -4479,7 +4479,7 @@ namespace Tensorflow.Operations /// time and batch corresponds to the blank, index (num_classes - 1), no new /// element is emitted. /// - public static (Tensor decoded_indices, Tensor decoded_values, Tensor decoded_shape, Tensor log_probability) c_t_c_greedy_decoder (Tensor inputs, Tensor sequence_length, bool? merge_repeated = null, string name = "CTCGreedyDecoder") + public static (Tensor decoded_indices, Tensor decoded_values, Tensor decoded_shape, Tensor log_probability) c_t_c_greedy_decoder(Tensor inputs, Tensor sequence_length, bool? merge_repeated = null, string name = "CTCGreedyDecoder") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -4540,7 +4540,7 @@ namespace Tensorflow.Operations /// the gradient. This class performs the softmax operation for you, so inputs /// should be e.g. linear projections of outputs by an LSTM. /// - public static (Tensor loss, Tensor gradient) c_t_c_loss (Tensor inputs, Tensor labels_indices, Tensor labels_values, Tensor sequence_length, bool? preprocess_collapse_repeated = null, bool? ctc_merge_repeated = null, bool? ignore_longer_outputs_than_inputs = null, string name = "CTCLoss") + public static (Tensor loss, Tensor gradient) c_t_c_loss(Tensor inputs, Tensor labels_indices, Tensor labels_values, Tensor sequence_length, bool? preprocess_collapse_repeated = null, bool? ctc_merge_repeated = null, bool? ignore_longer_outputs_than_inputs = null, string name = "CTCLoss") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -4587,7 +4587,7 @@ namespace Tensorflow.Operations /// (e.g. cannot be opened, contains tensors of the wrong shape / size), an error /// will the returned when used. /// - public static Tensor cache_dataset (Tensor input_dataset, Tensor filename, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "CacheDataset") + public static Tensor cache_dataset(Tensor input_dataset, Tensor filename, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "CacheDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -4614,7 +4614,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor cast (Tensor x, TF_DataType DstT, bool? Truncate = null, string name = "Cast") + public static Tensor cast(Tensor x, TF_DataType DstT, bool? Truncate = null, string name = "Cast") { var dict = new Dictionary(); dict["x"] = x; @@ -4636,7 +4636,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor ceil (Tensor x, string name = "Ceil") + public static Tensor ceil(Tensor x, string name = "Ceil") { var dict = new Dictionary(); dict["x"] = x; @@ -4663,7 +4663,7 @@ namespace Tensorflow.Operations /// When run, reports an InvalidArgument error if tensor has any values /// that are not a number (NaN) or infinity (Inf). Otherwise, passes tensor as-is. /// - public static Tensor check_numerics (Tensor tensor, string message, string name = "CheckNumerics") + public static Tensor check_numerics(Tensor tensor, string message, string name = "CheckNumerics") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -4700,7 +4700,7 @@ namespace Tensorflow.Operations /// not for large batch dimensions when the submatrices are small. In this /// case it might be faster to use the CPU. /// - public static Tensor cholesky (Tensor input, string name = "Cholesky") + public static Tensor cholesky(Tensor input, string name = "Cholesky") { var dict = new Dictionary(); dict["input"] = input; @@ -4732,7 +4732,7 @@ namespace Tensorflow.Operations /// For an explanation see "Differentiation of the Cholesky algorithm" by /// Iain Murray http://arxiv.org/abs/1602.07527. /// - public static Tensor cholesky_grad (Tensor l, Tensor grad, string name = "CholeskyGrad") + public static Tensor cholesky_grad(Tensor l, Tensor grad, string name = "CholeskyGrad") { var dict = new Dictionary(); dict["l"] = l; @@ -4768,7 +4768,7 @@ namespace Tensorflow.Operations /// Any values less than clip_value_min are set to clip_value_min. Any values /// greater than clip_value_max are set to clip_value_max. /// - public static Tensor clip_by_value (Tensor t, Tensor clip_value_min, Tensor clip_value_max, string name = "ClipByValue") + public static Tensor clip_by_value(Tensor t, Tensor clip_value_min, Tensor clip_value_max, string name = "ClipByValue") { var dict = new Dictionary(); dict["t"] = t; @@ -4802,7 +4802,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor collective_bcast_recv (TF_DataType T, int group_size, int group_key, int instance_key, TensorShape shape, string name = "CollectiveBcastRecv") + public static Tensor collective_bcast_recv(TF_DataType T, int group_size, int group_key, int instance_key, TensorShape shape, string name = "CollectiveBcastRecv") { var dict = new Dictionary(); dict["T"] = T; @@ -4837,7 +4837,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor collective_bcast_send (Tensor input, int group_size, int group_key, int instance_key, TensorShape shape, string name = "CollectiveBcastSend") + public static Tensor collective_bcast_send(Tensor input, int group_size, int group_key, int instance_key, TensorShape shape, string name = "CollectiveBcastSend") { var dict = new Dictionary(); dict["input"] = input; @@ -4878,7 +4878,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor collective_reduce (Tensor input, int group_size, int group_key, int instance_key, string merge_op, string final_op, int[] subdiv_offsets, string name = "CollectiveReduce") + public static Tensor collective_reduce(Tensor input, int group_size, int group_key, int instance_key, string merge_op, string final_op, int[] subdiv_offsets, string name = "CollectiveReduce") { var dict = new Dictionary(); dict["input"] = input; @@ -4933,7 +4933,7 @@ namespace Tensorflow.Operations /// Given an input shaped [s0, s1, ..., s_n], the output is /// a uint8 tensor shaped [s0, s1, ..., s_n / 8]. /// - public static Tensor compare_and_bitpack (Tensor input, Tensor threshold, string name = "CompareAndBitpack") + public static Tensor compare_and_bitpack(Tensor input, Tensor threshold, string name = "CompareAndBitpack") { var dict = new Dictionary(); dict["input"] = input; @@ -4973,7 +4973,7 @@ namespace Tensorflow.Operations /// tf.complex(real, imag) ==&gt; [[2.25 + 4.75j], [3.25 + 5.75j]] /// /// - public static Tensor complex (Tensor real, Tensor imag, TF_DataType? Tout = null, string name = "Complex") + public static Tensor complex(Tensor real, Tensor imag, TF_DataType? Tout = null, string name = "Complex") { var dict = new Dictionary(); dict["real"] = real; @@ -5003,7 +5003,7 @@ namespace Tensorflow.Operations /// elements in x must be complex numbers of the form \\(a + bj\\). The absolute /// value is computed as \\( \sqrt{a^2 + b^2}\\). /// - public static Tensor complex_abs (Tensor x, TF_DataType? Tout = null, string name = "ComplexAbs") + public static Tensor complex_abs(Tensor x, TF_DataType? Tout = null, string name = "ComplexAbs") { var dict = new Dictionary(); dict["x"] = x; @@ -5052,7 +5052,7 @@ namespace Tensorflow.Operations /// the effect of 'removing' the sampled labels that match the true labels by /// making the classifier sure that they are sampled labels. /// - public static (Tensor indices, Tensor ids, Tensor weights) compute_accidental_hits (Tensor true_classes, Tensor sampled_candidates, int num_true, int? seed = null, int? seed2 = null, string name = "ComputeAccidentalHits") + public static (Tensor indices, Tensor ids, Tensor weights) compute_accidental_hits(Tensor true_classes, Tensor sampled_candidates, int num_true, int? seed = null, int? seed2 = null, string name = "ComputeAccidentalHits") { var dict = new Dictionary(); dict["true_classes"] = true_classes; @@ -5090,7 +5090,7 @@ namespace Tensorflow.Operations /// in concat_dim where it has the sum of the sizes. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor concat (Tensor concat_dim, Tensor[] values, string name = "Concat") + public static Tensor concat(Tensor concat_dim, Tensor[] values, string name = "Concat") { var dict = new Dictionary(); dict["concat_dim"] = concat_dim; @@ -5128,7 +5128,7 @@ namespace Tensorflow.Operations /// /// This is typically used by gradient computations for a concat operation. /// - public static Tensor[] concat_offset (Tensor concat_dim, Tensor[] shape, string name = "ConcatOffset") + public static Tensor[] concat_offset(Tensor concat_dim, Tensor[] shape, string name = "ConcatOffset") { var dict = new Dictionary(); dict["concat_dim"] = concat_dim; @@ -5159,7 +5159,7 @@ namespace Tensorflow.Operations /// in concat_dim where it has the sum of the sizes. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor concat_v2 (Tensor[] values, Tensor axis, string name = "ConcatV2") + public static Tensor concat_v2(Tensor[] values, Tensor axis, string name = "ConcatV2") { var dict = new Dictionary(); dict["values"] = values; @@ -5187,7 +5187,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor concatenate_dataset (Tensor input_dataset, Tensor another_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ConcatenateDataset") + public static Tensor concatenate_dataset(Tensor input_dataset, Tensor another_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ConcatenateDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -5232,7 +5232,7 @@ namespace Tensorflow.Operations /// resets the aggregate to 0, and increments the global_step recorded by /// the accumulator. /// - public static Tensor conditional_accumulator (TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "ConditionalAccumulator") + public static Tensor conditional_accumulator(TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "ConditionalAccumulator") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -5269,7 +5269,7 @@ namespace Tensorflow.Operations /// /// system. /// - public static Tensor configure_distributed_t_p_u (string embedding_config = null, string tpu_embedding_config = null, bool? is_global_init = null, string name = "ConfigureDistributedTPU") + public static Tensor configure_distributed_t_p_u(string embedding_config = null, string tpu_embedding_config = null, bool? is_global_init = null, string name = "ConfigureDistributedTPU") { var dict = new Dictionary(); if (embedding_config != null) @@ -5308,7 +5308,7 @@ namespace Tensorflow.Operations /// tf.conj(input) ==&gt; [-2.25 - 4.75j, 3.25 - 5.75j] /// /// - public static Tensor conj (Tensor input, string name = "Conj") + public static Tensor conj(Tensor input, string name = "Conj") { var dict = new Dictionary(); dict["input"] = input; @@ -5334,7 +5334,7 @@ namespace Tensorflow.Operations /// y.shape[i] == x.shape[perm[i]] for i in [0, 1, ..., rank(x) - 1] /// y[i,j,k,...,s,t,u] == conj(x[perm[i], perm[j], perm[k],...,perm[s], perm[t], perm[u]]) /// - public static Tensor conjugate_transpose (Tensor x, Tensor perm, string name = "ConjugateTranspose") + public static Tensor conjugate_transpose(Tensor x, Tensor perm, string name = "ConjugateTranspose") { var dict = new Dictionary(); dict["x"] = x; @@ -5359,7 +5359,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor constant (Tensor value, TF_DataType dtype, string name = "Const") + public static Tensor constant(Tensor value, TF_DataType dtype, string name = "Const") { var dict = new Dictionary(); dict["value"] = value; @@ -5389,7 +5389,7 @@ namespace Tensorflow.Operations /// **NOTE**: This operation must run on the same device as its input. This may /// be enforced via the colocate_with mechanism. /// - public static Operation consume_mutex_lock (Tensor mutex_lock, string name = "ConsumeMutexLock") + public static Operation consume_mutex_lock(Tensor mutex_lock, string name = "ConsumeMutexLock") { var dict = new Dictionary(); dict["mutex_lock"] = mutex_lock; @@ -5409,7 +5409,7 @@ namespace Tensorflow.Operations /// /// Only useful as a placeholder for control edges. /// - public static Operation control_trigger (string name = "ControlTrigger") + public static Operation control_trigger(string name = "ControlTrigger") { var dict = new Dictionary(); var op = tf.OpDefLib._apply_op_helper("ControlTrigger", name: name, keywords: dict); @@ -5484,7 +5484,7 @@ namespace Tensorflow.Operations /// Must have strides[0] = strides[3] = 1. For the most common case of the same /// horizontal and vertices strides, strides = [1, stride, stride, 1]. /// - public static Tensor conv2d (Tensor input, Tensor filter, int[] strides, string padding, bool? use_cudnn_on_gpu = null, string data_format = null, int[] dilations = null, string name = "Conv2D") + public static Tensor conv2d(Tensor input, Tensor filter, int[] strides, string padding, bool? use_cudnn_on_gpu = null, string data_format = null, int[] dilations = null, string name = "Conv2D") { var dict = new Dictionary(); dict["input"] = input; @@ -5551,7 +5551,7 @@ namespace Tensorflow.Operations /// the filter input of the convolution. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor conv2d_backprop_filter (Tensor input, Tensor filter_sizes, Tensor out_backprop, int[] strides, string padding, bool? use_cudnn_on_gpu = null, string data_format = null, int[] dilations = null, string name = "Conv2DBackpropFilter") + public static Tensor conv2d_backprop_filter(Tensor input, Tensor filter_sizes, Tensor out_backprop, int[] strides, string padding, bool? use_cudnn_on_gpu = null, string data_format = null, int[] dilations = null, string name = "Conv2DBackpropFilter") { var dict = new Dictionary(); dict["input"] = input; @@ -5618,7 +5618,7 @@ namespace Tensorflow.Operations /// w.r.t. the input of the convolution. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor conv2d_backprop_input (Tensor input_sizes, Tensor filter, Tensor out_backprop, int[] strides, string padding, bool? use_cudnn_on_gpu = null, string data_format = null, int[] dilations = null, string name = "Conv2DBackpropInput") + public static Tensor conv2d_backprop_input(Tensor input_sizes, Tensor filter, Tensor out_backprop, int[] strides, string padding, bool? use_cudnn_on_gpu = null, string data_format = null, int[] dilations = null, string name = "Conv2DBackpropInput") { var dict = new Dictionary(); dict["input_sizes"] = input_sizes; @@ -5682,7 +5682,7 @@ namespace Tensorflow.Operations /// /// Our Conv3D implements a form of cross-correlation. /// - public static Tensor conv3d (Tensor input, Tensor filter, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "Conv3D") + public static Tensor conv3d(Tensor input, Tensor filter, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "Conv3D") { var dict = new Dictionary(); dict["input"] = input; @@ -5728,7 +5728,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor conv3d_backprop_filter (Tensor input, Tensor filter, Tensor out_backprop, int[] strides, string padding, int[] dilations = null, string name = "Conv3DBackpropFilter") + public static Tensor conv3d_backprop_filter(Tensor input, Tensor filter, Tensor out_backprop, int[] strides, string padding, int[] dilations = null, string name = "Conv3DBackpropFilter") { var dict = new Dictionary(); dict["input"] = input; @@ -5787,7 +5787,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor conv3d_backprop_filter_v2 (Tensor input, Tensor filter_sizes, Tensor out_backprop, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "Conv3DBackpropFilterV2") + public static Tensor conv3d_backprop_filter_v2(Tensor input, Tensor filter_sizes, Tensor out_backprop, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "Conv3DBackpropFilterV2") { var dict = new Dictionary(); dict["input"] = input; @@ -5834,7 +5834,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor conv3d_backprop_input (Tensor input, Tensor filter, Tensor out_backprop, int[] strides, string padding, int[] dilations = null, string name = "Conv3DBackpropInput") + public static Tensor conv3d_backprop_input(Tensor input, Tensor filter, Tensor out_backprop, int[] strides, string padding, int[] dilations = null, string name = "Conv3DBackpropInput") { var dict = new Dictionary(); dict["input"] = input; @@ -5893,7 +5893,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor conv3d_backprop_input_v2 (Tensor input_sizes, Tensor filter, Tensor out_backprop, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "Conv3DBackpropInputV2") + public static Tensor conv3d_backprop_input_v2(Tensor input_sizes, Tensor filter, Tensor out_backprop, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "Conv3DBackpropInputV2") { var dict = new Dictionary(); dict["input_sizes"] = input_sizes; @@ -5942,7 +5942,7 @@ namespace Tensorflow.Operations /// Unlike the CopyHost Op, this op does not have HostMemory constraint on its /// input or output. /// - public static Tensor copy (Tensor input, string tensor_name = null, string[] debug_ops_spec = null, string name = "Copy") + public static Tensor copy(Tensor input, string tensor_name = null, string[] debug_ops_spec = null, string name = "Copy") { var dict = new Dictionary(); dict["input"] = input; @@ -5985,7 +5985,7 @@ namespace Tensorflow.Operations /// /// Unlike the Copy Op, this op has HostMemory constraint on its input or output. /// - public static Tensor copy_host (Tensor input, string tensor_name = null, string[] debug_ops_spec = null, string name = "CopyHost") + public static Tensor copy_host(Tensor input, string tensor_name = null, string[] debug_ops_spec = null, string name = "CopyHost") { var dict = new Dictionary(); dict["input"] = input; @@ -6008,7 +6008,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor cos (Tensor x, string name = "Cos") + public static Tensor cos(Tensor x, string name = "Cos") { var dict = new Dictionary(); dict["x"] = x; @@ -6027,7 +6027,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor cosh (Tensor x, string name = "Cosh") + public static Tensor cosh(Tensor x, string name = "Cosh") { var dict = new Dictionary(); dict["x"] = x; @@ -6054,7 +6054,7 @@ namespace Tensorflow.Operations /// input, the values produced will all be distinct. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor count_up_to (Tensor referecne, int limit, string name = "CountUpTo") + public static Tensor count_up_to(Tensor referecne, int limit, string name = "CountUpTo") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -6124,7 +6124,7 @@ namespace Tensorflow.Operations /// tf.image.resize_nearest_neighbor()(depends on the method argument) with /// align_corners=True. /// - public static Tensor crop_and_resize (Tensor image, Tensor boxes, Tensor box_ind, Tensor crop_size, string method = null, float? extrapolation_value = null, string name = "CropAndResize") + public static Tensor crop_and_resize(Tensor image, Tensor boxes, Tensor box_ind, Tensor crop_size, string method = null, float? extrapolation_value = null, string name = "CropAndResize") { var dict = new Dictionary(); dict["image"] = image; @@ -6176,7 +6176,7 @@ namespace Tensorflow.Operations /// A 2-D tensor of shape [num_boxes, 4]. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor crop_and_resize_grad_boxes (Tensor grads, Tensor image, Tensor boxes, Tensor box_ind, string method = null, string name = "CropAndResizeGradBoxes") + public static Tensor crop_and_resize_grad_boxes(Tensor grads, Tensor image, Tensor boxes, Tensor box_ind, string method = null, string name = "CropAndResizeGradBoxes") { var dict = new Dictionary(); dict["grads"] = grads; @@ -6230,7 +6230,7 @@ namespace Tensorflow.Operations /// A 4-D tensor of shape [batch, image_height, image_width, depth]. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor crop_and_resize_grad_image (Tensor grads, Tensor boxes, Tensor box_ind, Tensor image_size, TF_DataType T, string method = null, string name = "CropAndResizeGradImage") + public static Tensor crop_and_resize_grad_image(Tensor grads, Tensor boxes, Tensor box_ind, Tensor image_size, TF_DataType T, string method = null, string name = "CropAndResizeGradImage") { var dict = new Dictionary(); dict["grads"] = grads; @@ -6265,7 +6265,7 @@ namespace Tensorflow.Operations /// or any shape where the innermost dimension is 3. In the latter case, each pair /// of corresponding 3-element vectors is cross-multiplied independently. /// - public static Tensor cross (Tensor a, Tensor b, string name = "Cross") + public static Tensor cross(Tensor a, Tensor b, string name = "Cross") { var dict = new Dictionary(); dict["a"] = a; @@ -6302,7 +6302,7 @@ namespace Tensorflow.Operations /// and B, D, F, H as group 1. Thus we get the outputs: /// [A+C+E+G, B+D+F+H, A+C+E+G, B+D+F+H, A+C+E+G, B+D+F+H, A+C+E+G, B+D+F+H]. /// - public static Tensor cross_replica_sum (Tensor input, Tensor group_assignment, string name = "CrossReplicaSum") + public static Tensor cross_replica_sum(Tensor input, Tensor group_assignment, string name = "CrossReplicaSum") { var dict = new Dictionary(); dict["input"] = input; @@ -6379,7 +6379,7 @@ namespace Tensorflow.Operations /// reserve_space: An opaque tensor that can be used in backprop calculation. It /// is only produced if is_training is false. /// - public static (Tensor output, Tensor output_h, Tensor output_c, Tensor reserve_space) cudnn_r_n_n (Tensor input, Tensor input_h, Tensor input_c, Tensor parameters, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, bool? is_training = null, string name = "CudnnRNN") + public static (Tensor output, Tensor output_h, Tensor output_c, Tensor reserve_space) cudnn_r_n_n(Tensor input, Tensor input_h, Tensor input_c, Tensor parameters, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, bool? is_training = null, string name = "CudnnRNN") { var dict = new Dictionary(); dict["input"] = input; @@ -6498,7 +6498,7 @@ namespace Tensorflow.Operations /// params_backprop: The backprop to the params buffer in the forward pass. Has the /// same shape as params. /// - public static (Tensor input_backprop, Tensor input_h_backprop, Tensor input_c_backprop, Tensor params_backprop) cudnn_r_n_n_backprop (Tensor input, Tensor input_h, Tensor input_c, Tensor parameters, Tensor output, Tensor output_h, Tensor output_c, Tensor output_backprop, Tensor output_h_backprop, Tensor output_c_backprop, Tensor reserve_space, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNBackprop") + public static (Tensor input_backprop, Tensor input_h_backprop, Tensor input_c_backprop, Tensor params_backprop) cudnn_r_n_n_backprop(Tensor input, Tensor input_h, Tensor input_c, Tensor parameters, Tensor output, Tensor output_h, Tensor output_c, Tensor output_backprop, Tensor output_h_backprop, Tensor output_c_backprop, Tensor reserve_space, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNBackprop") { var dict = new Dictionary(); dict["input"] = input; @@ -6627,7 +6627,7 @@ namespace Tensorflow.Operations /// params_backprop: The backprop to the params buffer in the forward pass. Has the /// same shape as params. /// - public static (Tensor input_backprop, Tensor input_h_backprop, Tensor input_c_backprop, Tensor params_backprop) cudnn_r_n_n_backprop_v2 (Tensor input, Tensor input_h, Tensor input_c, Tensor parameters, Tensor output, Tensor output_h, Tensor output_c, Tensor output_backprop, Tensor output_h_backprop, Tensor output_c_backprop, Tensor reserve_space, Tensor host_reserved, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNBackpropV2") + public static (Tensor input_backprop, Tensor input_h_backprop, Tensor input_c_backprop, Tensor params_backprop) cudnn_r_n_n_backprop_v2(Tensor input, Tensor input_h, Tensor input_c, Tensor parameters, Tensor output, Tensor output_h, Tensor output_c, Tensor output_backprop, Tensor output_h_backprop, Tensor output_c_backprop, Tensor reserve_space, Tensor host_reserved, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNBackpropV2") { var dict = new Dictionary(); dict["input"] = input; @@ -6725,7 +6725,7 @@ namespace Tensorflow.Operations /// seed: the 1st part of a seed to initialize dropout. /// seed2: the 2nd part of a seed to initialize dropout. /// - public static Tensor cudnn_r_n_n_canonical_to_params (Tensor num_layers, Tensor num_units, Tensor input_size, Tensor[] weights, Tensor[] biases, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNCanonicalToParams") + public static Tensor cudnn_r_n_n_canonical_to_params(Tensor num_layers, Tensor num_units, Tensor input_size, Tensor[] weights, Tensor[] biases, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNCanonicalToParams") { var dict = new Dictionary(); dict["num_layers"] = num_layers; @@ -6805,7 +6805,7 @@ namespace Tensorflow.Operations /// CudnnRNNParamsBiases to save and restore them in a way that is compatible /// across different runs. /// - public static Tensor cudnn_r_n_n_params_size (Tensor num_layers, Tensor num_units, Tensor input_size, TF_DataType T, TF_DataType S, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNParamsSize") + public static Tensor cudnn_r_n_n_params_size(Tensor num_layers, Tensor num_units, Tensor input_size, TF_DataType T, TF_DataType S, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNParamsSize") { var dict = new Dictionary(); dict["num_layers"] = num_layers; @@ -6895,7 +6895,7 @@ namespace Tensorflow.Operations /// seed: the 1st part of a seed to initialize dropout. /// seed2: the 2nd part of a seed to initialize dropout. /// - public static (Tensor[] weights, Tensor[] biases) cudnn_r_n_n_params_to_canonical (Tensor num_layers, Tensor num_units, Tensor input_size, Tensor parameters, int num_params, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNParamsToCanonical") + public static (Tensor[] weights, Tensor[] biases) cudnn_r_n_n_params_to_canonical(Tensor num_layers, Tensor num_units, Tensor input_size, Tensor parameters, int num_params, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, string name = "CudnnRNNParamsToCanonical") { var dict = new Dictionary(); dict["num_layers"] = num_layers; @@ -6994,7 +6994,7 @@ namespace Tensorflow.Operations /// only produced if is_training is true. It is output on host memory rather than /// device memory. /// - public static (Tensor output, Tensor output_h, Tensor output_c, Tensor reserve_space, Tensor host_reserved) cudnn_r_n_n_v2 (Tensor input, Tensor input_h, Tensor input_c, Tensor parameters, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, bool? is_training = null, string name = "CudnnRNNV2") + public static (Tensor output, Tensor output_h, Tensor output_c, Tensor reserve_space, Tensor host_reserved) cudnn_r_n_n_v2(Tensor input, Tensor input_h, Tensor input_c, Tensor parameters, string rnn_mode = null, string input_mode = null, string direction = null, float? dropout = null, int? seed = null, int? seed2 = null, bool? is_training = null, string name = "CudnnRNNV2") { var dict = new Dictionary(); dict["input"] = input; @@ -7079,7 +7079,7 @@ namespace Tensorflow.Operations /// tf.cumprod([a, b, c], exclusive=True, reverse=True) # =&gt; [b * c, c, 1] /// /// - public static Tensor cumprod (Tensor x, Tensor axis, bool? exclusive = null, bool? reverse = null, string name = "Cumprod") + public static Tensor cumprod(Tensor x, Tensor axis, bool? exclusive = null, bool? reverse = null, string name = "Cumprod") { var dict = new Dictionary(); dict["x"] = x; @@ -7146,7 +7146,7 @@ namespace Tensorflow.Operations /// tf.cumsum([a, b, c], exclusive=True, reverse=True) # =&gt; [b + c, c, 0] /// /// - public static Tensor cumsum (Tensor x, Tensor axis, bool? exclusive = null, bool? reverse = null, string name = "Cumsum") + public static Tensor cumsum(Tensor x, Tensor axis, bool? exclusive = null, bool? reverse = null, string name = "Cumsum") { var dict = new Dictionary(); dict["x"] = x; @@ -7182,7 +7182,7 @@ namespace Tensorflow.Operations /// /// the source data format. /// - public static Tensor data_format_dim_map (Tensor x, string src_format = null, string dst_format = null, string name = "DataFormatDimMap") + public static Tensor data_format_dim_map(Tensor x, string src_format = null, string dst_format = null, string name = "DataFormatDimMap") { var dict = new Dictionary(); dict["x"] = x; @@ -7216,7 +7216,7 @@ namespace Tensorflow.Operations /// /// one in the source data format. /// - public static Tensor data_format_vec_permute (Tensor x, string src_format = null, string dst_format = null, string name = "DataFormatVecPermute") + public static Tensor data_format_vec_permute(Tensor x, string src_format = null, string dst_format = null, string name = "DataFormatVecPermute") { var dict = new Dictionary(); dict["x"] = x; @@ -7244,7 +7244,7 @@ namespace Tensorflow.Operations /// /// Returns a graph representation for input_dataset. /// - public static Tensor dataset_to_graph (Tensor input_dataset, string name = "DatasetToGraph") + public static Tensor dataset_to_graph(Tensor input_dataset, string name = "DatasetToGraph") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -7271,7 +7271,7 @@ namespace Tensorflow.Operations /// The components of the single element of input. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor[] dataset_to_single_element (Tensor dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "DatasetToSingleElement") + public static Tensor[] dataset_to_single_element(Tensor dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "DatasetToSingleElement") { var dict = new Dictionary(); dict["dataset"] = dataset; @@ -7302,7 +7302,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation dataset_to_t_f_record (Tensor input_dataset, Tensor filename, Tensor compression_type, string name = "DatasetToTFRecord") + public static Operation dataset_to_t_f_record(Tensor input_dataset, Tensor filename, Tensor compression_type, string name = "DatasetToTFRecord") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -7328,7 +7328,7 @@ namespace Tensorflow.Operations /// register gradient tensors for gradient debugging. /// This op operates on non-reference-type tensors. /// - public static Tensor debug_gradient_identity (Tensor input, string name = "DebugGradientIdentity") + public static Tensor debug_gradient_identity(Tensor input, string name = "DebugGradientIdentity") { var dict = new Dictionary(); dict["input"] = input; @@ -7352,7 +7352,7 @@ namespace Tensorflow.Operations /// register gradient tensors for gradient debugging. /// This op operates on reference-type tensors. /// - public static Tensor debug_gradient_ref_identity (Tensor input, string name = "DebugGradientRefIdentity") + public static Tensor debug_gradient_ref_identity(Tensor input, string name = "DebugGradientRefIdentity") { var dict = new Dictionary(); dict["input"] = input; @@ -7393,7 +7393,7 @@ namespace Tensorflow.Operations /// /// Provides an identity mapping of the non-Ref type input tensor for debugging. /// - public static Tensor debug_identity (Tensor input, string device_name = null, string tensor_name = null, string[] debug_urls = null, bool? gated_grpc = null, string name = "DebugIdentity") + public static Tensor debug_identity(Tensor input, string device_name = null, string tensor_name = null, string[] debug_urls = null, bool? gated_grpc = null, string name = "DebugIdentity") { var dict = new Dictionary(); dict["input"] = input; @@ -7442,7 +7442,7 @@ namespace Tensorflow.Operations /// /// Counts number of NaNs in the input tensor, for debugging. /// - public static Tensor debug_nan_count (Tensor input, string device_name = null, string tensor_name = null, string[] debug_urls = null, bool? gated_grpc = null, string name = "DebugNanCount") + public static Tensor debug_nan_count(Tensor input, string device_name = null, string tensor_name = null, string[] debug_urls = null, bool? gated_grpc = null, string name = "DebugNanCount") { var dict = new Dictionary(); dict["input"] = input; @@ -7530,7 +7530,7 @@ namespace Tensorflow.Operations /// /// Provide a basic summary of numeric value types, range and distribution. /// - public static Tensor debug_numeric_summary (Tensor input, string device_name = null, string tensor_name = null, string[] debug_urls = null, float? lower_bound = null, float? upper_bound = null, bool? mute_if_healthy = null, bool? gated_grpc = null, string name = "DebugNumericSummary") + public static Tensor debug_numeric_summary(Tensor input, string device_name = null, string tensor_name = null, string[] debug_urls = null, float? lower_bound = null, float? upper_bound = null, bool? mute_if_healthy = null, bool? gated_grpc = null, string name = "DebugNumericSummary") { var dict = new Dictionary(); dict["input"] = input; @@ -7614,7 +7614,7 @@ namespace Tensorflow.Operations /// It is equivalent to a combination of decode and crop, but much faster by only /// decoding partial jpeg image. /// - public static Tensor decode_and_crop_jpeg (Tensor contents, Tensor crop_window, int? channels = null, int? ratio = null, bool? fancy_upscaling = null, bool? try_recover_truncated = null, float? acceptable_fraction = null, string dct_method = null, string name = "DecodeAndCropJpeg") + public static Tensor decode_and_crop_jpeg(Tensor contents, Tensor crop_window, int? channels = null, int? ratio = null, bool? fancy_upscaling = null, bool? try_recover_truncated = null, float? acceptable_fraction = null, string dct_method = null, string name = "DecodeAndCropJpeg") { var dict = new Dictionary(); dict["contents"] = contents; @@ -7652,7 +7652,7 @@ namespace Tensorflow.Operations /// Input may or may not have padding at the end. See EncodeBase64 for padding. /// Web-safe means that input must use - and _ instead of + and /. /// - public static Tensor decode_base64 (Tensor input, string name = "DecodeBase64") + public static Tensor decode_base64(Tensor input, string name = "DecodeBase64") { var dict = new Dictionary(); dict["input"] = input; @@ -7685,7 +7685,7 @@ namespace Tensorflow.Operations /// * 3: output an RGB image. /// * 4: output an RGBA image. /// - public static Tensor decode_bmp (Tensor contents, int? channels = null, string name = "DecodeBmp") + public static Tensor decode_bmp(Tensor contents, int? channels = null, string name = "DecodeBmp") { var dict = new Dictionary(); dict["contents"] = contents; @@ -7732,7 +7732,7 @@ namespace Tensorflow.Operations /// (https://tools.ietensorflow.org/html/rfc4180) /// Note that we allow leading and trailing spaces with int or float field. /// - public static Tensor[] decode_c_s_v (Tensor records, Tensor[] record_defaults, string field_delim = null, bool? use_quote_delim = null, string na_value = null, int[] select_cols = null, string name = "DecodeCSV") + public static Tensor[] decode_c_s_v(Tensor records, Tensor[] record_defaults, string field_delim = null, bool? use_quote_delim = null, string na_value = null, int[] select_cols = null, string name = "DecodeCSV") { var dict = new Dictionary(); dict["records"] = records; @@ -7777,7 +7777,7 @@ namespace Tensorflow.Operations /// each element containing the decompressed data from the corresponding /// element in bytes. /// - public static Tensor decode_compressed (Tensor bytes, string compression_type = null, string name = "DecodeCompressed") + public static Tensor decode_compressed(Tensor bytes, string compression_type = null, string name = "DecodeCompressed") { var dict = new Dictionary(); dict["bytes"] = bytes; @@ -7809,7 +7809,7 @@ namespace Tensorflow.Operations /// This op also supports decoding JPEGs and PNGs, though it is cleaner to use /// tf.image.decode_image. /// - public static Tensor decode_gif (Tensor contents, string name = "DecodeGif") + public static Tensor decode_gif(Tensor contents, string name = "DecodeGif") { var dict = new Dictionary(); dict["contents"] = contents; @@ -7840,7 +7840,7 @@ namespace Tensorflow.Operations /// buffers. The resulting tensor can then be fed to any of the other /// Example-parsing ops. /// - public static Tensor decode_j_s_o_n_example (Tensor json_examples, string name = "DecodeJSONExample") + public static Tensor decode_j_s_o_n_example(Tensor json_examples, string name = "DecodeJSONExample") { var dict = new Dictionary(); dict["json_examples"] = json_examples; @@ -7907,7 +7907,7 @@ namespace Tensorflow.Operations /// This op also supports decoding PNGs and non-animated GIFs since the interface is /// the same, though it is cleaner to use tf.image.decode_image. /// - public static Tensor decode_jpeg (Tensor contents, int? channels = null, int? ratio = null, bool? fancy_upscaling = null, bool? try_recover_truncated = null, float? acceptable_fraction = null, string dct_method = null, string name = "DecodeJpeg") + public static Tensor decode_jpeg(Tensor contents, int? channels = null, int? ratio = null, bool? fancy_upscaling = null, bool? try_recover_truncated = null, float? acceptable_fraction = null, string dct_method = null, string name = "DecodeJpeg") { var dict = new Dictionary(); dict["contents"] = contents; @@ -7962,7 +7962,7 @@ namespace Tensorflow.Operations /// This op also supports decoding JPEGs and non-animated GIFs since the interface /// is the same, though it is cleaner to use tf.image.decode_image. /// - public static Tensor decode_png (Tensor contents, int? channels = null, TF_DataType? dtype = null, string name = "DecodePng") + public static Tensor decode_png(Tensor contents, int? channels = null, TF_DataType? dtype = null, string name = "DecodePng") { var dict = new Dictionary(); dict["contents"] = contents; @@ -8066,7 +8066,7 @@ namespace Tensorflow.Operations /// Both binary and text proto serializations are supported, and can be /// chosen using the format attribute. /// - public static (Tensor sizes, Tensor[] values) decode_proto_v2 (Tensor bytes, string message_type, string[] field_names, TF_DataType[] output_types, string descriptor_source = null, string message_format = null, bool? sanitize = null, string name = "DecodeProtoV2") + public static (Tensor sizes, Tensor[] values) decode_proto_v2(Tensor bytes, string message_type, string[] field_names, TF_DataType[] output_types, string descriptor_source = null, string message_format = null, bool? sanitize = null, string name = "DecodeProtoV2") { var dict = new Dictionary(); dict["bytes"] = bytes; @@ -8109,7 +8109,7 @@ namespace Tensorflow.Operations /// of bytes divided by the number of bytes to represent out_type. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor decode_raw (Tensor bytes, TF_DataType out_type, bool? little_endian = null, string name = "DecodeRaw") + public static Tensor decode_raw(Tensor bytes, TF_DataType out_type, bool? little_endian = null, string name = "DecodeRaw") { var dict = new Dictionary(); dict["bytes"] = bytes; @@ -8157,7 +8157,7 @@ namespace Tensorflow.Operations /// number of samples. For example, a ten-sample-long stereo WAV file should give an /// output shape of [10, 2]. /// - public static (Tensor audio, Tensor sample_rate) decode_wav (Tensor contents, int? desired_channels = null, int? desired_samples = null, string name = "DecodeWav") + public static (Tensor audio, Tensor sample_rate) decode_wav(Tensor contents, int? desired_channels = null, int? desired_samples = null, string name = "DecodeWav") { var dict = new Dictionary(); dict["contents"] = contents; @@ -8186,7 +8186,7 @@ namespace Tensorflow.Operations /// is not an alias of x. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor deep_copy (Tensor x, string name = "DeepCopy") + public static Tensor deep_copy(Tensor x, string name = "DeepCopy") { var dict = new Dictionary(); dict["x"] = x; @@ -8206,7 +8206,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation delete_session_tensor (Tensor handle, string name = "DeleteSessionTensor") + public static Operation delete_session_tensor(Tensor handle, string name = "DeleteSessionTensor") { var dict = new Dictionary(); dict["handle"] = handle; @@ -8251,7 +8251,7 @@ namespace Tensorflow.Operations /// dimension contains the result of set_operation applied to the corresponding /// [0...n-1] dimension of set. /// - public static (Tensor result_indices, Tensor result_values, Tensor result_shape) dense_to_dense_set_operation (Tensor set1, Tensor set2, string set_operation, bool? validate_indices = null, string name = "DenseToDenseSetOperation") + public static (Tensor result_indices, Tensor result_values, Tensor result_shape) dense_to_dense_set_operation(Tensor set1, Tensor set2, string set_operation, bool? validate_indices = null, string name = "DenseToDenseSetOperation") { var dict = new Dictionary(); dict["set1"] = set1; @@ -8294,7 +8294,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor dense_to_sparse_batch_dataset (Tensor input_dataset, Tensor batch_size, Tensor row_shape, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "DenseToSparseBatchDataset") + public static Tensor dense_to_sparse_batch_dataset(Tensor input_dataset, Tensor batch_size, Tensor row_shape, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "DenseToSparseBatchDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -8360,7 +8360,7 @@ namespace Tensorflow.Operations /// dimension contains the result of set_operation applied to the corresponding /// [0...n-1] dimension of set. /// - public static (Tensor result_indices, Tensor result_values, Tensor result_shape) dense_to_sparse_set_operation (Tensor set1, Tensor set2_indices, Tensor set2_values, Tensor set2_shape, string set_operation, bool? validate_indices = null, string name = "DenseToSparseSetOperation") + public static (Tensor result_indices, Tensor result_values, Tensor result_shape) dense_to_sparse_set_operation(Tensor set1, Tensor set2_indices, Tensor set2_values, Tensor set2_shape, string set_operation, bool? validate_indices = null, string name = "DenseToSparseSetOperation") { var dict = new Dictionary(); dict["set1"] = set1; @@ -8486,7 +8486,7 @@ namespace Tensorflow.Operations /// /// /// - public static Tensor depth_to_space (Tensor input, int block_size, string data_format = null, string name = "DepthToSpace") + public static Tensor depth_to_space(Tensor input, int block_size, string data_format = null, string name = "DepthToSpace") { var dict = new Dictionary(); dict["input"] = input; @@ -8553,7 +8553,7 @@ namespace Tensorflow.Operations /// Must have strides[0] = strides[3] = 1. For the most common case of the same /// horizontal and vertices strides, strides = [1, stride, stride, 1]. /// - public static Tensor depthwise_conv2d_native (Tensor input, Tensor filter, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "DepthwiseConv2dNative") + public static Tensor depthwise_conv2d_native(Tensor input, Tensor filter, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "DepthwiseConv2dNative") { var dict = new Dictionary(); dict["input"] = input; @@ -8619,7 +8619,7 @@ namespace Tensorflow.Operations /// the filter input of the convolution. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor depthwise_conv2d_native_backprop_filter (Tensor input, Tensor filter_sizes, Tensor out_backprop, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "DepthwiseConv2dNativeBackpropFilter") + public static Tensor depthwise_conv2d_native_backprop_filter(Tensor input, Tensor filter_sizes, Tensor out_backprop, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "DepthwiseConv2dNativeBackpropFilter") { var dict = new Dictionary(); dict["input"] = input; @@ -8686,7 +8686,7 @@ namespace Tensorflow.Operations /// convolution. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor depthwise_conv2d_native_backprop_input (Tensor input_sizes, Tensor filter, Tensor out_backprop, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "DepthwiseConv2dNativeBackpropInput") + public static Tensor depthwise_conv2d_native_backprop_input(Tensor input_sizes, Tensor filter, Tensor out_backprop, int[] strides, string padding, string data_format = null, int[] dilations = null, string name = "DepthwiseConv2dNativeBackpropInput") { var dict = new Dictionary(); dict["input_sizes"] = input_sizes; @@ -8796,7 +8796,7 @@ namespace Tensorflow.Operations /// result = input * s /// /// - public static Tensor dequantize (Tensor input, Tensor min_range, Tensor max_range, string mode = null, string name = "Dequantize") + public static Tensor dequantize(Tensor input, Tensor min_range, Tensor max_range, string mode = null, string name = "Dequantize") { var dict = new Dictionary(); dict["input"] = input; @@ -8824,7 +8824,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation deserialize_iterator (Tensor resource_handle, Tensor serialized, string name = "DeserializeIterator") + public static Operation deserialize_iterator(Tensor resource_handle, Tensor serialized, string name = "DeserializeIterator") { var dict = new Dictionary(); dict["resource_handle"] = resource_handle; @@ -8897,7 +8897,7 @@ namespace Tensorflow.Operations /// values = [1, 2, 3, 4, 5] /// shape = [2 50] /// - public static (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape) deserialize_many_sparse (Tensor serialized_sparse, TF_DataType dtype, string name = "DeserializeManySparse") + public static (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape) deserialize_many_sparse(Tensor serialized_sparse, TF_DataType dtype, string name = "DeserializeManySparse") { var dict = new Dictionary(); dict["serialized_sparse"] = serialized_sparse; @@ -8974,7 +8974,7 @@ namespace Tensorflow.Operations /// values = [1, 2, 3, 4, 5] /// shape = [2 50] /// - public static (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape) deserialize_sparse (Tensor serialized_sparse, TF_DataType dtype, string name = "DeserializeSparse") + public static (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape) deserialize_sparse(Tensor serialized_sparse, TF_DataType dtype, string name = "DeserializeSparse") { var dict = new Dictionary(); dict["serialized_sparse"] = serialized_sparse; @@ -9007,7 +9007,7 @@ namespace Tensorflow.Operations /// All subsequent operations using the resource will result in a NotFound /// error status. /// - public static Operation destroy_resource_op (Tensor resource, bool? ignore_lookup_error = null, string name = "DestroyResourceOp") + public static Operation destroy_resource_op(Tensor resource, bool? ignore_lookup_error = null, string name = "DestroyResourceOp") { var dict = new Dictionary(); dict["resource"] = resource; @@ -9043,7 +9043,7 @@ namespace Tensorflow.Operations /// /// Outputs the final value of the tensor pointed to by 'ref'. /// - public static Tensor destroy_temporary_variable (Tensor referecne, string var_name, string name = "DestroyTemporaryVariable") + public static Tensor destroy_temporary_variable(Tensor referecne, string var_name, string name = "DestroyTemporaryVariable") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -9083,7 +9083,7 @@ namespace Tensorflow.Operations /// [0, 0, 0, 4]] /// /// - public static Tensor diag (Tensor diagonal, string name = "Diag") + public static Tensor diag(Tensor diagonal, string name = "Diag") { var dict = new Dictionary(); dict["diagonal"] = diagonal; @@ -9124,7 +9124,7 @@ namespace Tensorflow.Operations /// tf.diag_part(input) ==&gt; [1, 2, 3, 4] /// /// - public static Tensor diag_part (Tensor input, string name = "DiagPart") + public static Tensor diag_part(Tensor input, string name = "DiagPart") { var dict = new Dictionary(); dict["input"] = input; @@ -9146,7 +9146,7 @@ namespace Tensorflow.Operations /// /// Gamma(x)), element-wise. /// - public static Tensor digamma (Tensor x, string name = "Digamma") + public static Tensor digamma(Tensor x, string name = "Digamma") { var dict = new Dictionary(); dict["x"] = x; @@ -9209,7 +9209,7 @@ namespace Tensorflow.Operations /// Note on duality: The dilation of input by the filter is equal to the /// negation of the erosion of -input by the reflected filter. /// - public static Tensor dilation2d (Tensor input, Tensor filter, int[] strides, int[] rates, string padding, string name = "Dilation2D") + public static Tensor dilation2d(Tensor input, Tensor filter, int[] strides, int[] rates, string padding, string name = "Dilation2D") { var dict = new Dictionary(); dict["input"] = input; @@ -9254,7 +9254,7 @@ namespace Tensorflow.Operations /// 3-D with shape [filter_height, filter_width, depth]. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor dilation2d_backprop_filter (Tensor input, Tensor filter, Tensor out_backprop, int[] strides, int[] rates, string padding, string name = "Dilation2DBackpropFilter") + public static Tensor dilation2d_backprop_filter(Tensor input, Tensor filter, Tensor out_backprop, int[] strides, int[] rates, string padding, string name = "Dilation2DBackpropFilter") { var dict = new Dictionary(); dict["input"] = input; @@ -9300,7 +9300,7 @@ namespace Tensorflow.Operations /// 4-D with shape [batch, in_height, in_width, depth]. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor dilation2d_backprop_input (Tensor input, Tensor filter, Tensor out_backprop, int[] strides, int[] rates, string padding, string name = "Dilation2DBackpropInput") + public static Tensor dilation2d_backprop_input(Tensor input, Tensor filter, Tensor out_backprop, int[] strides, int[] rates, string padding, string name = "Dilation2DBackpropInput") { var dict = new Dictionary(); dict["input"] = input; @@ -9330,7 +9330,7 @@ namespace Tensorflow.Operations /// *NOTE*: Div supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor div (Tensor x, Tensor y, string name = "Div") + public static Tensor div(Tensor x, Tensor y, string name = "Div") { var dict = new Dictionary(); dict["x"] = x; @@ -9357,7 +9357,7 @@ namespace Tensorflow.Operations /// *NOTE*: DivNoNan supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor div_no_nan (Tensor x, Tensor y, string name = "DivNoNan") + public static Tensor div_no_nan(Tensor x, Tensor y, string name = "DivNoNan") { var dict = new Dictionary(); dict["x"] = x; @@ -9397,7 +9397,7 @@ namespace Tensorflow.Operations /// /// Parts of the bounding box may fall outside the image. /// - public static Tensor draw_bounding_boxes (Tensor images, Tensor boxes, string name = "DrawBoundingBoxes") + public static Tensor draw_bounding_boxes(Tensor images, Tensor boxes, string name = "DrawBoundingBoxes") { var dict = new Dictionary(); dict["images"] = images; @@ -9463,7 +9463,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/DynamicPartition.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor[] dynamic_partition (Tensor data, Tensor partitions, int num_partitions, string name = "DynamicPartition") + public static Tensor[] dynamic_partition(Tensor data, Tensor partitions, int num_partitions, string name = "DynamicPartition") { var dict = new Dictionary(); dict["data"] = data; @@ -9552,7 +9552,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/DynamicStitch.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor dynamic_stitch (Tensor[] indices, Tensor[] data, string name = "DynamicStitch") + public static Tensor dynamic_stitch(Tensor[] indices, Tensor[] data, string name = "DynamicStitch") { var dict = new Dictionary(); dict["indices"] = indices; @@ -9636,7 +9636,7 @@ namespace Tensorflow.Operations /// /// The inputs are: /// - public static Tensor edit_distance (Tensor hypothesis_indices, Tensor hypothesis_values, Tensor hypothesis_shape, Tensor truth_indices, Tensor truth_values, Tensor truth_shape, bool? normalize = null, string name = "EditDistance") + public static Tensor edit_distance(Tensor hypothesis_indices, Tensor hypothesis_values, Tensor hypothesis_shape, Tensor truth_indices, Tensor truth_values, Tensor truth_shape, bool? normalize = null, string name = "EditDistance") { var dict = new Dictionary(); dict["hypothesis_indices"] = hypothesis_indices; @@ -9666,7 +9666,7 @@ namespace Tensorflow.Operations /// See [Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs) /// ](http://arxiv.org/abs/1511.07289) /// - public static Tensor elu (Tensor features, string name = "Elu") + public static Tensor elu(Tensor features, string name = "Elu") { var dict = new Dictionary(); dict["features"] = features; @@ -9691,7 +9691,7 @@ namespace Tensorflow.Operations /// gradients otherwise. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor elu_grad (Tensor gradients, Tensor outputs, string name = "EluGrad") + public static Tensor elu_grad(Tensor gradients, Tensor outputs, string name = "EluGrad") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -9721,7 +9721,7 @@ namespace Tensorflow.Operations /// A Tensor of type T. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor empty (Tensor shape, TF_DataType dtype, bool? init = null, string name = "Empty") + public static Tensor empty(Tensor shape, TF_DataType dtype, bool? init = null, string name = "Empty") { var dict = new Dictionary(); dict["shape"] = shape; @@ -9754,7 +9754,7 @@ namespace Tensorflow.Operations /// element_dtype: the type of elements in the list. /// element_shape: a shape compatible with that of elements in the list. /// - public static Tensor empty_tensor_list (Tensor element_shape, TF_DataType element_dtype, string name = "EmptyTensorList") + public static Tensor empty_tensor_list(Tensor element_shape, TF_DataType element_dtype, string name = "EmptyTensorList") { var dict = new Dictionary(); dict["element_shape"] = element_shape; @@ -9787,7 +9787,7 @@ namespace Tensorflow.Operations /// /// Web-safe means that the encoder uses - and _ instead of + and /. /// - public static Tensor encode_base64 (Tensor input, bool? pad = null, string name = "EncodeBase64") + public static Tensor encode_base64(Tensor input, bool? pad = null, string name = "EncodeBase64") { var dict = new Dictionary(); dict["input"] = input; @@ -9856,7 +9856,7 @@ namespace Tensorflow.Operations /// * 1: Output a grayscale image. /// * 3: Output an RGB image. /// - public static Tensor encode_jpeg (Tensor image, string format = null, int? quality = null, bool? progressive = null, bool? optimize_size = null, bool? chroma_downsampling = null, string density_unit = null, int? x_density = null, int? y_density = null, string xmp_metadata = null, string name = "EncodeJpeg") + public static Tensor encode_jpeg(Tensor image, string format = null, int? quality = null, bool? progressive = null, bool? optimize_size = null, bool? chroma_downsampling = null, string density_unit = null, int? x_density = null, int? y_density = null, string xmp_metadata = null, string name = "EncodeJpeg") { var dict = new Dictionary(); dict["image"] = image; @@ -9916,7 +9916,7 @@ namespace Tensorflow.Operations /// default or a value from 0 to 9. 9 is the highest compression level, generating /// the smallest output, but is slower. /// - public static Tensor encode_png (Tensor image, int? compression = null, string name = "EncodePng") + public static Tensor encode_png(Tensor image, int? compression = null, string name = "EncodePng") { var dict = new Dictionary(); dict["image"] = image; @@ -9991,7 +9991,7 @@ namespace Tensorflow.Operations /// Unsigned int32 values can be represented exactly with tf.int64, or /// with sign wrapping if the input is of type tf.int32. /// - public static Tensor encode_proto (Tensor sizes, Tensor[] values, string[] field_names, string message_type, string descriptor_source = null, string name = "EncodeProto") + public static Tensor encode_proto(Tensor sizes, Tensor[] values, string[] field_names, string message_type, string descriptor_source = null, string name = "EncodeProto") { var dict = new Dictionary(); dict["sizes"] = sizes; @@ -10029,7 +10029,7 @@ namespace Tensorflow.Operations /// audio is a 2-D float Tensor of shape [length, channels]. /// sample_rate is a scalar Tensor holding the rate to use (e.g. 44100). /// - public static Tensor encode_wav (Tensor audio, Tensor sample_rate, string name = "EncodeWav") + public static Tensor encode_wav(Tensor audio, Tensor sample_rate, string name = "EncodeWav") { var dict = new Dictionary(); dict["audio"] = audio; @@ -10059,7 +10059,7 @@ namespace Tensorflow.Operations /// Raises an error if the input tensor's shape does not match the specified shape. /// Returns the input tensor otherwise. /// - public static Tensor ensure_shape (Tensor input, TensorShape shape, string name = "EnsureShape") + public static Tensor ensure_shape(Tensor input, TensorShape shape, string name = "EnsureShape") { var dict = new Dictionary(); dict["input"] = input; @@ -10098,7 +10098,7 @@ namespace Tensorflow.Operations /// it may be changed in the child frame. At most parallel_iterations iterations /// are run in parallel in the child frame. /// - public static Tensor enter (Tensor data, string frame_name, bool? is_constant = null, int? parallel_iterations = null, string name = "Enter") + public static Tensor enter(Tensor data, string frame_name, bool? is_constant = null, int? parallel_iterations = null, string name = "Enter") { var dict = new Dictionary(); dict["data"] = data; @@ -10128,7 +10128,7 @@ namespace Tensorflow.Operations /// *NOTE*: Equal supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor equal (Tensor x, Tensor y, string name = "Equal") + public static Tensor equal(Tensor x, Tensor y, string name = "Equal") { var dict = new Dictionary(); dict["x"] = x; @@ -10148,7 +10148,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor erf (Tensor x, string name = "Erf") + public static Tensor erf(Tensor x, string name = "Erf") { var dict = new Dictionary(); dict["x"] = x; @@ -10167,7 +10167,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor erfc (Tensor x, string name = "Erfc") + public static Tensor erfc(Tensor x, string name = "Erfc") { var dict = new Dictionary(); dict["x"] = x; @@ -10191,7 +10191,7 @@ namespace Tensorflow.Operations /// /// Exit makes its input data available to the parent frame. /// - public static Tensor exit (Tensor data, string name = "Exit") + public static Tensor exit(Tensor data, string name = "Exit") { var dict = new Dictionary(); dict["data"] = data; @@ -10210,7 +10210,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor exp (Tensor x, string name = "Exp") + public static Tensor exp(Tensor x, string name = "Exp") { var dict = new Dictionary(); dict["x"] = x; @@ -10268,7 +10268,7 @@ namespace Tensorflow.Operations /// This operation is related to squeeze(), which removes dimensions of /// size 1. /// - public static Tensor expand_dims (Tensor input, Tensor dim, string name = "ExpandDims") + public static Tensor expand_dims(Tensor input, Tensor dim, string name = "ExpandDims") { var dict = new Dictionary(); dict["input"] = input; @@ -10291,7 +10291,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = (\exp x) - 1\\). /// - public static Tensor expm1 (Tensor x, string name = "Expm1") + public static Tensor expm1(Tensor x, string name = "Expm1") { var dict = new Dictionary(); dict["x"] = x; @@ -10358,7 +10358,7 @@ namespace Tensorflow.Operations /// * If the coordinates are not normalized they are interpreted as /// numbers of pixels. /// - public static Tensor extract_glimpse (Tensor input, Tensor size, Tensor offsets, bool? centered = null, bool? normalized = null, bool? uniform_noise = null, string name = "ExtractGlimpse") + public static Tensor extract_glimpse(Tensor input, Tensor size, Tensor offsets, bool? centered = null, bool? normalized = null, bool? uniform_noise = null, string name = "ExtractGlimpse") { var dict = new Dictionary(); dict["input"] = input; @@ -10420,7 +10420,7 @@ namespace Tensorflow.Operations /// out_rows and out_cols are the dimensions of the output patches. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor extract_image_patches (Tensor images, int[] ksizes, int[] strides, int[] rates, string padding, string name = "ExtractImagePatches") + public static Tensor extract_image_patches(Tensor images, int[] ksizes, int[] strides, int[] rates, string padding, string name = "ExtractImagePatches") { var dict = new Dictionary(); dict["images"] = images; @@ -10452,7 +10452,7 @@ namespace Tensorflow.Operations /// /// This op only parses the image header, so it is much faster than DecodeJpeg. /// - public static Tensor extract_jpeg_shape (Tensor contents, TF_DataType? output_type = null, string name = "ExtractJpegShape") + public static Tensor extract_jpeg_shape(Tensor contents, TF_DataType? output_type = null, string name = "ExtractJpegShape") { var dict = new Dictionary(); dict["contents"] = contents; @@ -10484,7 +10484,7 @@ namespace Tensorflow.Operations /// Computes the 1-dimensional discrete Fourier transform over the inner-most /// dimension of input. /// - public static Tensor f_f_t (Tensor input, string name = "FFT") + public static Tensor f_f_t(Tensor input, string name = "FFT") { var dict = new Dictionary(); dict["input"] = input; @@ -10514,7 +10514,7 @@ namespace Tensorflow.Operations /// Computes the 2-dimensional discrete Fourier transform over the inner-most /// 2 dimensions of input. /// - public static Tensor f_f_t2d (Tensor input, string name = "FFT2D") + public static Tensor f_f_t2d(Tensor input, string name = "FFT2D") { var dict = new Dictionary(); dict["input"] = input; @@ -10544,7 +10544,7 @@ namespace Tensorflow.Operations /// Computes the 3-dimensional discrete Fourier transform over the inner-most 3 /// dimensions of input. /// - public static Tensor f_f_t3d (Tensor input, string name = "FFT3D") + public static Tensor f_f_t3d(Tensor input, string name = "FFT3D") { var dict = new Dictionary(); dict["input"] = input; @@ -10584,7 +10584,7 @@ namespace Tensorflow.Operations /// The handle to the queue. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor f_i_f_o_queue (TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "FIFOQueue") + public static Tensor f_i_f_o_queue(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "FIFOQueue") { var dict = new Dictionary(); dict["component_types"] = component_types; @@ -10632,7 +10632,7 @@ namespace Tensorflow.Operations /// The handle to the queue. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor f_i_f_o_queue_v2 (TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "FIFOQueueV2") + public static Tensor f_i_f_o_queue_v2(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "FIFOQueueV2") { var dict = new Dictionary(); dict["component_types"] = component_types; @@ -10670,7 +10670,7 @@ namespace Tensorflow.Operations /// \"Fake\" output value. This should not be consumed by another op. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor fake_param (TF_DataType dtype, TensorShape shape, string name = "FakeParam") + public static Tensor fake_param(TF_DataType dtype, TensorShape shape, string name = "FakeParam") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -10707,7 +10707,7 @@ namespace Tensorflow.Operations /// /// Quantization is called fake since the output is still in floating point. /// - public static Tensor fake_quant_with_min_max_args (Tensor inputs, float? min = null, float? max = null, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxArgs") + public static Tensor fake_quant_with_min_max_args(Tensor inputs, float? min = null, float? max = null, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxArgs") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -10748,7 +10748,7 @@ namespace Tensorflow.Operations /// gradients * (inputs &gt;= min && inputs &lt;= max). /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor fake_quant_with_min_max_args_gradient (Tensor gradients, Tensor inputs, float? min = null, float? max = null, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxArgsGradient") + public static Tensor fake_quant_with_min_max_args_gradient(Tensor gradients, Tensor inputs, float? min = null, float? max = null, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxArgsGradient") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -10796,7 +10796,7 @@ namespace Tensorflow.Operations /// This operation has a gradient and thus allows for training min and max /// values. /// - public static Tensor fake_quant_with_min_max_vars (Tensor inputs, Tensor min, Tensor max, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxVars") + public static Tensor fake_quant_with_min_max_vars(Tensor inputs, Tensor min, Tensor max, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxVars") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -10843,7 +10843,7 @@ namespace Tensorflow.Operations /// sum(gradients * (inputs &gt; max)). /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor backprops_wrt_input, Tensor backprop_wrt_min, Tensor backprop_wrt_max) fake_quant_with_min_max_vars_gradient (Tensor gradients, Tensor inputs, Tensor min, Tensor max, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxVarsGradient") + public static (Tensor backprops_wrt_input, Tensor backprop_wrt_min, Tensor backprop_wrt_max) fake_quant_with_min_max_vars_gradient(Tensor gradients, Tensor inputs, Tensor min, Tensor max, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxVarsGradient") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -10894,7 +10894,7 @@ namespace Tensorflow.Operations /// This operation has a gradient and thus allows for training min and max /// values. /// - public static Tensor fake_quant_with_min_max_vars_per_channel (Tensor inputs, Tensor min, Tensor max, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxVarsPerChannel") + public static Tensor fake_quant_with_min_max_vars_per_channel(Tensor inputs, Tensor min, Tensor max, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxVarsPerChannel") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -10944,7 +10944,7 @@ namespace Tensorflow.Operations /// sum_per_d(gradients * (inputs &gt; max)). /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor backprops_wrt_input, Tensor backprop_wrt_min, Tensor backprop_wrt_max) fake_quant_with_min_max_vars_per_channel_gradient (Tensor gradients, Tensor inputs, Tensor min, Tensor max, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxVarsPerChannelGradient") + public static (Tensor backprops_wrt_input, Tensor backprop_wrt_min, Tensor backprop_wrt_max) fake_quant_with_min_max_vars_per_channel_gradient(Tensor gradients, Tensor inputs, Tensor min, Tensor max, int? num_bits = null, bool? narrow_range = null, string name = "FakeQuantWithMinMaxVarsPerChannelGradient") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -10974,7 +10974,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor fake_queue (Tensor resource, string name = "FakeQueue") + public static Tensor fake_queue(Tensor resource, string name = "FakeQueue") { var dict = new Dictionary(); dict["resource"] = resource; @@ -11022,7 +11022,7 @@ namespace Tensorflow.Operations /// * Because tf.fill evaluates at graph runtime, it supports dynamic shapes /// based on other runtime Tensors, unlike tf.constant. /// - public static Tensor fill (Tensor dims, Tensor value, string name = "Fill") + public static Tensor fill(Tensor dims, Tensor value, string name = "Fill") { var dict = new Dictionary(); dict["dims"] = dims; @@ -11048,7 +11048,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor filter_by_last_component_dataset (Tensor input_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "FilterByLastComponentDataset") + public static Tensor filter_by_last_component_dataset(Tensor input_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "FilterByLastComponentDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -11085,7 +11085,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor fixed_length_record_dataset (Tensor filenames, Tensor header_bytes, Tensor record_bytes, Tensor footer_bytes, Tensor buffer_size, string name = "FixedLengthRecordDataset") + public static Tensor fixed_length_record_dataset(Tensor filenames, Tensor header_bytes, Tensor record_bytes, Tensor footer_bytes, Tensor buffer_size, string name = "FixedLengthRecordDataset") { var dict = new Dictionary(); dict["filenames"] = filenames; @@ -11129,7 +11129,7 @@ namespace Tensorflow.Operations /// The handle to reference the Reader. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor fixed_length_record_reader (int record_bytes, int? header_bytes = null, int? footer_bytes = null, int? hop_bytes = null, string container = null, string shared_name = null, string name = "FixedLengthRecordReader") + public static Tensor fixed_length_record_reader(int record_bytes, int? header_bytes = null, int? footer_bytes = null, int? hop_bytes = null, string container = null, string shared_name = null, string name = "FixedLengthRecordReader") { var dict = new Dictionary(); dict["record_bytes"] = record_bytes; @@ -11183,7 +11183,7 @@ namespace Tensorflow.Operations /// The handle to reference the Reader. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor fixed_length_record_reader_v2 (int record_bytes, int? header_bytes = null, int? footer_bytes = null, int? hop_bytes = null, string container = null, string shared_name = null, string encoding = null, string name = "FixedLengthRecordReaderV2") + public static Tensor fixed_length_record_reader_v2(int record_bytes, int? header_bytes = null, int? footer_bytes = null, int? hop_bytes = null, string container = null, string shared_name = null, string encoding = null, string name = "FixedLengthRecordReaderV2") { var dict = new Dictionary(); dict["record_bytes"] = record_bytes; @@ -11303,7 +11303,7 @@ namespace Tensorflow.Operations /// the sampled candidates must be chosen independently of the context and of the /// true labels. /// - public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) fixed_unigram_candidate_sampler (Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, string vocab_file = null, float? distortion = null, int? num_reserved_ids = null, int? num_shards = null, int? shard = null, float[] unigrams = null, int? seed = null, int? seed2 = null, string name = "FixedUnigramCandidateSampler") + public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) fixed_unigram_candidate_sampler(Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, string vocab_file = null, float? distortion = null, int? num_reserved_ids = null, int? num_shards = null, int? shard = null, float[] unigrams = null, int? seed = null, int? seed2 = null, string name = "FixedUnigramCandidateSampler") { var dict = new Dictionary(); dict["true_classes"] = true_classes; @@ -11346,7 +11346,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor floor (Tensor x, string name = "Floor") + public static Tensor floor(Tensor x, string name = "Floor") { var dict = new Dictionary(); dict["x"] = x; @@ -11371,7 +11371,7 @@ namespace Tensorflow.Operations /// *NOTE*: FloorDiv supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor floor_div (Tensor x, Tensor y, string name = "FloorDiv") + public static Tensor floor_div(Tensor x, Tensor y, string name = "FloorDiv") { var dict = new Dictionary(); dict["x"] = x; @@ -11400,7 +11400,7 @@ namespace Tensorflow.Operations /// *NOTE*: FloorMod supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor floor_mod (Tensor x, Tensor y, string name = "FloorMod") + public static Tensor floor_mod(Tensor x, Tensor y, string name = "FloorMod") { var dict = new Dictionary(); dict["x"] = x; @@ -11470,7 +11470,7 @@ namespace Tensorflow.Operations /// generated, a mean operation is performed instead of a max operation in each /// pooling region. /// - public static (Tensor output, Tensor row_pooling_sequence, Tensor col_pooling_sequence) fractional_avg_pool (Tensor value, float[] pooling_ratio, bool? pseudo_random = null, bool? overlapping = null, bool? deterministic = null, int? seed = null, int? seed2 = null, string name = "FractionalAvgPool") + public static (Tensor output, Tensor row_pooling_sequence, Tensor col_pooling_sequence) fractional_avg_pool(Tensor value, float[] pooling_ratio, bool? pseudo_random = null, bool? overlapping = null, bool? deterministic = null, int? seed = null, int? seed2 = null, string name = "FractionalAvgPool") { var dict = new Dictionary(); dict["value"] = value; @@ -11536,7 +11536,7 @@ namespace Tensorflow.Operations /// just need to know the shape of original input tensor, instead of the whole /// tensor. /// - public static Tensor fractional_avg_pool_grad (Tensor orig_input_tensor_shape, Tensor out_backprop, Tensor row_pooling_sequence, Tensor col_pooling_sequence, bool? overlapping = null, string name = "FractionalAvgPoolGrad") + public static Tensor fractional_avg_pool_grad(Tensor orig_input_tensor_shape, Tensor out_backprop, Tensor row_pooling_sequence, Tensor col_pooling_sequence, bool? overlapping = null, string name = "FractionalAvgPoolGrad") { var dict = new Dictionary(); dict["orig_input_tensor_shape"] = orig_input_tensor_shape; @@ -11634,7 +11634,7 @@ namespace Tensorflow.Operations /// For more details on fractional max pooling, see this paper: /// [Benjamin Graham, Fractional Max-Pooling](http://arxiv.org/abs/1412.6071) /// - public static (Tensor output, Tensor row_pooling_sequence, Tensor col_pooling_sequence) fractional_max_pool (Tensor value, float[] pooling_ratio, bool? pseudo_random = null, bool? overlapping = null, bool? deterministic = null, int? seed = null, int? seed2 = null, string name = "FractionalMaxPool") + public static (Tensor output, Tensor row_pooling_sequence, Tensor col_pooling_sequence) fractional_max_pool(Tensor value, float[] pooling_ratio, bool? pseudo_random = null, bool? overlapping = null, bool? deterministic = null, int? seed = null, int? seed2 = null, string name = "FractionalMaxPool") { var dict = new Dictionary(); dict["value"] = value; @@ -11696,7 +11696,7 @@ namespace Tensorflow.Operations /// 4-D. Gradients w.r.t. the input of fractional_max_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor fractional_max_pool_grad (Tensor orig_input, Tensor orig_output, Tensor out_backprop, Tensor row_pooling_sequence, Tensor col_pooling_sequence, bool? overlapping = null, string name = "FractionalMaxPoolGrad") + public static Tensor fractional_max_pool_grad(Tensor orig_input, Tensor orig_output, Tensor out_backprop, Tensor row_pooling_sequence, Tensor col_pooling_sequence, bool? overlapping = null, string name = "FractionalMaxPoolGrad") { var dict = new Dictionary(); dict["orig_input"] = orig_input; @@ -11760,7 +11760,7 @@ namespace Tensorflow.Operations /// Note that the size of 4D Tensors are defined by either "NHWC" or "NCHW". /// The size of 1D Tensors matches the dimension C of the 4D Tensors. /// - public static (Tensor y, Tensor batch_mean, Tensor batch_variance, Tensor reserve_space_1, Tensor reserve_space_2) fused_batch_norm (Tensor x, Tensor scale, Tensor offset, Tensor mean, Tensor variance, float? epsilon = null, string data_format = null, bool? is_training = null, string name = "FusedBatchNorm") + public static (Tensor y, Tensor batch_mean, Tensor batch_variance, Tensor reserve_space_1, Tensor reserve_space_2) fused_batch_norm(Tensor x, Tensor scale, Tensor offset, Tensor mean, Tensor variance, float? epsilon = null, string data_format = null, bool? is_training = null, string name = "FusedBatchNorm") { var dict = new Dictionary(); dict["x"] = x; @@ -11837,7 +11837,7 @@ namespace Tensorflow.Operations /// Note that the size of 4D Tensors are defined by either "NHWC" or "NCHW". /// The size of 1D Tensors matches the dimension C of the 4D Tensors. /// - public static (Tensor x_backprop, Tensor scale_backprop, Tensor offset_backprop, Tensor reserve_space_3, Tensor reserve_space_4) fused_batch_norm_grad (Tensor y_backprop, Tensor x, Tensor scale, Tensor reserve_space_1, Tensor reserve_space_2, float? epsilon = null, string data_format = null, bool? is_training = null, string name = "FusedBatchNormGrad") + public static (Tensor x_backprop, Tensor scale_backprop, Tensor offset_backprop, Tensor reserve_space_3, Tensor reserve_space_4) fused_batch_norm_grad(Tensor y_backprop, Tensor x, Tensor scale, Tensor reserve_space_1, Tensor reserve_space_2, float? epsilon = null, string data_format = null, bool? is_training = null, string name = "FusedBatchNormGrad") { var dict = new Dictionary(); dict["y_backprop"] = y_backprop; @@ -11914,7 +11914,7 @@ namespace Tensorflow.Operations /// Note that the size of 4D Tensors are defined by either "NHWC" or "NCHW". /// The size of 1D Tensors matches the dimension C of the 4D Tensors. /// - public static (Tensor x_backprop, Tensor scale_backprop, Tensor offset_backprop, Tensor reserve_space_3, Tensor reserve_space_4) fused_batch_norm_grad_v2 (Tensor y_backprop, Tensor x, Tensor scale, Tensor reserve_space_1, Tensor reserve_space_2, float? epsilon = null, string data_format = null, bool? is_training = null, string name = "FusedBatchNormGradV2") + public static (Tensor x_backprop, Tensor scale_backprop, Tensor offset_backprop, Tensor reserve_space_3, Tensor reserve_space_4) fused_batch_norm_grad_v2(Tensor y_backprop, Tensor x, Tensor scale, Tensor reserve_space_1, Tensor reserve_space_2, float? epsilon = null, string data_format = null, bool? is_training = null, string name = "FusedBatchNormGradV2") { var dict = new Dictionary(); dict["y_backprop"] = y_backprop; @@ -11988,7 +11988,7 @@ namespace Tensorflow.Operations /// Note that the size of 4D Tensors are defined by either "NHWC" or "NCHW". /// The size of 1D Tensors matches the dimension C of the 4D Tensors. /// - public static (Tensor y, Tensor batch_mean, Tensor batch_variance, Tensor reserve_space_1, Tensor reserve_space_2) fused_batch_norm_v2 (Tensor x, Tensor scale, Tensor offset, Tensor mean, Tensor variance, float? epsilon = null, string data_format = null, bool? is_training = null, string name = "FusedBatchNormV2") + public static (Tensor y, Tensor batch_mean, Tensor batch_variance, Tensor reserve_space_1, Tensor reserve_space_2) fused_batch_norm_v2(Tensor x, Tensor scale, Tensor offset, Tensor mean, Tensor variance, float? epsilon = null, string data_format = null, bool? is_training = null, string name = "FusedBatchNormV2") { var dict = new Dictionary(); dict["x"] = x; @@ -12057,7 +12057,7 @@ namespace Tensorflow.Operations /// will block if multiple versions are being run in parallel. This is because this /// operator is primarily an optimization to minimize memory usage. /// - public static Tensor fused_pad_conv2d (Tensor input, Tensor paddings, Tensor filter, string mode, int[] strides, string padding, string name = "FusedPadConv2D") + public static Tensor fused_pad_conv2d(Tensor input, Tensor paddings, Tensor filter, string mode, int[] strides, string padding, string name = "FusedPadConv2D") { var dict = new Dictionary(); dict["input"] = input; @@ -12122,7 +12122,7 @@ namespace Tensorflow.Operations /// will block if multiple versions are being run in parallel. This is because this /// operator is primarily an optimization to minimize memory usage. /// - public static Tensor fused_resize_and_pad_conv2d (Tensor input, Tensor size, Tensor paddings, Tensor filter, string mode, int[] strides, string padding, bool? resize_align_corners = null, string name = "FusedResizeAndPadConv2D") + public static Tensor fused_resize_and_pad_conv2d(Tensor input, Tensor size, Tensor paddings, Tensor filter, string mode, int[] strides, string padding, bool? resize_align_corners = null, string name = "FusedResizeAndPadConv2D") { var dict = new Dictionary(); dict["input"] = input; @@ -12180,7 +12180,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/Gather.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor gather (Tensor parameters, Tensor indices, bool? validate_indices = null, string name = "Gather") + public static Tensor gather(Tensor parameters, Tensor indices, bool? validate_indices = null, string name = "Gather") { var dict = new Dictionary(); dict["params"] = parameters; @@ -12314,7 +12314,7 @@ namespace Tensorflow.Operations /// /// See also tf.gather and tf.batch_gather. /// - public static Tensor gather_nd (Tensor parameters, Tensor indices, string name = "GatherNd") + public static Tensor gather_nd(Tensor parameters, Tensor indices, string name = "GatherNd") { var dict = new Dictionary(); dict["params"] = parameters; @@ -12374,7 +12374,7 @@ namespace Tensorflow.Operations /// /// See also tf.batch_gather and tf.gather_nd. /// - public static Tensor gather_v2 (Tensor parameters, Tensor indices, Tensor axis, string name = "GatherV2") + public static Tensor gather_v2(Tensor parameters, Tensor indices, Tensor axis, string name = "GatherV2") { var dict = new Dictionary(); dict["params"] = parameters; @@ -12446,7 +12446,7 @@ namespace Tensorflow.Operations /// use the corresponding index_table_from_file() as the FeatureColumn framework /// does (as opposed to tf.feature_to_id(), which uses a CuckooTable). /// - public static (Tensor remapping, Tensor num_present) generate_vocab_remapping (Tensor new_vocab_file, Tensor old_vocab_file, int new_vocab_offset, int num_new_vocab, int? old_vocab_size = null, string name = "GenerateVocabRemapping") + public static (Tensor remapping, Tensor num_present) generate_vocab_remapping(Tensor new_vocab_file, Tensor old_vocab_file, int new_vocab_offset, int num_new_vocab, int? old_vocab_size = null, string name = "GenerateVocabRemapping") { var dict = new Dictionary(); dict["new_vocab_file"] = new_vocab_file; @@ -12476,7 +12476,7 @@ namespace Tensorflow.Operations /// as a string. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor get_session_handle (Tensor value, string name = "GetSessionHandle") + public static Tensor get_session_handle(Tensor value, string name = "GetSessionHandle") { var dict = new Dictionary(); dict["value"] = value; @@ -12498,7 +12498,7 @@ namespace Tensorflow.Operations /// as a ResourceHandle object. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor get_session_handle_v2 (Tensor value, string name = "GetSessionHandleV2") + public static Tensor get_session_handle_v2(Tensor value, string name = "GetSessionHandleV2") { var dict = new Dictionary(); dict["value"] = value; @@ -12523,7 +12523,7 @@ namespace Tensorflow.Operations /// The tensor for the given handle. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor get_session_tensor (Tensor handle, TF_DataType dtype, string name = "GetSessionTensor") + public static Tensor get_session_tensor(Tensor handle, TF_DataType dtype, string name = "GetSessionTensor") { var dict = new Dictionary(); dict["handle"] = handle; @@ -12549,7 +12549,7 @@ namespace Tensorflow.Operations /// *NOTE*: Greater supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor greater (Tensor x, Tensor y, string name = "Greater") + public static Tensor greater(Tensor x, Tensor y, string name = "Greater") { var dict = new Dictionary(); dict["x"] = x; @@ -12575,7 +12575,7 @@ namespace Tensorflow.Operations /// *NOTE*: GreaterEqual supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor greater_equal (Tensor x, Tensor y, string name = "GreaterEqual") + public static Tensor greater_equal(Tensor x, Tensor y, string name = "GreaterEqual") { var dict = new Dictionary(); dict["x"] = x; @@ -12603,7 +12603,7 @@ namespace Tensorflow.Operations /// /// Returns the input tensor without modification. /// - public static Tensor guarantee_const (Tensor input, string name = "GuaranteeConst") + public static Tensor guarantee_const(Tensor input, string name = "GuaranteeConst") { var dict = new Dictionary(); dict["input"] = input; @@ -12631,7 +12631,7 @@ namespace Tensorflow.Operations /// /// See rgb_to_hsv for a description of the HSV encoding. /// - public static Tensor h_s_v_to_r_g_b (Tensor images, string name = "HSVToRGB") + public static Tensor h_s_v_to_r_g_b(Tensor images, string name = "HSVToRGB") { var dict = new Dictionary(); dict["images"] = images; @@ -12674,7 +12674,7 @@ namespace Tensorflow.Operations /// Before using the table you will have to initialize it. After initialization the /// table will be immutable. /// - public static Tensor hash_table (TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, string name = "HashTable") + public static Tensor hash_table(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, string name = "HashTable") { var dict = new Dictionary(); dict["key_dtype"] = key_dtype; @@ -12724,7 +12724,7 @@ namespace Tensorflow.Operations /// Before using the table you will have to initialize it. After initialization the /// table will be immutable. /// - public static Tensor hash_table_v2 (TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, string name = "HashTableV2") + public static Tensor hash_table_v2(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, string name = "HashTableV2") { var dict = new Dictionary(); dict["key_dtype"] = key_dtype; @@ -12779,7 +12779,7 @@ namespace Tensorflow.Operations /// sess.run(hist) =&gt; [2, 1, 1, 0, 2] /// /// - public static Tensor histogram_fixed_width (Tensor values, Tensor value_range, Tensor nbins, TF_DataType? dtype = null, string name = "HistogramFixedWidth") + public static Tensor histogram_fixed_width(Tensor values, Tensor value_range, Tensor nbins, TF_DataType? dtype = null, string name = "HistogramFixedWidth") { var dict = new Dictionary(); dict["values"] = values; @@ -12814,7 +12814,7 @@ namespace Tensorflow.Operations /// /// This op reports an InvalidArgument error if any value is not finite. /// - public static Tensor histogram_summary (Tensor tag, Tensor values, string name = "HistogramSummary") + public static Tensor histogram_summary(Tensor tag, Tensor values, string name = "HistogramSummary") { var dict = new Dictionary(); dict["tag"] = tag; @@ -12839,7 +12839,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor host_const (Tensor value, TF_DataType dtype, string name = "HostConst") + public static Tensor host_const(Tensor value, TF_DataType dtype, string name = "HostConst") { var dict = new Dictionary(); dict["value"] = value; @@ -12870,7 +12870,7 @@ namespace Tensorflow.Operations /// Computes the inverse 1-dimensional discrete Fourier transform over the /// inner-most dimension of input. /// - public static Tensor i_f_f_t (Tensor input, string name = "IFFT") + public static Tensor i_f_f_t(Tensor input, string name = "IFFT") { var dict = new Dictionary(); dict["input"] = input; @@ -12900,7 +12900,7 @@ namespace Tensorflow.Operations /// Computes the inverse 2-dimensional discrete Fourier transform over the /// inner-most 2 dimensions of input. /// - public static Tensor i_f_f_t2d (Tensor input, string name = "IFFT2D") + public static Tensor i_f_f_t2d(Tensor input, string name = "IFFT2D") { var dict = new Dictionary(); dict["input"] = input; @@ -12930,7 +12930,7 @@ namespace Tensorflow.Operations /// Computes the inverse 3-dimensional discrete Fourier transform over the /// inner-most 3 dimensions of input. /// - public static Tensor i_f_f_t3d (Tensor input, string name = "IFFT3D") + public static Tensor i_f_f_t3d(Tensor input, string name = "IFFT3D") { var dict = new Dictionary(); dict["input"] = input; @@ -12975,7 +12975,7 @@ namespace Tensorflow.Operations /// than the corresponding dimension of input, the dimension is cropped. If it is /// larger, the dimension is padded with zeros. /// - public static Tensor i_r_f_f_t (Tensor input, Tensor fft_length, string name = "IRFFT") + public static Tensor i_r_f_f_t(Tensor input, Tensor fft_length, string name = "IRFFT") { var dict = new Dictionary(); dict["input"] = input; @@ -13022,7 +13022,7 @@ namespace Tensorflow.Operations /// corresponding dimension of input, the dimension is cropped. If it is larger, /// the dimension is padded with zeros. /// - public static Tensor i_r_f_f_t2d (Tensor input, Tensor fft_length, string name = "IRFFT2D") + public static Tensor i_r_f_f_t2d(Tensor input, Tensor fft_length, string name = "IRFFT2D") { var dict = new Dictionary(); dict["input"] = input; @@ -13069,7 +13069,7 @@ namespace Tensorflow.Operations /// corresponding dimension of input, the dimension is cropped. If it is larger, /// the dimension is padded with zeros. /// - public static Tensor i_r_f_f_t3d (Tensor input, Tensor fft_length, string name = "IRFFT3D") + public static Tensor i_r_f_f_t3d(Tensor input, Tensor fft_length, string name = "IRFFT3D") { var dict = new Dictionary(); dict["input"] = input; @@ -13089,7 +13089,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor identity (Tensor input, string name = "Identity") + public static Tensor identity(Tensor input, string name = "Identity") { var dict = new Dictionary(); dict["input"] = input; @@ -13125,7 +13125,7 @@ namespace Tensorflow.Operations /// return [None, g(dy)] # Do not backprop to f(x). /// /// - public static Tensor[] identity_n (Tensor[] input, string name = "IdentityN") + public static Tensor[] identity_n(Tensor[] input, string name = "IdentityN") { var dict = new Dictionary(); dict["input"] = input; @@ -13157,7 +13157,7 @@ namespace Tensorflow.Operations /// To use, enqueue strings in a Queue. ReaderRead will take the front /// work string and output (work, work). /// - public static Tensor identity_reader (string container = null, string shared_name = null, string name = "IdentityReader") + public static Tensor identity_reader(string container = null, string shared_name = null, string name = "IdentityReader") { var dict = new Dictionary(); if (container != null) @@ -13190,7 +13190,7 @@ namespace Tensorflow.Operations /// To use, enqueue strings in a Queue. ReaderRead will take the front /// work string and output (work, work). /// - public static Tensor identity_reader_v2 (string container = null, string shared_name = null, string name = "IdentityReaderV2") + public static Tensor identity_reader_v2(string container = null, string shared_name = null, string name = "IdentityReaderV2") { var dict = new Dictionary(); if (container != null) @@ -13229,7 +13229,7 @@ namespace Tensorflow.Operations /// Note, above Q(a, x) (Igammac) is the upper regularized complete /// Gamma function. /// - public static Tensor igamma (Tensor a, Tensor x, string name = "Igamma") + public static Tensor igamma(Tensor a, Tensor x, string name = "Igamma") { var dict = new Dictionary(); dict["a"] = a; @@ -13251,7 +13251,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor igamma_grad_a (Tensor a, Tensor x, string name = "IgammaGradA") + public static Tensor igamma_grad_a(Tensor a, Tensor x, string name = "IgammaGradA") { var dict = new Dictionary(); dict["a"] = a; @@ -13287,7 +13287,7 @@ namespace Tensorflow.Operations /// Note, above P(a, x) (Igamma) is the lower regularized complete /// Gamma function. /// - public static Tensor igammac (Tensor a, Tensor x, string name = "Igammac") + public static Tensor igammac(Tensor a, Tensor x, string name = "Igammac") { var dict = new Dictionary(); dict["a"] = a; @@ -13322,7 +13322,7 @@ namespace Tensorflow.Operations /// tf.imag(input) ==&gt; [4.75, 5.75] /// /// - public static Tensor imag (Tensor input, TF_DataType? Tout = null, string name = "Imag") + public static Tensor imag(Tensor input, TF_DataType? Tout = null, string name = "Imag") { var dict = new Dictionary(); dict["input"] = input; @@ -13390,7 +13390,7 @@ namespace Tensorflow.Operations /// replaced by this tensor in the output image. The default value is the color /// red. /// - public static Tensor image_summary (Tensor tag, Tensor tensor, int? max_images = null, Tensor bad_color = null, string name = "ImageSummary") + public static Tensor image_summary(Tensor tag, Tensor tensor, int? max_images = null, Tensor bad_color = null, string name = "ImageSummary") { var dict = new Dictionary(); dict["tag"] = tag; @@ -13428,7 +13428,7 @@ namespace Tensorflow.Operations /// /// The current implementation memmaps the tensor from a file. /// - public static Tensor immutable_const (TF_DataType dtype, TensorShape shape, string memory_region_name, string name = "ImmutableConst") + public static Tensor immutable_const(TF_DataType dtype, TensorShape shape, string memory_region_name, string name = "ImmutableConst") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -13474,7 +13474,7 @@ namespace Tensorflow.Operations /// /// $$out_i = predictions_{i, targets_i} \in TopKIncludingTies(predictions_i)$$ /// - public static Tensor in_top_k (Tensor predictions, Tensor targets, int k, string name = "InTopK") + public static Tensor in_top_k(Tensor predictions, Tensor targets, int k, string name = "InTopK") { var dict = new Dictionary(); dict["predictions"] = predictions; @@ -13519,7 +13519,7 @@ namespace Tensorflow.Operations /// /// $$out_i = predictions_{i, targets_i} \in TopKIncludingTies(predictions_i)$$ /// - public static Tensor in_top_k_v2 (Tensor predictions, Tensor targets, Tensor k, string name = "InTopKV2") + public static Tensor in_top_k_v2(Tensor predictions, Tensor targets, Tensor k, string name = "InTopKV2") { var dict = new Dictionary(); dict["predictions"] = predictions; @@ -13547,7 +13547,7 @@ namespace Tensorflow.Operations /// A tensor that will be provided using the infeed mechanism. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor infeed_dequeue (TF_DataType dtype, TensorShape shape, string name = "InfeedDequeue") + public static Tensor infeed_dequeue(TF_DataType dtype, TensorShape shape, string name = "InfeedDequeue") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -13577,7 +13577,7 @@ namespace Tensorflow.Operations /// /// simultaneously as an XLA tuple. /// - public static Tensor[] infeed_dequeue_tuple (TF_DataType[] dtypes, TensorShape[] shapes, string name = "InfeedDequeueTuple") + public static Tensor[] infeed_dequeue_tuple(TF_DataType[] dtypes, TensorShape[] shapes, string name = "InfeedDequeueTuple") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -13608,7 +13608,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation infeed_enqueue (Tensor input, TensorShape shape = null, int? device_ordinal = null, string name = "InfeedEnqueue") + public static Operation infeed_enqueue(Tensor input, TensorShape shape = null, int? device_ordinal = null, string name = "InfeedEnqueue") { var dict = new Dictionary(); dict["input"] = input; @@ -13641,7 +13641,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation infeed_enqueue_tuple (Tensor[] inputs, TensorShape[] shapes, int? device_ordinal = null, string name = "InfeedEnqueueTuple") + public static Operation infeed_enqueue_tuple(Tensor[] inputs, TensorShape[] shapes, int? device_ordinal = null, string name = "InfeedEnqueueTuple") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -13670,7 +13670,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation initialize_table (Tensor table_handle, Tensor keys, Tensor values, string name = "InitializeTable") + public static Operation initialize_table(Tensor table_handle, Tensor keys, Tensor values, string name = "InitializeTable") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -13722,7 +13722,7 @@ namespace Tensorflow.Operations /// - A value &gt;= 0 means use the index (starting at zero) of the split line based /// on delimiter. /// - public static Operation initialize_table_from_text_file (Tensor table_handle, Tensor filename, int key_index, int value_index, int? vocab_size = null, string delimiter = null, string name = "InitializeTableFromTextFile") + public static Operation initialize_table_from_text_file(Tensor table_handle, Tensor filename, int key_index, int value_index, int? vocab_size = null, string delimiter = null, string name = "InitializeTableFromTextFile") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -13779,7 +13779,7 @@ namespace Tensorflow.Operations /// - A value &gt;= 0 means use the index (starting at zero) of the split line based /// on delimiter. /// - public static Operation initialize_table_from_text_file_v2 (Tensor table_handle, Tensor filename, int key_index, int value_index, int? vocab_size = null, string delimiter = null, string name = "InitializeTableFromTextFileV2") + public static Operation initialize_table_from_text_file_v2(Tensor table_handle, Tensor filename, int key_index, int value_index, int? vocab_size = null, string delimiter = null, string name = "InitializeTableFromTextFileV2") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -13812,7 +13812,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation initialize_table_v2 (Tensor table_handle, Tensor keys, Tensor values, string name = "InitializeTableV2") + public static Operation initialize_table_v2(Tensor table_handle, Tensor keys, Tensor values, string name = "InitializeTableV2") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -13843,7 +13843,7 @@ namespace Tensorflow.Operations /// A Tensor of type T. An alias of x. The content of y is undefined if there are duplicates in i. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor inplace_add (Tensor x, Tensor i, Tensor v, string name = "InplaceAdd") + public static Tensor inplace_add(Tensor x, Tensor i, Tensor v, string name = "InplaceAdd") { var dict = new Dictionary(); dict["x"] = x; @@ -13874,7 +13874,7 @@ namespace Tensorflow.Operations /// A Tensor of type T. An alias of x. The content of y is undefined if there are duplicates in i. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor inplace_sub (Tensor x, Tensor i, Tensor v, string name = "InplaceSub") + public static Tensor inplace_sub(Tensor x, Tensor i, Tensor v, string name = "InplaceSub") { var dict = new Dictionary(); dict["x"] = x; @@ -13905,7 +13905,7 @@ namespace Tensorflow.Operations /// A Tensor of type T. An alias of x. The content of y is undefined if there are duplicates in i. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor inplace_update (Tensor x, Tensor i, Tensor v, string name = "InplaceUpdate") + public static Tensor inplace_update(Tensor x, Tensor i, Tensor v, string name = "InplaceUpdate") { var dict = new Dictionary(); dict["x"] = x; @@ -13929,7 +13929,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = 1 / x\\). /// - public static Tensor inv (Tensor x, string name = "Inv") + public static Tensor inv(Tensor x, string name = "Inv") { var dict = new Dictionary(); dict["x"] = x; @@ -13954,7 +13954,7 @@ namespace Tensorflow.Operations /// Specifically, grad = -dy * y*y, where y = 1/x, and dy /// is the corresponding input gradient. /// - public static Tensor inv_grad (Tensor y, Tensor dy, string name = "InvGrad") + public static Tensor inv_grad(Tensor y, Tensor dy, string name = "InvGrad") { var dict = new Dictionary(); dict["y"] = y; @@ -13978,7 +13978,7 @@ namespace Tensorflow.Operations /// The result will have exactly those bits set, that are not set in x. The /// computation is performed on the underlying representation of x. /// - public static Tensor invert (Tensor x, string name = "Invert") + public static Tensor invert(Tensor x, string name = "Invert") { var dict = new Dictionary(); dict["x"] = x; @@ -14016,7 +14016,7 @@ namespace Tensorflow.Operations /// invert_permutation(x) ==&gt; [2, 4, 3, 0, 1] /// /// - public static Tensor invert_permutation (Tensor x, string name = "InvertPermutation") + public static Tensor invert_permutation(Tensor x, string name = "InvertPermutation") { var dict = new Dictionary(); dict["x"] = x; @@ -14037,7 +14037,7 @@ namespace Tensorflow.Operations /// output boolean on whether it is initialized or not. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor is_boosted_trees_ensemble_initialized (Tensor tree_ensemble_handle, string name = "IsBoostedTreesEnsembleInitialized") + public static Tensor is_boosted_trees_ensemble_initialized(Tensor tree_ensemble_handle, string name = "IsBoostedTreesEnsembleInitialized") { var dict = new Dictionary(); dict["tree_ensemble_handle"] = tree_ensemble_handle; @@ -14061,7 +14061,7 @@ namespace Tensorflow.Operations /// Equivalent to np.isfinite /// @end_compatibility /// - public static Tensor is_finite (Tensor x, string name = "IsFinite") + public static Tensor is_finite(Tensor x, string name = "IsFinite") { var dict = new Dictionary(); dict["x"] = x; @@ -14085,7 +14085,7 @@ namespace Tensorflow.Operations /// Equivalent to np.isinf /// @end_compatibility /// - public static Tensor is_inf (Tensor x, string name = "IsInf") + public static Tensor is_inf(Tensor x, string name = "IsInf") { var dict = new Dictionary(); dict["x"] = x; @@ -14109,7 +14109,7 @@ namespace Tensorflow.Operations /// Equivalent to np.isnan /// @end_compatibility /// - public static Tensor is_nan (Tensor x, string name = "IsNan") + public static Tensor is_nan(Tensor x, string name = "IsNan") { var dict = new Dictionary(); dict["x"] = x; @@ -14132,7 +14132,7 @@ namespace Tensorflow.Operations /// /// Outputs boolean scalar indicating whether the tensor has been initialized. /// - public static Tensor is_variable_initialized (Tensor referecne, string name = "IsVariableInitialized") + public static Tensor is_variable_initialized(Tensor referecne, string name = "IsVariableInitialized") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -14163,7 +14163,7 @@ namespace Tensorflow.Operations /// or "IteratorGetNext" op. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor iterator (string shared_name, string container, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "Iterator") + public static Tensor iterator(string shared_name, string container, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "Iterator") { var dict = new Dictionary(); dict["shared_name"] = shared_name; @@ -14195,7 +14195,7 @@ namespace Tensorflow.Operations /// A handle to an iterator resource. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor iterator_from_string_handle (Tensor string_handle, TF_DataType[] output_types = null, TensorShape[] output_shapes = null, string name = "IteratorFromStringHandle") + public static Tensor iterator_from_string_handle(Tensor string_handle, TF_DataType[] output_types = null, TensorShape[] output_shapes = null, string name = "IteratorFromStringHandle") { var dict = new Dictionary(); dict["string_handle"] = string_handle; @@ -14224,7 +14224,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor[] iterator_get_next (Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNext") + public static Tensor[] iterator_get_next(Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNext") { var dict = new Dictionary(); dict["iterator"] = iterator; @@ -14253,7 +14253,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor iterator_get_next_as_optional (Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNextAsOptional") + public static Tensor iterator_get_next_as_optional(Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNextAsOptional") { var dict = new Dictionary(); dict["iterator"] = iterator; @@ -14286,7 +14286,7 @@ namespace Tensorflow.Operations /// the calling thread is not a member of the thread pool used to execute parallel /// operations (e.g. in eager mode). /// - public static Tensor[] iterator_get_next_sync (Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNextSync") + public static Tensor[] iterator_get_next_sync(Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNextSync") { var dict = new Dictionary(); dict["iterator"] = iterator; @@ -14311,7 +14311,7 @@ namespace Tensorflow.Operations /// A string representation of the given handle. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor iterator_to_string_handle (Tensor resource_handle, string name = "IteratorToStringHandle") + public static Tensor iterator_to_string_handle(Tensor resource_handle, string name = "IteratorToStringHandle") { var dict = new Dictionary(); dict["resource_handle"] = resource_handle; @@ -14337,7 +14337,7 @@ namespace Tensorflow.Operations /// /// output = sum(t ** 2) / 2 /// - public static Tensor l2loss (Tensor t, string name = "L2Loss") + public static Tensor l2loss(Tensor t, string name = "L2Loss") { var dict = new Dictionary(); dict["t"] = t; @@ -14363,7 +14363,7 @@ namespace Tensorflow.Operations /// The handle to reference the Reader. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor l_m_d_b_reader (string container = null, string shared_name = null, string name = "LMDBReader") + public static Tensor l_m_d_b_reader(string container = null, string shared_name = null, string name = "LMDBReader") { var dict = new Dictionary(); if (container != null) @@ -14411,7 +14411,7 @@ namespace Tensorflow.Operations /// For details, see [Krizhevsky et al., ImageNet classification with deep /// convolutional neural networks (NIPS 2012)](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks). /// - public static Tensor l_r_n (Tensor input, int? depth_radius = null, float? bias = null, float? alpha = null, float? beta = null, string name = "LRN") + public static Tensor l_r_n(Tensor input, int? depth_radius = null, float? bias = null, float? alpha = null, float? beta = null, string name = "LRN") { var dict = new Dictionary(); dict["input"] = input; @@ -14458,7 +14458,7 @@ namespace Tensorflow.Operations /// The gradients for LRN. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor l_r_n_grad (Tensor input_grads, Tensor input_image, Tensor output_image, int? depth_radius = null, float? bias = null, float? alpha = null, float? beta = null, string name = "LRNGrad") + public static Tensor l_r_n_grad(Tensor input_grads, Tensor input_image, Tensor output_image, int? depth_radius = null, float? bias = null, float? alpha = null, float? beta = null, string name = "LRNGrad") { var dict = new Dictionary(); dict["input_grads"] = input_grads; @@ -14495,7 +14495,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor latency_stats_dataset (Tensor input_dataset, Tensor tag, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "LatencyStatsDataset") + public static Tensor latency_stats_dataset(Tensor input_dataset, Tensor tag, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "LatencyStatsDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -14566,7 +14566,7 @@ namespace Tensorflow.Operations /// the sampled candidates must be chosen independently of the context and of the /// true labels. /// - public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) learned_unigram_candidate_sampler (Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, int? seed = null, int? seed2 = null, string name = "LearnedUnigramCandidateSampler") + public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) learned_unigram_candidate_sampler(Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, int? seed = null, int? seed2 = null, string name = "LearnedUnigramCandidateSampler") { var dict = new Dictionary(); dict["true_classes"] = true_classes; @@ -14603,7 +14603,7 @@ namespace Tensorflow.Operations /// If y is negative, or greater than or equal to the width of x in bits the /// result is implementation defined. /// - public static Tensor left_shift (Tensor x, Tensor y, string name = "LeftShift") + public static Tensor left_shift(Tensor x, Tensor y, string name = "LeftShift") { var dict = new Dictionary(); dict["x"] = x; @@ -14629,7 +14629,7 @@ namespace Tensorflow.Operations /// *NOTE*: Less supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor less (Tensor x, Tensor y, string name = "Less") + public static Tensor less(Tensor x, Tensor y, string name = "Less") { var dict = new Dictionary(); dict["x"] = x; @@ -14655,7 +14655,7 @@ namespace Tensorflow.Operations /// *NOTE*: LessEqual supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor less_equal (Tensor x, Tensor y, string name = "LessEqual") + public static Tensor less_equal(Tensor x, Tensor y, string name = "LessEqual") { var dict = new Dictionary(); dict["x"] = x; @@ -14675,7 +14675,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor lgamma (Tensor x, string name = "Lgamma") + public static Tensor lgamma(Tensor x, string name = "Lgamma") { var dict = new Dictionary(); dict["x"] = x; @@ -14713,7 +14713,7 @@ namespace Tensorflow.Operations /// tf.linspace(10.0, 12.0, 3, name="linspace") =&gt; [ 10.0 11.0 12.0] /// /// - public static Tensor lin_space (Tensor start, Tensor stop, Tensor num, string name = "LinSpace") + public static Tensor lin_space(Tensor start, Tensor stop, Tensor num, string name = "LinSpace") { var dict = new Dictionary(); dict["start"] = start; @@ -14766,7 +14766,7 @@ namespace Tensorflow.Operations /// idx ==&gt; [1, 3, 5] /// /// - public static (Tensor output, Tensor idx) list_diff (Tensor x, Tensor y, TF_DataType? out_idx = null, string name = "ListDiff") + public static (Tensor output, Tensor idx) list_diff(Tensor x, Tensor y, TF_DataType? out_idx = null, string name = "ListDiff") { var dict = new Dictionary(); dict["x"] = x; @@ -14863,7 +14863,7 @@ namespace Tensorflow.Operations /// [w(0, 0), w(0, 2), -0.5], /// [0.25, -0.25, 42]] /// - public static Tensor load_and_remap_matrix (Tensor ckpt_path, Tensor old_tensor_name, Tensor row_remapping, Tensor col_remapping, Tensor initializing_values, int num_rows, int num_cols, int? max_rows_in_memory = null, string name = "LoadAndRemapMatrix") + public static Tensor load_and_remap_matrix(Tensor ckpt_path, Tensor old_tensor_name, Tensor row_remapping, Tensor col_remapping, Tensor initializing_values, int num_rows, int num_cols, int? max_rows_in_memory = null, string name = "LoadAndRemapMatrix") { var dict = new Dictionary(); dict["ckpt_path"] = ckpt_path; @@ -14893,7 +14893,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = \log_e x\\). /// - public static Tensor log (Tensor x, string name = "Log") + public static Tensor log(Tensor x, string name = "Log") { var dict = new Dictionary(); dict["x"] = x; @@ -14915,7 +14915,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = \log_e (1 + x)\\). /// - public static Tensor log1p (Tensor x, string name = "Log1p") + public static Tensor log1p(Tensor x, string name = "Log1p") { var dict = new Dictionary(); dict["x"] = x; @@ -14950,7 +14950,7 @@ namespace Tensorflow.Operations /// is the LU decomposition of the input and P is the corresponding /// permutation matrix. /// - public static (Tensor sign, Tensor log_abs_determinant) log_matrix_determinant (Tensor input, string name = "LogMatrixDeterminant") + public static (Tensor sign, Tensor log_abs_determinant) log_matrix_determinant(Tensor input, string name = "LogMatrixDeterminant") { var dict = new Dictionary(); dict["input"] = input; @@ -14979,7 +14979,7 @@ namespace Tensorflow.Operations /// /// logsoftmax[i, j] = logits[i, j] - log(sum(exp(logits[i]))) /// - public static Tensor log_softmax (Tensor logits, string name = "LogSoftmax") + public static Tensor log_softmax(Tensor logits, string name = "LogSoftmax") { var dict = new Dictionary(); dict["logits"] = logits; @@ -15047,7 +15047,7 @@ namespace Tensorflow.Operations /// the sampled candidates must be chosen independently of the context and of the /// true labels. /// - public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) log_uniform_candidate_sampler (Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, int? seed = null, int? seed2 = null, string name = "LogUniformCandidateSampler") + public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) log_uniform_candidate_sampler(Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, int? seed = null, int? seed2 = null, string name = "LogUniformCandidateSampler") { var dict = new Dictionary(); dict["true_classes"] = true_classes; @@ -15084,7 +15084,7 @@ namespace Tensorflow.Operations /// *NOTE*: LogicalAnd supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor logical_and (Tensor x, Tensor y, string name = "LogicalAnd") + public static Tensor logical_and(Tensor x, Tensor y, string name = "LogicalAnd") { var dict = new Dictionary(); dict["x"] = x; @@ -15104,7 +15104,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor logical_not (Tensor x, string name = "LogicalNot") + public static Tensor logical_not(Tensor x, string name = "LogicalNot") { var dict = new Dictionary(); dict["x"] = x; @@ -15129,7 +15129,7 @@ namespace Tensorflow.Operations /// *NOTE*: LogicalOr supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor logical_or (Tensor x, Tensor y, string name = "LogicalOr") + public static Tensor logical_or(Tensor x, Tensor y, string name = "LogicalOr") { var dict = new Dictionary(); dict["x"] = x; @@ -15159,7 +15159,7 @@ namespace Tensorflow.Operations /// values : Tensor of all values in the table. Indexed in parallel with keys. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor keys, Tensor values) lookup_table_export (Tensor table_handle, TF_DataType Tkeys, TF_DataType Tvalues, string name = "LookupTableExport") + public static (Tensor keys, Tensor values) lookup_table_export(Tensor table_handle, TF_DataType Tkeys, TF_DataType Tvalues, string name = "LookupTableExport") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15193,7 +15193,7 @@ namespace Tensorflow.Operations /// values : Tensor of all values in the table. Indexed in parallel with keys. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor keys, Tensor values) lookup_table_export_v2 (Tensor table_handle, TF_DataType Tkeys, TF_DataType Tvalues, string name = "LookupTableExportV2") + public static (Tensor keys, Tensor values) lookup_table_export_v2(Tensor table_handle, TF_DataType Tkeys, TF_DataType Tvalues, string name = "LookupTableExportV2") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15232,7 +15232,7 @@ namespace Tensorflow.Operations /// The scalar default_value is the value output for keys not present in the /// table. It must also be of the same type as the table values. /// - public static Tensor lookup_table_find (Tensor table_handle, Tensor keys, Tensor default_value, string name = "LookupTableFind") + public static Tensor lookup_table_find(Tensor table_handle, Tensor keys, Tensor default_value, string name = "LookupTableFind") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15268,7 +15268,7 @@ namespace Tensorflow.Operations /// The scalar default_value is the value output for keys not present in the /// table. It must also be of the same type as the table values. /// - public static Tensor lookup_table_find_v2 (Tensor table_handle, Tensor keys, Tensor default_value, string name = "LookupTableFindV2") + public static Tensor lookup_table_find_v2(Tensor table_handle, Tensor keys, Tensor default_value, string name = "LookupTableFindV2") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15300,7 +15300,7 @@ namespace Tensorflow.Operations /// The tensor keys must be of the same type as the keys of the table. /// The tensor values must be of the type of the table values. /// - public static Operation lookup_table_import (Tensor table_handle, Tensor keys, Tensor values, string name = "LookupTableImport") + public static Operation lookup_table_import(Tensor table_handle, Tensor keys, Tensor values, string name = "LookupTableImport") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15332,7 +15332,7 @@ namespace Tensorflow.Operations /// The tensor keys must be of the same type as the keys of the table. /// The tensor values must be of the type of the table values. /// - public static Operation lookup_table_import_v2 (Tensor table_handle, Tensor keys, Tensor values, string name = "LookupTableImportV2") + public static Operation lookup_table_import_v2(Tensor table_handle, Tensor keys, Tensor values, string name = "LookupTableImportV2") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15364,7 +15364,7 @@ namespace Tensorflow.Operations /// The tensor keys must be of the same type as the keys of the table. /// The tensor values must be of the type of the table values. /// - public static Operation lookup_table_insert (Tensor table_handle, Tensor keys, Tensor values, string name = "LookupTableInsert") + public static Operation lookup_table_insert(Tensor table_handle, Tensor keys, Tensor values, string name = "LookupTableInsert") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15396,7 +15396,7 @@ namespace Tensorflow.Operations /// The tensor keys must be of the same type as the keys of the table. /// The tensor values must be of the type of the table values. /// - public static Operation lookup_table_insert_v2 (Tensor table_handle, Tensor keys, Tensor values, string name = "LookupTableInsertV2") + public static Operation lookup_table_insert_v2(Tensor table_handle, Tensor keys, Tensor values, string name = "LookupTableInsertV2") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15419,7 +15419,7 @@ namespace Tensorflow.Operations /// Scalar that contains number of elements in the table. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor lookup_table_size (Tensor table_handle, string name = "LookupTableSize") + public static Tensor lookup_table_size(Tensor table_handle, string name = "LookupTableSize") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15440,7 +15440,7 @@ namespace Tensorflow.Operations /// Scalar that contains number of elements in the table. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor lookup_table_size_v2 (Tensor table_handle, string name = "LookupTableSizeV2") + public static Tensor lookup_table_size_v2(Tensor table_handle, string name = "LookupTableSizeV2") { var dict = new Dictionary(); dict["table_handle"] = table_handle; @@ -15465,7 +15465,7 @@ namespace Tensorflow.Operations /// This operator represents the loop termination condition used by the /// "pivot" switches of a loop. /// - public static Tensor loop_cond (Tensor input, string name = "LoopCond") + public static Tensor loop_cond(Tensor input, string name = "LoopCond") { var dict = new Dictionary(); dict["input"] = input; @@ -15490,7 +15490,7 @@ namespace Tensorflow.Operations /// This operation may be executed multiple times. Each execution will reset the /// iterator in iterator to the first element of dataset. /// - public static Operation make_iterator (Tensor dataset, Tensor iterator, string name = "MakeIterator") + public static Operation make_iterator(Tensor dataset, Tensor iterator, string name = "MakeIterator") { var dict = new Dictionary(); dict["dataset"] = dataset; @@ -15519,7 +15519,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation map_clear (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapClear") + public static Operation map_clear(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapClear") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -15555,7 +15555,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor map_incomplete_size (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapIncompleteSize") + public static Tensor map_incomplete_size(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapIncompleteSize") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -15599,7 +15599,7 @@ namespace Tensorflow.Operations /// underlying container does not contain this key /// this op will block until it does. /// - public static Tensor[] map_peek (Tensor key, Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapPeek") + public static Tensor[] map_peek(Tensor key, Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapPeek") { var dict = new Dictionary(); dict["key"] = key; @@ -15639,7 +15639,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor map_size (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapSize") + public static Tensor map_size(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapSize") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -15689,7 +15689,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation map_stage (Tensor key, Tensor indices, Tensor[] values, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapStage") + public static Operation map_stage(Tensor key, Tensor indices, Tensor[] values, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapStage") { var dict = new Dictionary(); dict["key"] = key; @@ -15736,7 +15736,7 @@ namespace Tensorflow.Operations /// from the underlying container. If the underlying container /// does not contain this key, the op will block until it does. /// - public static Tensor[] map_unstage (Tensor key, Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapUnstage") + public static Tensor[] map_unstage(Tensor key, Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapUnstage") { var dict = new Dictionary(); dict["key"] = key; @@ -15785,7 +15785,7 @@ namespace Tensorflow.Operations /// from the underlying container. If the underlying container /// does not contain elements, the op will block until it does. /// - public static (Tensor key, Tensor[] values) map_unstage_no_key (Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapUnstageNoKey") + public static (Tensor key, Tensor[] values) map_unstage_no_key(Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "MapUnstageNoKey") { var dict = new Dictionary(); dict["indices"] = indices; @@ -15833,7 +15833,7 @@ namespace Tensorflow.Operations /// *Note*: The default kernel implementation for MatMul on GPUs uses /// cublas. /// - public static Tensor mat_mul (Tensor a, Tensor b, bool? transpose_a = null, bool? transpose_b = null, string name = "MatMul") + public static Tensor mat_mul(Tensor a, Tensor b, bool? transpose_a = null, bool? transpose_b = null, string name = "MatMul") { var dict = new Dictionary(); dict["a"] = a; @@ -15864,7 +15864,7 @@ namespace Tensorflow.Operations /// basename portion of the pattern, not in the directory portion. /// Note also that the order of filenames returned can be non-deterministic. /// - public static Tensor matching_files (Tensor pattern, string name = "MatchingFiles") + public static Tensor matching_files(Tensor pattern, string name = "MatchingFiles") { var dict = new Dictionary(); dict["pattern"] = pattern; @@ -15934,7 +15934,7 @@ namespace Tensorflow.Operations /// tf.matrix_band_part(input, 0, 0) ==&gt; Diagonal. /// /// - public static Tensor matrix_band_part (Tensor input, Tensor num_lower, Tensor num_upper, string name = "MatrixBandPart") + public static Tensor matrix_band_part(Tensor input, Tensor num_lower, Tensor num_upper, string name = "MatrixBandPart") { var dict = new Dictionary(); dict["input"] = input; @@ -15962,7 +15962,7 @@ namespace Tensorflow.Operations /// form square matrices. The output is a tensor containing the determinants /// for all input submatrices [..., :, :]. /// - public static Tensor matrix_determinant (Tensor input, string name = "MatrixDeterminant") + public static Tensor matrix_determinant(Tensor input, string name = "MatrixDeterminant") { var dict = new Dictionary(); dict["input"] = input; @@ -16011,7 +16011,7 @@ namespace Tensorflow.Operations /// which has shape (2, 4, 4) /// /// - public static Tensor matrix_diag (Tensor diagonal, string name = "MatrixDiag") + public static Tensor matrix_diag(Tensor diagonal, string name = "MatrixDiag") { var dict = new Dictionary(); dict["diagonal"] = diagonal; @@ -16063,7 +16063,7 @@ namespace Tensorflow.Operations /// which has shape (2, 4) /// /// - public static Tensor matrix_diag_part (Tensor input, string name = "MatrixDiagPart") + public static Tensor matrix_diag_part(Tensor input, string name = "MatrixDiagPart") { var dict = new Dictionary(); dict["input"] = input; @@ -16082,7 +16082,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor matrix_exponential (Tensor input, string name = "MatrixExponential") + public static Tensor matrix_exponential(Tensor input, string name = "MatrixExponential") { var dict = new Dictionary(); dict["input"] = input; @@ -16122,7 +16122,7 @@ namespace Tensorflow.Operations /// may detect the condition and raise an exception or it may simply return a /// garbage result. /// - public static Tensor matrix_inverse (Tensor input, bool? adjoint = null, string name = "MatrixInverse") + public static Tensor matrix_inverse(Tensor input, bool? adjoint = null, string name = "MatrixInverse") { var dict = new Dictionary(); dict["input"] = input; @@ -16166,7 +16166,7 @@ namespace Tensorflow.Operations /// form square matrices. The output is a tensor of the same shape as the input /// containing the exponential for all input submatrices [..., :, :]. /// - public static Tensor matrix_logarithm (Tensor input, string name = "MatrixLogarithm") + public static Tensor matrix_logarithm(Tensor input, string name = "MatrixLogarithm") { var dict = new Dictionary(); dict["input"] = input; @@ -16204,7 +16204,7 @@ namespace Tensorflow.Operations /// * output[i, j, k, ..., m, n] = diagonal[i, j, k, ..., n] for m == n. /// * output[i, j, k, ..., m, n] = input[i, j, k, ..., m, n] for m != n. /// - public static Tensor matrix_set_diag (Tensor input, Tensor diagonal, string name = "MatrixSetDiag") + public static Tensor matrix_set_diag(Tensor input, Tensor diagonal, string name = "MatrixSetDiag") { var dict = new Dictionary(); dict["input"] = input; @@ -16241,7 +16241,7 @@ namespace Tensorflow.Operations /// If adjoint is True then each output matrix satisfies /// adjoint(matrix[..., :, :]) * output[..., :, :] = rhs[..., :, :]. /// - public static Tensor matrix_solve (Tensor matrix, Tensor rhs, bool? adjoint = null, string name = "MatrixSolve") + public static Tensor matrix_solve(Tensor matrix, Tensor rhs, bool? adjoint = null, string name = "MatrixSolve") { var dict = new Dictionary(); dict["matrix"] = matrix; @@ -16313,7 +16313,7 @@ namespace Tensorflow.Operations /// typically 6-7 times slower than the fast path. If fast is False then /// l2_regularizer is ignored. /// - public static Tensor matrix_solve_ls (Tensor matrix, Tensor rhs, Tensor l2_regularizer, bool? fast = null, string name = "MatrixSolveLs") + public static Tensor matrix_solve_ls(Tensor matrix, Tensor rhs, Tensor l2_regularizer, bool? fast = null, string name = "MatrixSolveLs") { var dict = new Dictionary(); dict["matrix"] = matrix; @@ -16370,7 +16370,7 @@ namespace Tensorflow.Operations /// output satisfy matrix equations /// adjoint(matrix[..., i, k]) * output[..., k, j] = rhs[..., i, j]. /// - public static Tensor matrix_triangular_solve (Tensor matrix, Tensor rhs, bool? lower = null, bool? adjoint = null, string name = "MatrixTriangularSolve") + public static Tensor matrix_triangular_solve(Tensor matrix, Tensor rhs, bool? lower = null, bool? adjoint = null, string name = "MatrixTriangularSolve") { var dict = new Dictionary(); dict["matrix"] = matrix; @@ -16409,7 +16409,7 @@ namespace Tensorflow.Operations /// axis. If keep_dims is true, the reduced dimensions are /// retained with length 1. /// - public static Tensor max (Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Max") + public static Tensor max(Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Max") { var dict = new Dictionary(); dict["input"] = input; @@ -16453,7 +16453,7 @@ namespace Tensorflow.Operations /// The max pooled output tensor. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool (Tensor input, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPool") + public static Tensor max_pool(Tensor input, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPool") { var dict = new Dictionary(); dict["input"] = input; @@ -16500,7 +16500,7 @@ namespace Tensorflow.Operations /// The max pooled output tensor. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool3d (Tensor input, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPool3D") + public static Tensor max_pool3d(Tensor input, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPool3D") { var dict = new Dictionary(); dict["input"] = input; @@ -16552,7 +16552,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool3d_grad (Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPool3DGrad") + public static Tensor max_pool3d_grad(Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPool3DGrad") { var dict = new Dictionary(); dict["orig_input"] = orig_input; @@ -16607,7 +16607,7 @@ namespace Tensorflow.Operations /// Gradients of gradients w.r.t. the input to max_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool3d_grad_grad (Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPool3DGradGrad") + public static Tensor max_pool3d_grad_grad(Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPool3DGradGrad") { var dict = new Dictionary(); dict["orig_input"] = orig_input; @@ -16661,7 +16661,7 @@ namespace Tensorflow.Operations /// Gradients w.r.t. the input to max_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool_grad (Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPoolGrad") + public static Tensor max_pool_grad(Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPoolGrad") { var dict = new Dictionary(); dict["orig_input"] = orig_input; @@ -16715,7 +16715,7 @@ namespace Tensorflow.Operations /// Gradients of gradients w.r.t. the input to max_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool_grad_grad (Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPoolGradGrad") + public static Tensor max_pool_grad_grad(Tensor orig_input, Tensor orig_output, Tensor grad, int[] ksize, int[] strides, string padding, string data_format = null, string name = "MaxPoolGradGrad") { var dict = new Dictionary(); dict["orig_input"] = orig_input; @@ -16767,7 +16767,7 @@ namespace Tensorflow.Operations /// Gradients of gradients w.r.t. the input to max_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool_grad_grad_v2 (Tensor orig_input, Tensor orig_output, Tensor grad, Tensor ksize, Tensor strides, string padding, string data_format = null, string name = "MaxPoolGradGradV2") + public static Tensor max_pool_grad_grad_v2(Tensor orig_input, Tensor orig_output, Tensor grad, Tensor ksize, Tensor strides, string padding, string data_format = null, string name = "MaxPoolGradGradV2") { var dict = new Dictionary(); dict["orig_input"] = orig_input; @@ -16815,7 +16815,7 @@ namespace Tensorflow.Operations /// Gradients of gradients w.r.t. the input of max_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool_grad_grad_with_argmax (Tensor input, Tensor grad, Tensor argmax, int[] ksize, int[] strides, string padding, string name = "MaxPoolGradGradWithArgmax") + public static Tensor max_pool_grad_grad_with_argmax(Tensor input, Tensor grad, Tensor argmax, int[] ksize, int[] strides, string padding, string name = "MaxPoolGradGradWithArgmax") { var dict = new Dictionary(); dict["input"] = input; @@ -16865,7 +16865,7 @@ namespace Tensorflow.Operations /// Gradients w.r.t. the input to max_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool_grad_v2 (Tensor orig_input, Tensor orig_output, Tensor grad, Tensor ksize, Tensor strides, string padding, string data_format = null, string name = "MaxPoolGradV2") + public static Tensor max_pool_grad_v2(Tensor orig_input, Tensor orig_output, Tensor grad, Tensor ksize, Tensor strides, string padding, string data_format = null, string name = "MaxPoolGradV2") { var dict = new Dictionary(); dict["orig_input"] = orig_input; @@ -16913,7 +16913,7 @@ namespace Tensorflow.Operations /// Gradients w.r.t. the input of max_pool. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool_grad_with_argmax (Tensor input, Tensor grad, Tensor argmax, int[] ksize, int[] strides, string padding, string name = "MaxPoolGradWithArgmax") + public static Tensor max_pool_grad_with_argmax(Tensor input, Tensor grad, Tensor argmax, int[] ksize, int[] strides, string padding, string name = "MaxPoolGradWithArgmax") { var dict = new Dictionary(); dict["input"] = input; @@ -16957,7 +16957,7 @@ namespace Tensorflow.Operations /// The max pooled output tensor. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor max_pool_v2 (Tensor input, Tensor ksize, Tensor strides, string padding, string data_format = null, string name = "MaxPoolV2") + public static Tensor max_pool_v2(Tensor input, Tensor ksize, Tensor strides, string padding, string data_format = null, string name = "MaxPoolV2") { var dict = new Dictionary(); dict["input"] = input; @@ -17010,7 +17010,7 @@ namespace Tensorflow.Operations /// (either negative or too large). This is a bug, but fixing it is difficult to do /// in a safe backwards compatible way, especially due to flattening. /// - public static (Tensor output, Tensor argmax) max_pool_with_argmax (Tensor input, int[] ksize, int[] strides, string padding, TF_DataType? Targmax = null, string name = "MaxPoolWithArgmax") + public static (Tensor output, Tensor argmax) max_pool_with_argmax(Tensor input, int[] ksize, int[] strides, string padding, TF_DataType? Targmax = null, string name = "MaxPoolWithArgmax") { var dict = new Dictionary(); dict["input"] = input; @@ -17043,7 +17043,7 @@ namespace Tensorflow.Operations /// *NOTE*: Maximum supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor maximum (Tensor x, Tensor y, string name = "Maximum") + public static Tensor maximum(Tensor x, Tensor y, string name = "Maximum") { var dict = new Dictionary(); dict["x"] = x; @@ -17078,7 +17078,7 @@ namespace Tensorflow.Operations /// axis. If keep_dims is true, the reduced dimensions are /// retained with length 1. /// - public static Tensor mean (Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Mean") + public static Tensor mean(Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Mean") { var dict = new Dictionary(); dict["input"] = input; @@ -17111,7 +17111,7 @@ namespace Tensorflow.Operations /// Merge forwards the first tensor to become available to output, and sets /// value_index to its index in inputs. /// - public static (Tensor output, Tensor value_index) merge (Tensor[] inputs, string name = "Merge") + public static (Tensor output, Tensor value_index) merge(Tensor[] inputs, string name = "Merge") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -17145,7 +17145,7 @@ namespace Tensorflow.Operations /// When the Op is run, it reports an InvalidArgument error if multiple values /// in the summaries to merge use the same tag. /// - public static Tensor merge_summary (Tensor[] inputs, string name = "MergeSummary") + public static Tensor merge_summary(Tensor[] inputs, string name = "MergeSummary") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -17182,7 +17182,7 @@ namespace Tensorflow.Operations /// path in the input checkpoint_prefixes. This is useful when those paths are non /// user-facing temporary locations. /// - public static Operation merge_v2checkpoints (Tensor checkpoint_prefixes, Tensor destination_prefix, bool? delete_old_dirs = null, string name = "MergeV2Checkpoints") + public static Operation merge_v2checkpoints(Tensor checkpoint_prefixes, Tensor destination_prefix, bool? delete_old_dirs = null, string name = "MergeV2Checkpoints") { var dict = new Dictionary(); dict["checkpoint_prefixes"] = checkpoint_prefixes; @@ -17231,7 +17231,7 @@ namespace Tensorflow.Operations /// history in the speech recognition world, and https://en.wikipedia.org/wiki/Mel-frequency_cepstrum /// is a good resource to learn more. /// - public static Tensor mfcc (Tensor spectrogram, Tensor sample_rate, float? upper_frequency_limit = null, float? lower_frequency_limit = null, int? filterbank_channel_count = null, int? dct_coefficient_count = null, string name = "Mfcc") + public static Tensor mfcc(Tensor spectrogram, Tensor sample_rate, float? upper_frequency_limit = null, float? lower_frequency_limit = null, int? filterbank_channel_count = null, int? dct_coefficient_count = null, string name = "Mfcc") { var dict = new Dictionary(); dict["spectrogram"] = spectrogram; @@ -17274,7 +17274,7 @@ namespace Tensorflow.Operations /// axis. If keep_dims is true, the reduced dimensions are /// retained with length 1. /// - public static Tensor min (Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Min") + public static Tensor min(Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Min") { var dict = new Dictionary(); dict["input"] = input; @@ -17302,7 +17302,7 @@ namespace Tensorflow.Operations /// *NOTE*: Minimum supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor minimum (Tensor x, Tensor y, string name = "Minimum") + public static Tensor minimum(Tensor x, Tensor y, string name = "Minimum") { var dict = new Dictionary(); dict["x"] = x; @@ -17363,7 +17363,7 @@ namespace Tensorflow.Operations /// [5, 4, 4, 5, 6, 6, 5]] /// /// - public static Tensor mirror_pad (Tensor input, Tensor paddings, string mode, string name = "MirrorPad") + public static Tensor mirror_pad(Tensor input, Tensor paddings, string mode, string name = "MirrorPad") { var dict = new Dictionary(); dict["input"] = input; @@ -17414,7 +17414,7 @@ namespace Tensorflow.Operations /// [11, 28]] /// /// - public static Tensor mirror_pad_grad (Tensor input, Tensor paddings, string mode, string name = "MirrorPadGrad") + public static Tensor mirror_pad_grad(Tensor input, Tensor paddings, string mode, string name = "MirrorPadGrad") { var dict = new Dictionary(); dict["input"] = input; @@ -17444,7 +17444,7 @@ namespace Tensorflow.Operations /// *NOTE*: Mod supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor mod (Tensor x, Tensor y, string name = "Mod") + public static Tensor mod(Tensor x, Tensor y, string name = "Mod") { var dict = new Dictionary(); dict["x"] = x; @@ -17470,7 +17470,7 @@ namespace Tensorflow.Operations /// *NOTE*: Multiply supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor mul (Tensor x, Tensor y, string name = "Mul") + public static Tensor mul(Tensor x, Tensor y, string name = "Mul") { var dict = new Dictionary(); dict["x"] = x; @@ -17506,7 +17506,7 @@ namespace Tensorflow.Operations /// contains the drawn class labels with range [0, num_classes). /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor multinomial (Tensor logits, Tensor num_samples, int? seed = null, int? seed2 = null, TF_DataType? output_dtype = null, string name = "Multinomial") + public static Tensor multinomial(Tensor logits, Tensor num_samples, int? seed = null, int? seed2 = null, TF_DataType? output_dtype = null, string name = "Multinomial") { var dict = new Dictionary(); dict["logits"] = logits; @@ -17568,7 +17568,7 @@ namespace Tensorflow.Operations /// values. Each value must be a scalar. Data can be inserted into the table using /// the insert operations. It does not support the initialization operation. /// - public static Tensor mutable_dense_hash_table (Tensor empty_key, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, int? initial_num_buckets = null, float? max_load_factor = null, string name = "MutableDenseHashTable") + public static Tensor mutable_dense_hash_table(Tensor empty_key, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, int? initial_num_buckets = null, float? max_load_factor = null, string name = "MutableDenseHashTable") { var dict = new Dictionary(); dict["empty_key"] = empty_key; @@ -17636,7 +17636,7 @@ namespace Tensorflow.Operations /// values. Each value must be a scalar. Data can be inserted into the table using /// the insert operations. It does not support the initialization operation. /// - public static Tensor mutable_dense_hash_table_v2 (Tensor empty_key, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, int? initial_num_buckets = null, float? max_load_factor = null, string name = "MutableDenseHashTableV2") + public static Tensor mutable_dense_hash_table_v2(Tensor empty_key, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, int? initial_num_buckets = null, float? max_load_factor = null, string name = "MutableDenseHashTableV2") { var dict = new Dictionary(); dict["empty_key"] = empty_key; @@ -17692,7 +17692,7 @@ namespace Tensorflow.Operations /// values. Each value must be a scalar. Data can be inserted into the table using /// the insert operations. It does not support the initialization operation. /// - public static Tensor mutable_hash_table (TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, string name = "MutableHashTable") + public static Tensor mutable_hash_table(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, string name = "MutableHashTable") { var dict = new Dictionary(); dict["key_dtype"] = key_dtype; @@ -17742,7 +17742,7 @@ namespace Tensorflow.Operations /// values. Each value must be a vector. Data can be inserted into the table using /// the insert operations. It does not support the initialization operation. /// - public static Tensor mutable_hash_table_of_tensors (TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, string name = "MutableHashTableOfTensors") + public static Tensor mutable_hash_table_of_tensors(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, string name = "MutableHashTableOfTensors") { var dict = new Dictionary(); dict["key_dtype"] = key_dtype; @@ -17794,7 +17794,7 @@ namespace Tensorflow.Operations /// values. Each value must be a vector. Data can be inserted into the table using /// the insert operations. It does not support the initialization operation. /// - public static Tensor mutable_hash_table_of_tensors_v2 (TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, string name = "MutableHashTableOfTensorsV2") + public static Tensor mutable_hash_table_of_tensors_v2(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, string name = "MutableHashTableOfTensorsV2") { var dict = new Dictionary(); dict["key_dtype"] = key_dtype; @@ -17846,7 +17846,7 @@ namespace Tensorflow.Operations /// values. Each value must be a scalar. Data can be inserted into the table using /// the insert operations. It does not support the initialization operation. /// - public static Tensor mutable_hash_table_v2 (TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, string name = "MutableHashTableV2") + public static Tensor mutable_hash_table_v2(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, string name = "MutableHashTableV2") { var dict = new Dictionary(); dict["key_dtype"] = key_dtype; @@ -17916,7 +17916,7 @@ namespace Tensorflow.Operations /// It is also useful if two separate functions must share a resource, but we /// wish to ensure the usage is exclusive. /// - public static Tensor mutex_lock (Tensor mutex, string name = "MutexLock") + public static Tensor mutex_lock(Tensor mutex, string name = "MutexLock") { var dict = new Dictionary(); dict["mutex"] = mutex; @@ -17942,7 +17942,7 @@ namespace Tensorflow.Operations /// The mutex resource. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor mutex_v2 (string container = null, string shared_name = null, string name = "MutexV2") + public static Tensor mutex_v2(string container = null, string shared_name = null, string name = "MutexV2") { var dict = new Dictionary(); if (container != null) @@ -17967,7 +17967,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = -x\\). /// - public static Tensor neg (Tensor x, string name = "Neg") + public static Tensor neg(Tensor x, string name = "Neg") { var dict = new Dictionary(); dict["x"] = x; @@ -18006,7 +18006,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation neg_train (Tensor w_in, Tensor w_out, Tensor examples, Tensor labels, Tensor lr, int[] vocab_count, int num_negative_samples, string name = "NegTrain") + public static Operation neg_train(Tensor w_in, Tensor w_out, Tensor examples, Tensor labels, Tensor lr, int[] vocab_count, int num_negative_samples, string name = "NegTrain") { var dict = new Dictionary(); dict["w_in"] = w_in; @@ -18033,7 +18033,7 @@ namespace Tensorflow.Operations /// The same tensor as data. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor next_iteration (Tensor data, string name = "NextIteration") + public static Tensor next_iteration(Tensor data, string name = "NextIteration") { var dict = new Dictionary(); dict["data"] = data; @@ -18050,7 +18050,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation no_op (string name = "NoOp") + public static Operation no_op(string name = "NoOp") { var dict = new Dictionary(); var op = tf.OpDefLib._apply_op_helper("NoOp", name: name, keywords: dict); @@ -18101,7 +18101,7 @@ namespace Tensorflow.Operations /// boxes, scores, max_output_size, iou_threshold) /// selected_boxes = tf.gather(boxes, selected_indices) /// - public static Tensor non_max_suppression (Tensor boxes, Tensor scores, Tensor max_output_size, float? iou_threshold = null, string name = "NonMaxSuppression") + public static Tensor non_max_suppression(Tensor boxes, Tensor scores, Tensor max_output_size, float? iou_threshold = null, string name = "NonMaxSuppression") { var dict = new Dictionary(); dict["boxes"] = boxes; @@ -18159,7 +18159,7 @@ namespace Tensorflow.Operations /// boxes, scores, max_output_size, iou_threshold) /// selected_boxes = tf.gather(boxes, selected_indices) /// - public static Tensor non_max_suppression_v2 (Tensor boxes, Tensor scores, Tensor max_output_size, Tensor iou_threshold, string name = "NonMaxSuppressionV2") + public static Tensor non_max_suppression_v2(Tensor boxes, Tensor scores, Tensor max_output_size, Tensor iou_threshold, string name = "NonMaxSuppressionV2") { var dict = new Dictionary(); dict["boxes"] = boxes; @@ -18219,7 +18219,7 @@ namespace Tensorflow.Operations /// boxes, scores, max_output_size, iou_threshold, score_threshold) /// selected_boxes = tf.gather(boxes, selected_indices) /// - public static Tensor non_max_suppression_v3 (Tensor boxes, Tensor scores, Tensor max_output_size, Tensor iou_threshold, Tensor score_threshold, string name = "NonMaxSuppressionV3") + public static Tensor non_max_suppression_v3(Tensor boxes, Tensor scores, Tensor max_output_size, Tensor iou_threshold, Tensor score_threshold, string name = "NonMaxSuppressionV3") { var dict = new Dictionary(); dict["boxes"] = boxes; @@ -18287,7 +18287,7 @@ namespace Tensorflow.Operations /// boxes, scores, max_output_size, iou_threshold, score_threshold) /// selected_boxes = tf.gather(boxes, selected_indices) /// - public static (Tensor selected_indices, Tensor valid_outputs) non_max_suppression_v4 (Tensor boxes, Tensor scores, Tensor max_output_size, Tensor iou_threshold, Tensor score_threshold, bool? pad_to_max_output_size = null, string name = "NonMaxSuppressionV4") + public static (Tensor selected_indices, Tensor valid_outputs) non_max_suppression_v4(Tensor boxes, Tensor scores, Tensor max_output_size, Tensor iou_threshold, Tensor score_threshold, bool? pad_to_max_output_size = null, string name = "NonMaxSuppressionV4") { var dict = new Dictionary(); dict["boxes"] = boxes; @@ -18351,7 +18351,7 @@ namespace Tensorflow.Operations /// overlaps, scores, max_output_size, overlap_threshold, score_threshold) /// selected_boxes = tf.gather(boxes, selected_indices) /// - public static Tensor non_max_suppression_with_overlaps (Tensor overlaps, Tensor scores, Tensor max_output_size, Tensor overlap_threshold, Tensor score_threshold, string name = "NonMaxSuppressionWithOverlaps") + public static Tensor non_max_suppression_with_overlaps(Tensor overlaps, Tensor scores, Tensor max_output_size, Tensor overlap_threshold, Tensor score_threshold, string name = "NonMaxSuppressionWithOverlaps") { var dict = new Dictionary(); dict["overlaps"] = overlaps; @@ -18380,7 +18380,7 @@ namespace Tensorflow.Operations /// *NOTE*: NotEqual supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor not_equal (Tensor x, Tensor y, string name = "NotEqual") + public static Tensor not_equal(Tensor x, Tensor y, string name = "NotEqual") { var dict = new Dictionary(); dict["x"] = x; @@ -18419,7 +18419,7 @@ namespace Tensorflow.Operations /// /// values.shape = input.shape[:-1] /// - public static Tensor nth_element (Tensor input, Tensor n, bool? reverse = null, string name = "NthElement") + public static Tensor nth_element(Tensor input, Tensor n, bool? reverse = null, string name = "NthElement") { var dict = new Dictionary(); dict["input"] = input; @@ -18549,7 +18549,7 @@ namespace Tensorflow.Operations /// ] /// /// - public static Tensor one_hot (Tensor indices, Tensor depth, Tensor on_value, Tensor off_value, int? axis = null, string name = "OneHot") + public static Tensor one_hot(Tensor indices, Tensor depth, Tensor on_value, Tensor off_value, int? axis = null, string name = "OneHot") { var dict = new Dictionary(); dict["indices"] = indices; @@ -18575,7 +18575,7 @@ namespace Tensorflow.Operations /// a tensor of the same shape and type as x but filled with ones. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor ones_like (Tensor x, string name = "OnesLike") + public static Tensor ones_like(Tensor x, string name = "OnesLike") { var dict = new Dictionary(); dict["x"] = x; @@ -18607,7 +18607,7 @@ namespace Tensorflow.Operations /// /// Creates a dataset by applying optimizations to input_dataset. /// - public static Tensor optimize_dataset (Tensor input_dataset, Tensor optimizations, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "OptimizeDataset") + public static Tensor optimize_dataset(Tensor input_dataset, Tensor optimizations, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "OptimizeDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -18629,7 +18629,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor optional_from_value (Tensor[] components, string name = "OptionalFromValue") + public static Tensor optional_from_value(Tensor[] components, string name = "OptionalFromValue") { var dict = new Dictionary(); dict["components"] = components; @@ -18654,7 +18654,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor[] optional_get_value (Tensor optional, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "OptionalGetValue") + public static Tensor[] optional_get_value(Tensor optional, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "OptionalGetValue") { var dict = new Dictionary(); dict["optional"] = optional; @@ -18677,7 +18677,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor optional_has_value (Tensor optional, string name = "OptionalHasValue") + public static Tensor optional_has_value(Tensor optional, string name = "OptionalHasValue") { var dict = new Dictionary(); dict["optional"] = optional; @@ -18694,7 +18694,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor optional_none (string name = "OptionalNone") + public static Tensor optional_none(string name = "OptionalNone") { var dict = new Dictionary(); var op = tf.OpDefLib._apply_op_helper("OptionalNone", name: name, keywords: dict); @@ -18721,7 +18721,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation ordered_map_clear (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapClear") + public static Operation ordered_map_clear(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapClear") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -18757,7 +18757,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor ordered_map_incomplete_size (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapIncompleteSize") + public static Tensor ordered_map_incomplete_size(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapIncompleteSize") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -18802,7 +18802,7 @@ namespace Tensorflow.Operations /// this op will block until it does. This Op is optimized for /// performance. /// - public static Tensor[] ordered_map_peek (Tensor key, Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapPeek") + public static Tensor[] ordered_map_peek(Tensor key, Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapPeek") { var dict = new Dictionary(); dict["key"] = key; @@ -18842,7 +18842,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor ordered_map_size (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapSize") + public static Tensor ordered_map_size(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapSize") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -18895,7 +18895,7 @@ namespace Tensorflow.Operations /// /// associative container. Elements are ordered by key. /// - public static Operation ordered_map_stage (Tensor key, Tensor indices, Tensor[] values, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapStage") + public static Operation ordered_map_stage(Tensor key, Tensor indices, Tensor[] values, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapStage") { var dict = new Dictionary(); dict["key"] = key; @@ -18942,7 +18942,7 @@ namespace Tensorflow.Operations /// from the underlying container. If the underlying container /// does not contain this key, the op will block until it does. /// - public static Tensor[] ordered_map_unstage (Tensor key, Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapUnstage") + public static Tensor[] ordered_map_unstage(Tensor key, Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapUnstage") { var dict = new Dictionary(); dict["key"] = key; @@ -18991,7 +18991,7 @@ namespace Tensorflow.Operations /// key from the underlying container. If the underlying container /// does not contain elements, the op will block until it does. /// - public static (Tensor key, Tensor[] values) ordered_map_unstage_no_key (Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapUnstageNoKey") + public static (Tensor key, Tensor[] values) ordered_map_unstage_no_key(Tensor indices, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "OrderedMapUnstageNoKey") { var dict = new Dictionary(); dict["indices"] = indices; @@ -19037,7 +19037,7 @@ namespace Tensorflow.Operations /// /// block indefinitely until data is available. /// - public static Tensor outfeed_dequeue (TF_DataType dtype, TensorShape shape, int? device_ordinal = null, string name = "OutfeedDequeue") + public static Tensor outfeed_dequeue(TF_DataType dtype, TensorShape shape, int? device_ordinal = null, string name = "OutfeedDequeue") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -19075,7 +19075,7 @@ namespace Tensorflow.Operations /// tuple. This operations will block indefinitely until data is available. /// Output i corresponds to XLA tuple element i. /// - public static Tensor[] outfeed_dequeue_tuple (TF_DataType[] dtypes, TensorShape[] shapes, int? device_ordinal = null, string name = "OutfeedDequeueTuple") + public static Tensor[] outfeed_dequeue_tuple(TF_DataType[] dtypes, TensorShape[] shapes, int? device_ordinal = null, string name = "OutfeedDequeueTuple") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -19100,7 +19100,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation outfeed_enqueue (Tensor input, string name = "OutfeedEnqueue") + public static Operation outfeed_enqueue(Tensor input, string name = "OutfeedEnqueue") { var dict = new Dictionary(); dict["input"] = input; @@ -19121,7 +19121,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation outfeed_enqueue_tuple (Tensor[] inputs, string name = "OutfeedEnqueueTuple") + public static Operation outfeed_enqueue_tuple(Tensor[] inputs, string name = "OutfeedEnqueueTuple") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -19167,7 +19167,7 @@ namespace Tensorflow.Operations /// /// This is the opposite of unpack. /// - public static Tensor pack (Tensor[] values, int? axis = null, string name = "Pack") + public static Tensor pack(Tensor[] values, int? axis = null, string name = "Pack") { var dict = new Dictionary(); dict["values"] = values; @@ -19215,7 +19215,7 @@ namespace Tensorflow.Operations /// /// /// - public static Tensor pad (Tensor input, Tensor paddings, string name = "Pad") + public static Tensor pad(Tensor input, Tensor paddings, string name = "Pad") { var dict = new Dictionary(); dict["input"] = input; @@ -19265,7 +19265,7 @@ namespace Tensorflow.Operations /// [0, 0, 0, 0, 0, 0]] /// /// - public static Tensor pad_v2 (Tensor input, Tensor paddings, Tensor constant_values, string name = "PadV2") + public static Tensor pad_v2(Tensor input, Tensor paddings, Tensor constant_values, string name = "PadV2") { var dict = new Dictionary(); dict["input"] = input; @@ -19303,7 +19303,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor padded_batch_dataset (Tensor input_dataset, Tensor batch_size, Tensor[] padded_shapes, Tensor[] padding_values, TensorShape[] output_shapes, string name = "PaddedBatchDataset") + public static Tensor padded_batch_dataset(Tensor input_dataset, Tensor batch_size, Tensor[] padded_shapes, Tensor[] padding_values, TensorShape[] output_shapes, string name = "PaddedBatchDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -19347,7 +19347,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor padded_batch_dataset_v2 (Tensor input_dataset, Tensor batch_size, Tensor[] padded_shapes, Tensor[] padding_values, Tensor drop_remainder, TensorShape[] output_shapes, string name = "PaddedBatchDatasetV2") + public static Tensor padded_batch_dataset_v2(Tensor input_dataset, Tensor batch_size, Tensor[] padded_shapes, Tensor[] padding_values, Tensor drop_remainder, TensorShape[] output_shapes, string name = "PaddedBatchDatasetV2") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -19401,7 +19401,7 @@ namespace Tensorflow.Operations /// to 0 in the shape attr. In this case DequeueMany will pad up to the maximum /// size of any given element in the minibatch. See below for details. /// - public static Tensor padding_f_i_f_o_queue (TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "PaddingFIFOQueue") + public static Tensor padding_f_i_f_o_queue(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "PaddingFIFOQueue") { var dict = new Dictionary(); dict["component_types"] = component_types; @@ -19458,7 +19458,7 @@ namespace Tensorflow.Operations /// to 0 in the shape attr. In this case DequeueMany will pad up to the maximum /// size of any given element in the minibatch. See below for details. /// - public static Tensor padding_f_i_f_o_queue_v2 (TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "PaddingFIFOQueueV2") + public static Tensor padding_f_i_f_o_queue_v2(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "PaddingFIFOQueueV2") { var dict = new Dictionary(); dict["component_types"] = component_types; @@ -19511,7 +19511,7 @@ namespace Tensorflow.Operations /// will copy pieces of the input into the output as they become available, in /// some situations this can provide a performance benefit. /// - public static Tensor parallel_concat (Tensor[] values, TensorShape shape, string name = "ParallelConcat") + public static Tensor parallel_concat(Tensor[] values, TensorShape shape, string name = "ParallelConcat") { var dict = new Dictionary(); dict["values"] = values; @@ -19596,7 +19596,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/DynamicStitch.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor parallel_dynamic_stitch (Tensor[] indices, Tensor[] data, string name = "ParallelDynamicStitch") + public static Tensor parallel_dynamic_stitch(Tensor[] indices, Tensor[] data, string name = "ParallelDynamicStitch") { var dict = new Dictionary(); dict["indices"] = indices; @@ -19644,7 +19644,7 @@ namespace Tensorflow.Operations /// scalar which applies to the entire output, or a vector of length shape[0] which /// stores the parameters for each batch. /// - public static Tensor parameterized_truncated_normal (Tensor shape, Tensor means, Tensor stdevs, Tensor minvals, Tensor maxvals, int? seed = null, int? seed2 = null, string name = "ParameterizedTruncatedNormal") + public static Tensor parameterized_truncated_normal(Tensor shape, Tensor means, Tensor stdevs, Tensor minvals, Tensor maxvals, int? seed = null, int? seed2 = null, string name = "ParameterizedTruncatedNormal") { var dict = new Dictionary(); dict["shape"] = shape; @@ -19729,7 +19729,7 @@ namespace Tensorflow.Operations /// dense_values : /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor[] sparse_indices, Tensor[] sparse_values, Tensor[] sparse_shapes, Tensor[] dense_values) parse_example (Tensor serialized, Tensor names, Tensor[] sparse_keys, Tensor[] dense_keys, Tensor[] dense_defaults, TF_DataType[] sparse_types, TensorShape[] dense_shapes, string name = "ParseExample") + public static (Tensor[] sparse_indices, Tensor[] sparse_values, Tensor[] sparse_shapes, Tensor[] dense_values) parse_example(Tensor serialized, Tensor names, Tensor[] sparse_keys, Tensor[] dense_keys, Tensor[] dense_defaults, TF_DataType[] sparse_types, TensorShape[] dense_shapes, string name = "ParseExample") { var dict = new Dictionary(); dict["serialized"] = serialized; @@ -19801,7 +19801,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor parse_example_dataset (Tensor input_dataset, Tensor num_parallel_calls, Tensor[] dense_defaults, string[] sparse_keys, string[] dense_keys, TF_DataType[] sparse_types, TensorShape[] dense_shapes, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ParseExampleDataset") + public static Tensor parse_example_dataset(Tensor input_dataset, Tensor num_parallel_calls, Tensor[] dense_defaults, string[] sparse_keys, string[] dense_keys, TF_DataType[] sparse_types, TensorShape[] dense_shapes, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ParseExampleDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -19923,7 +19923,7 @@ namespace Tensorflow.Operations /// feature_list_dense_lengths : /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor[] context_sparse_indices, Tensor[] context_sparse_values, Tensor[] context_sparse_shapes, Tensor[] context_dense_values, Tensor[] feature_list_sparse_indices, Tensor[] feature_list_sparse_values, Tensor[] feature_list_sparse_shapes, Tensor[] feature_list_dense_values, Tensor[] feature_list_dense_lengths) parse_sequence_example (Tensor serialized, Tensor debug_name, Tensor[] context_dense_defaults, string[] feature_list_dense_missing_assumed_empty, string[] context_sparse_keys, string[] context_dense_keys, string[] feature_list_sparse_keys, string[] feature_list_dense_keys, int? Ncontext_sparse = null, int? Ncontext_dense = null, int? Nfeature_list_sparse = null, int? Nfeature_list_dense = null, TF_DataType[] context_sparse_types = null, TF_DataType[] feature_list_dense_types = null, TensorShape[] context_dense_shapes = null, TF_DataType[] feature_list_sparse_types = null, TensorShape[] feature_list_dense_shapes = null, string name = "ParseSequenceExample") + public static (Tensor[] context_sparse_indices, Tensor[] context_sparse_values, Tensor[] context_sparse_shapes, Tensor[] context_dense_values, Tensor[] feature_list_sparse_indices, Tensor[] feature_list_sparse_values, Tensor[] feature_list_sparse_shapes, Tensor[] feature_list_dense_values, Tensor[] feature_list_dense_lengths) parse_sequence_example(Tensor serialized, Tensor debug_name, Tensor[] context_dense_defaults, string[] feature_list_dense_missing_assumed_empty, string[] context_sparse_keys, string[] context_dense_keys, string[] feature_list_sparse_keys, string[] feature_list_dense_keys, int? Ncontext_sparse = null, int? Ncontext_dense = null, int? Nfeature_list_sparse = null, int? Nfeature_list_dense = null, TF_DataType[] context_sparse_types = null, TF_DataType[] feature_list_dense_types = null, TensorShape[] context_dense_shapes = null, TF_DataType[] feature_list_sparse_types = null, TensorShape[] feature_list_dense_shapes = null, string name = "ParseSequenceExample") { var dict = new Dictionary(); dict["serialized"] = serialized; @@ -20029,7 +20029,7 @@ namespace Tensorflow.Operations /// dense_values : /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor[] sparse_indices, Tensor[] sparse_values, Tensor[] sparse_shapes, Tensor[] dense_values) parse_single_example (Tensor serialized, Tensor[] dense_defaults, int num_sparse, string[] sparse_keys, string[] dense_keys, TF_DataType[] sparse_types, TensorShape[] dense_shapes, string name = "ParseSingleExample") + public static (Tensor[] sparse_indices, Tensor[] sparse_values, Tensor[] sparse_shapes, Tensor[] dense_values) parse_single_example(Tensor serialized, Tensor[] dense_defaults, int num_sparse, string[] sparse_keys, string[] dense_keys, TF_DataType[] sparse_types, TensorShape[] dense_shapes, string name = "ParseSingleExample") { var dict = new Dictionary(); dict["serialized"] = serialized; @@ -20140,7 +20140,7 @@ namespace Tensorflow.Operations /// feature_list_dense_values : /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor[] context_sparse_indices, Tensor[] context_sparse_values, Tensor[] context_sparse_shapes, Tensor[] context_dense_values, Tensor[] feature_list_sparse_indices, Tensor[] feature_list_sparse_values, Tensor[] feature_list_sparse_shapes, Tensor[] feature_list_dense_values) parse_single_sequence_example (Tensor serialized, Tensor feature_list_dense_missing_assumed_empty, Tensor[] context_sparse_keys, Tensor[] context_dense_keys, Tensor[] feature_list_sparse_keys, Tensor[] feature_list_dense_keys, Tensor[] context_dense_defaults, Tensor debug_name, TF_DataType[] context_sparse_types = null, TF_DataType[] feature_list_dense_types = null, TensorShape[] context_dense_shapes = null, TF_DataType[] feature_list_sparse_types = null, TensorShape[] feature_list_dense_shapes = null, string name = "ParseSingleSequenceExample") + public static (Tensor[] context_sparse_indices, Tensor[] context_sparse_values, Tensor[] context_sparse_shapes, Tensor[] context_dense_values, Tensor[] feature_list_sparse_indices, Tensor[] feature_list_sparse_values, Tensor[] feature_list_sparse_shapes, Tensor[] feature_list_dense_values) parse_single_sequence_example(Tensor serialized, Tensor feature_list_dense_missing_assumed_empty, Tensor[] context_sparse_keys, Tensor[] context_dense_keys, Tensor[] feature_list_sparse_keys, Tensor[] feature_list_dense_keys, Tensor[] context_dense_defaults, Tensor debug_name, TF_DataType[] context_sparse_types = null, TF_DataType[] feature_list_dense_types = null, TensorShape[] context_dense_shapes = null, TF_DataType[] feature_list_sparse_types = null, TensorShape[] feature_list_dense_shapes = null, string name = "ParseSingleSequenceExample") { var dict = new Dictionary(); dict["serialized"] = serialized; @@ -20192,7 +20192,7 @@ namespace Tensorflow.Operations /// A Tensor of type out_type. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor parse_tensor (Tensor serialized, TF_DataType out_type, string name = "ParseTensor") + public static Tensor parse_tensor(Tensor serialized, TF_DataType out_type, string name = "ParseTensor") { var dict = new Dictionary(); dict["serialized"] = serialized; @@ -20224,7 +20224,7 @@ namespace Tensorflow.Operations /// intended as a way to represent a value that will always be fed, and to /// provide attrs that enable the fed value to be checked at runtime. /// - public static Tensor placeholder (TF_DataType dtype, TensorShape shape = null, string name = "Placeholder") + public static Tensor placeholder(TF_DataType dtype, TensorShape shape = null, string name = "Placeholder") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -20258,7 +20258,7 @@ namespace Tensorflow.Operations /// intended as a way to represent a value that will always be fed, and to /// provide attrs that enable the fed value to be checked at runtime. /// - public static Tensor placeholder_v2 (TF_DataType dtype, TensorShape shape, string name = "PlaceholderV2") + public static Tensor placeholder_v2(TF_DataType dtype, TensorShape shape, string name = "PlaceholderV2") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -20284,7 +20284,7 @@ namespace Tensorflow.Operations /// A placeholder tensor that defaults to input if it is not fed. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor placeholder_with_default (Tensor input, TensorShape shape, string name = "PlaceholderWithDefault") + public static Tensor placeholder_with_default(Tensor input, TensorShape shape, string name = "PlaceholderWithDefault") { var dict = new Dictionary(); dict["input"] = input; @@ -20314,7 +20314,7 @@ namespace Tensorflow.Operations /// /// where \\(\psi(x)\\) is the digamma function. /// - public static Tensor polygamma (Tensor a, Tensor x, string name = "Polygamma") + public static Tensor polygamma(Tensor a, Tensor x, string name = "Polygamma") { var dict = new Dictionary(); dict["a"] = a; @@ -20342,7 +20342,7 @@ namespace Tensorflow.Operations /// int32 or int64 and perform the bitcount on the result, than to feed in /// 8- or 16-bit inputs and then aggregate the resulting counts. /// - public static Tensor population_count (Tensor x, string name = "PopulationCount") + public static Tensor population_count(Tensor x, string name = "PopulationCount") { var dict = new Dictionary(); dict["x"] = x; @@ -20373,7 +20373,7 @@ namespace Tensorflow.Operations /// tf.pow(x, y) ==&gt; [[256, 65536], [9, 27]] /// /// - public static Tensor pow (Tensor x, Tensor y, string name = "Pow") + public static Tensor pow(Tensor x, Tensor y, string name = "Pow") { var dict = new Dictionary(); dict["x"] = x; @@ -20403,7 +20403,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor prefetch_dataset (Tensor input_dataset, Tensor buffer_size, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "PrefetchDataset") + public static Tensor prefetch_dataset(Tensor input_dataset, Tensor buffer_size, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "PrefetchDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -20440,7 +20440,7 @@ namespace Tensorflow.Operations /// op exists to prevent subtle bugs from silently returning unimplemented /// gradients in some corner cases. /// - public static Tensor prevent_gradient (Tensor input, string message = null, string name = "PreventGradient") + public static Tensor prevent_gradient(Tensor input, string message = null, string name = "PreventGradient") { var dict = new Dictionary(); dict["input"] = input; @@ -20478,7 +20478,7 @@ namespace Tensorflow.Operations /// /// Passes input through to output and prints data when evaluating. /// - public static Tensor print (Tensor input, Tensor[] data, string message = null, int? first_n = null, int? summarize = null, string name = "Print") + public static Tensor print(Tensor input, Tensor[] data, string message = null, int? first_n = null, int? summarize = null, string name = "Print") { var dict = new Dictionary(); dict["input"] = input; @@ -20532,7 +20532,7 @@ namespace Tensorflow.Operations /// and DequeueMany) on a PriorityQueue will all require (resp. output) one extra /// entry in their input (resp. output) lists. /// - public static Tensor priority_queue (TensorShape[] shapes, TF_DataType[] component_types = null, int? capacity = null, string container = null, string shared_name = null, string name = "PriorityQueue") + public static Tensor priority_queue(TensorShape[] shapes, TF_DataType[] component_types = null, int? capacity = null, string container = null, string shared_name = null, string name = "PriorityQueue") { var dict = new Dictionary(); dict["shapes"] = shapes; @@ -20587,7 +20587,7 @@ namespace Tensorflow.Operations /// and DequeueMany) on a PriorityQueue will all require (resp. output) one extra /// entry in their input (resp. output) lists. /// - public static Tensor priority_queue_v2 (TensorShape[] shapes, TF_DataType[] component_types = null, int? capacity = null, string container = null, string shared_name = null, string name = "PriorityQueueV2") + public static Tensor priority_queue_v2(TensorShape[] shapes, TF_DataType[] component_types = null, int? capacity = null, string container = null, string shared_name = null, string name = "PriorityQueueV2") { var dict = new Dictionary(); dict["shapes"] = shapes; @@ -20629,7 +20629,7 @@ namespace Tensorflow.Operations /// axis. If keep_dims is true, the reduced dimensions are /// retained with length 1. /// - public static Tensor prod (Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Prod") + public static Tensor prod(Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Prod") { var dict = new Dictionary(); dict["input"] = input; @@ -20675,7 +20675,7 @@ namespace Tensorflow.Operations /// q_full, r_full = qr(a, full_matrices=True) /// /// - public static (Tensor q, Tensor r) qr (Tensor input, bool? full_matrices = null, string name = "Qr") + public static (Tensor q, Tensor r) qr(Tensor input, bool? full_matrices = null, string name = "Qr") { var dict = new Dictionary(); dict["input"] = input; @@ -20709,7 +20709,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor quantize_and_dequantize (Tensor input, bool? signed_input = null, int? num_bits = null, bool? range_given = null, float? input_min = null, float? input_max = null, string name = "QuantizeAndDequantize") + public static Tensor quantize_and_dequantize(Tensor input, bool? signed_input = null, int? num_bits = null, bool? range_given = null, float? input_min = null, float? input_max = null, string name = "QuantizeAndDequantize") { var dict = new Dictionary(); dict["input"] = input; @@ -20811,7 +20811,7 @@ namespace Tensorflow.Operations /// output = round(clamp(value, input_min, input_max) * scale_factor) / scale_factor. /// /// - public static Tensor quantize_and_dequantize_v2 (Tensor input, Tensor input_min, Tensor input_max, bool? signed_input = null, int? num_bits = null, bool? range_given = null, string name = "QuantizeAndDequantizeV2") + public static Tensor quantize_and_dequantize_v2(Tensor input, Tensor input_min, Tensor input_max, bool? signed_input = null, int? num_bits = null, bool? range_given = null, string name = "QuantizeAndDequantizeV2") { var dict = new Dictionary(); dict["input"] = input; @@ -20852,7 +20852,7 @@ namespace Tensorflow.Operations /// This is almost identical to QuantizeAndDequantizeV2, except that num_bits is a /// tensor, so its value can change during training. /// - public static Tensor quantize_and_dequantize_v3 (Tensor input, Tensor input_min, Tensor input_max, Tensor num_bits, bool? signed_input = null, bool? range_given = null, string name = "QuantizeAndDequantizeV3") + public static Tensor quantize_and_dequantize_v3(Tensor input, Tensor input_min, Tensor input_max, Tensor num_bits, bool? signed_input = null, bool? range_given = null, string name = "QuantizeAndDequantizeV3") { var dict = new Dictionary(); dict["input"] = input; @@ -20916,7 +20916,7 @@ namespace Tensorflow.Operations /// that output into this operator, we can reduce it from 32 bits down to 8 with /// minimal loss of accuracy. /// - public static (Tensor output, Tensor output_min, Tensor output_max) quantize_down_and_shrink_range (Tensor input, Tensor input_min, Tensor input_max, TF_DataType out_type, string name = "QuantizeDownAndShrinkRange") + public static (Tensor output, Tensor output_min, Tensor output_max) quantize_down_and_shrink_range(Tensor input, Tensor input_min, Tensor input_max, TF_DataType out_type, string name = "QuantizeDownAndShrinkRange") { var dict = new Dictionary(); dict["input"] = input; @@ -21059,7 +21059,7 @@ namespace Tensorflow.Operations /// quantized values map to the same float value, which causes problems for /// operations that have to perform further calculations on them. /// - public static (Tensor output, Tensor output_min, Tensor output_max) quantize_v2 (Tensor input, Tensor min_range, Tensor max_range, TF_DataType T, string mode = null, string round_mode = null, string name = "QuantizeV2") + public static (Tensor output, Tensor output_min, Tensor output_max) quantize_v2(Tensor input, Tensor min_range, Tensor max_range, TF_DataType T, string mode = null, string round_mode = null, string name = "QuantizeV2") { var dict = new Dictionary(); dict["input"] = input; @@ -21112,7 +21112,7 @@ namespace Tensorflow.Operations /// broadcasting [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor z, Tensor min_z, Tensor max_z) quantized_add (Tensor x, Tensor y, Tensor min_x, Tensor max_x, Tensor min_y, Tensor max_y, TF_DataType? Toutput = null, string name = "QuantizedAdd") + public static (Tensor z, Tensor min_z, Tensor max_z) quantized_add(Tensor x, Tensor y, Tensor min_x, Tensor max_x, Tensor min_y, Tensor max_y, TF_DataType? Toutput = null, string name = "QuantizedAdd") { var dict = new Dictionary(); dict["x"] = x; @@ -21167,7 +21167,7 @@ namespace Tensorflow.Operations /// max_output : The float value that the highest quantized output value represents. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor output, Tensor min_output, Tensor max_output) quantized_avg_pool (Tensor input, Tensor min_input, Tensor max_input, int[] ksize, int[] strides, string padding, string name = "QuantizedAvgPool") + public static (Tensor output, Tensor min_output, Tensor max_output) quantized_avg_pool(Tensor input, Tensor min_input, Tensor max_input, int[] ksize, int[] strides, string padding, string name = "QuantizedAvgPool") { var dict = new Dictionary(); dict["input"] = input; @@ -21265,7 +21265,7 @@ namespace Tensorflow.Operations /// This op is deprecated and will be removed in the future. Prefer /// tf.nn.batch_normalization. /// - public static (Tensor result, Tensor result_min, Tensor result_max) quantized_batch_norm_with_global_normalization (Tensor t, Tensor t_min, Tensor t_max, Tensor m, Tensor m_min, Tensor m_max, Tensor v, Tensor v_min, Tensor v_max, Tensor beta, Tensor beta_min, Tensor beta_max, Tensor gamma, Tensor gamma_min, Tensor gamma_max, TF_DataType out_type, float variance_epsilon, bool scale_after_normalization, string name = "QuantizedBatchNormWithGlobalNormalization") + public static (Tensor result, Tensor result_min, Tensor result_max) quantized_batch_norm_with_global_normalization(Tensor t, Tensor t_min, Tensor t_max, Tensor m, Tensor m_min, Tensor m_max, Tensor v, Tensor v_min, Tensor v_max, Tensor beta, Tensor beta_min, Tensor beta_max, Tensor gamma, Tensor gamma_min, Tensor gamma_max, TF_DataType out_type, float variance_epsilon, bool scale_after_normalization, string name = "QuantizedBatchNormWithGlobalNormalization") { var dict = new Dictionary(); dict["t"] = t; @@ -21330,7 +21330,7 @@ namespace Tensorflow.Operations /// /// Broadcasts the values of bias on dimensions 0..N-2 of 'input'. /// - public static (Tensor output, Tensor min_out, Tensor max_out) quantized_bias_add (Tensor input, Tensor bias, Tensor min_input, Tensor max_input, Tensor min_bias, Tensor max_bias, TF_DataType out_type, string name = "QuantizedBiasAdd") + public static (Tensor output, Tensor min_out, Tensor max_out) quantized_bias_add(Tensor input, Tensor bias, Tensor min_input, Tensor max_input, Tensor min_bias, Tensor max_bias, TF_DataType out_type, string name = "QuantizedBiasAdd") { var dict = new Dictionary(); dict["input"] = input; @@ -21377,7 +21377,7 @@ namespace Tensorflow.Operations /// output_max : The float value that the maximum quantized output value represents. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor output, Tensor output_min, Tensor output_max) quantized_concat (Tensor concat_dim, Tensor[] values, Tensor[] input_mins, Tensor[] input_maxes, string name = "QuantizedConcat") + public static (Tensor output, Tensor output_min, Tensor output_max) quantized_concat(Tensor concat_dim, Tensor[] values, Tensor[] input_mins, Tensor[] input_maxes, string name = "QuantizedConcat") { var dict = new Dictionary(); dict["concat_dim"] = concat_dim; @@ -21446,7 +21446,7 @@ namespace Tensorflow.Operations /// This means that you can only interpret the quantized output in the same way, by /// taking the returned minimum and maximum values into account. /// - public static (Tensor output, Tensor min_output, Tensor max_output) quantized_conv2d (Tensor input, Tensor filter, Tensor min_input, Tensor max_input, Tensor min_filter, Tensor max_filter, int[] strides, string padding, TF_DataType? out_type = null, int[] dilations = null, string name = "QuantizedConv2D") + public static (Tensor output, Tensor min_output, Tensor max_output) quantized_conv2d(Tensor input, Tensor filter, Tensor min_input, Tensor max_input, Tensor min_filter, Tensor max_filter, int[] strides, string padding, TF_DataType? out_type = null, int[] dilations = null, string name = "QuantizedConv2D") { var dict = new Dictionary(); dict["input"] = input; @@ -21508,7 +21508,7 @@ namespace Tensorflow.Operations /// y_max : The value represented by the highest quantized output. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor y, Tensor y_min, Tensor y_max) quantized_instance_norm (Tensor x, Tensor x_min, Tensor x_max, bool? output_range_given = null, float? given_y_min = null, float? given_y_max = null, float? variance_epsilon = null, float? min_separation = null, string name = "QuantizedInstanceNorm") + public static (Tensor y, Tensor y_min, Tensor y_max) quantized_instance_norm(Tensor x, Tensor x_min, Tensor x_max, bool? output_range_given = null, float? given_y_min = null, float? given_y_max = null, float? variance_epsilon = null, float? min_separation = null, string name = "QuantizedInstanceNorm") { var dict = new Dictionary(); dict["x"] = x; @@ -21581,7 +21581,7 @@ namespace Tensorflow.Operations /// outer dimension of b (after being transposed if transposed_b is /// non-zero). /// - public static (Tensor output, Tensor min_out, Tensor max_out) quantized_mat_mul (Tensor a, Tensor b, Tensor min_a, Tensor max_a, Tensor min_b, Tensor max_b, TF_DataType? Toutput = null, bool? transpose_a = null, bool? transpose_b = null, TF_DataType? Tactivation = null, string name = "QuantizedMatMul") + public static (Tensor output, Tensor min_out, Tensor max_out) quantized_mat_mul(Tensor a, Tensor b, Tensor min_a, Tensor max_a, Tensor min_b, Tensor max_b, TF_DataType? Toutput = null, bool? transpose_a = null, bool? transpose_b = null, TF_DataType? Tactivation = null, string name = "QuantizedMatMul") { var dict = new Dictionary(); dict["a"] = a; @@ -21642,7 +21642,7 @@ namespace Tensorflow.Operations /// max_output : The float value that the highest quantized output value represents. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor output, Tensor min_output, Tensor max_output) quantized_max_pool (Tensor input, Tensor min_input, Tensor max_input, int[] ksize, int[] strides, string padding, string name = "QuantizedMaxPool") + public static (Tensor output, Tensor min_output, Tensor max_output) quantized_max_pool(Tensor input, Tensor min_input, Tensor max_input, int[] ksize, int[] strides, string padding, string name = "QuantizedMaxPool") { var dict = new Dictionary(); dict["input"] = input; @@ -21693,7 +21693,7 @@ namespace Tensorflow.Operations /// broadcasting [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor z, Tensor min_z, Tensor max_z) quantized_mul (Tensor x, Tensor y, Tensor min_x, Tensor max_x, Tensor min_y, Tensor max_y, TF_DataType? Toutput = null, string name = "QuantizedMul") + public static (Tensor z, Tensor min_z, Tensor max_z) quantized_mul(Tensor x, Tensor y, Tensor min_x, Tensor max_x, Tensor min_y, Tensor max_y, TF_DataType? Toutput = null, string name = "QuantizedMul") { var dict = new Dictionary(); dict["x"] = x; @@ -21735,7 +21735,7 @@ namespace Tensorflow.Operations /// max_activations : The float value that the highest quantized value represents. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor activations, Tensor min_activations, Tensor max_activations) quantized_relu (Tensor features, Tensor min_features, Tensor max_features, TF_DataType? out_type = null, string name = "QuantizedRelu") + public static (Tensor activations, Tensor min_activations, Tensor max_activations) quantized_relu(Tensor features, Tensor min_features, Tensor max_features, TF_DataType? out_type = null, string name = "QuantizedRelu") { var dict = new Dictionary(); dict["features"] = features; @@ -21774,7 +21774,7 @@ namespace Tensorflow.Operations /// max_activations : The float value that the highest quantized value represents. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor activations, Tensor min_activations, Tensor max_activations) quantized_relu6 (Tensor features, Tensor min_features, Tensor max_features, TF_DataType? out_type = null, string name = "QuantizedRelu6") + public static (Tensor activations, Tensor min_activations, Tensor max_activations) quantized_relu6(Tensor features, Tensor min_features, Tensor max_features, TF_DataType? out_type = null, string name = "QuantizedRelu6") { var dict = new Dictionary(); dict["features"] = features; @@ -21815,7 +21815,7 @@ namespace Tensorflow.Operations /// max_activations : The float value that the highest quantized value represents. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor activations, Tensor min_activations, Tensor max_activations) quantized_relu_x (Tensor features, Tensor max_value, Tensor min_features, Tensor max_features, TF_DataType? out_type = null, string name = "QuantizedReluX") + public static (Tensor activations, Tensor min_activations, Tensor max_activations) quantized_relu_x(Tensor features, Tensor max_value, Tensor min_features, Tensor max_features, TF_DataType? out_type = null, string name = "QuantizedReluX") { var dict = new Dictionary(); dict["features"] = features; @@ -21858,7 +21858,7 @@ namespace Tensorflow.Operations /// /// /// - public static (Tensor output, Tensor output_min, Tensor output_max) quantized_reshape (Tensor tensor, Tensor shape, Tensor input_min, Tensor input_max, string name = "QuantizedReshape") + public static (Tensor output, Tensor output_min, Tensor output_max) quantized_reshape(Tensor tensor, Tensor shape, Tensor input_min, Tensor input_max, string name = "QuantizedReshape") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -21905,7 +21905,7 @@ namespace Tensorflow.Operations /// /// Input images and output images must be quantized types. /// - public static (Tensor resized_images, Tensor out_min, Tensor out_max) quantized_resize_bilinear (Tensor images, Tensor size, Tensor min, Tensor max, bool? align_corners = null, string name = "QuantizedResizeBilinear") + public static (Tensor resized_images, Tensor out_min, Tensor out_max) quantized_resize_bilinear(Tensor images, Tensor size, Tensor min, Tensor max, bool? align_corners = null, string name = "QuantizedResizeBilinear") { var dict = new Dictionary(); dict["images"] = images; @@ -21945,7 +21945,7 @@ namespace Tensorflow.Operations /// sufficient elements remain in the queue. Subsequent Dequeue(Many) /// operations that would block will fail immediately. /// - public static Operation queue_close (Tensor handle, bool? cancel_pending_enqueues = null, string name = "QueueClose") + public static Operation queue_close(Tensor handle, bool? cancel_pending_enqueues = null, string name = "QueueClose") { var dict = new Dictionary(); dict["handle"] = handle; @@ -21978,7 +21978,7 @@ namespace Tensorflow.Operations /// sufficient elements remain in the queue. Subsequent Dequeue(Many) /// operations that would block will fail immediately. /// - public static Operation queue_close_v2 (Tensor handle, bool? cancel_pending_enqueues = null, string name = "QueueCloseV2") + public static Operation queue_close_v2(Tensor handle, bool? cancel_pending_enqueues = null, string name = "QueueCloseV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22018,7 +22018,7 @@ namespace Tensorflow.Operations /// N.B. If the queue is empty, this operation will block until an element /// has been dequeued (or 'timeout_ms' elapses, if specified). /// - public static Tensor[] queue_dequeue (Tensor handle, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeue") + public static Tensor[] queue_dequeue(Tensor handle, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeue") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22071,7 +22071,7 @@ namespace Tensorflow.Operations /// N.B. If the queue is empty, this operation will block until n elements /// have been dequeued (or 'timeout_ms' elapses, if specified). /// - public static Tensor[] queue_dequeue_many (Tensor handle, Tensor n, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueMany") + public static Tensor[] queue_dequeue_many(Tensor handle, Tensor n, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueMany") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22125,7 +22125,7 @@ namespace Tensorflow.Operations /// N.B. If the queue is empty, this operation will block until n elements /// have been dequeued (or 'timeout_ms' elapses, if specified). /// - public static Tensor[] queue_dequeue_many_v2 (Tensor handle, Tensor n, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueManyV2") + public static Tensor[] queue_dequeue_many_v2(Tensor handle, Tensor n, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueManyV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22183,7 +22183,7 @@ namespace Tensorflow.Operations /// the tuples stored in the given queue, and output i is the ith /// component of the dequeued tuple. /// - public static Tensor[] queue_dequeue_up_to (Tensor handle, Tensor n, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueUpTo") + public static Tensor[] queue_dequeue_up_to(Tensor handle, Tensor n, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueUpTo") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22241,7 +22241,7 @@ namespace Tensorflow.Operations /// the tuples stored in the given queue, and output i is the ith /// component of the dequeued tuple. /// - public static Tensor[] queue_dequeue_up_to_v2 (Tensor handle, Tensor n, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueUpToV2") + public static Tensor[] queue_dequeue_up_to_v2(Tensor handle, Tensor n, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueUpToV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22285,7 +22285,7 @@ namespace Tensorflow.Operations /// N.B. If the queue is empty, this operation will block until an element /// has been dequeued (or 'timeout_ms' elapses, if specified). /// - public static Tensor[] queue_dequeue_v2 (Tensor handle, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueV2") + public static Tensor[] queue_dequeue_v2(Tensor handle, TF_DataType[] component_types, int? timeout_ms = null, string name = "QueueDequeueV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22325,7 +22325,7 @@ namespace Tensorflow.Operations /// N.B. If the queue is full, this operation will block until the given /// element has been enqueued (or 'timeout_ms' elapses, if specified). /// - public static Operation queue_enqueue (Tensor handle, Tensor[] components, int? timeout_ms = null, string name = "QueueEnqueue") + public static Operation queue_enqueue(Tensor handle, Tensor[] components, int? timeout_ms = null, string name = "QueueEnqueue") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22368,7 +22368,7 @@ namespace Tensorflow.Operations /// N.B. If the queue is full, this operation will block until the given /// elements have been enqueued (or 'timeout_ms' elapses, if specified). /// - public static Operation queue_enqueue_many (Tensor handle, Tensor[] components, int? timeout_ms = null, string name = "QueueEnqueueMany") + public static Operation queue_enqueue_many(Tensor handle, Tensor[] components, int? timeout_ms = null, string name = "QueueEnqueueMany") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22411,7 +22411,7 @@ namespace Tensorflow.Operations /// N.B. If the queue is full, this operation will block until the given /// elements have been enqueued (or 'timeout_ms' elapses, if specified). /// - public static Operation queue_enqueue_many_v2 (Tensor handle, Tensor[] components, int? timeout_ms = null, string name = "QueueEnqueueManyV2") + public static Operation queue_enqueue_many_v2(Tensor handle, Tensor[] components, int? timeout_ms = null, string name = "QueueEnqueueManyV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22449,7 +22449,7 @@ namespace Tensorflow.Operations /// N.B. If the queue is full, this operation will block until the given /// element has been enqueued (or 'timeout_ms' elapses, if specified). /// - public static Operation queue_enqueue_v2 (Tensor handle, Tensor[] components, int? timeout_ms = null, string name = "QueueEnqueueV2") + public static Operation queue_enqueue_v2(Tensor handle, Tensor[] components, int? timeout_ms = null, string name = "QueueEnqueueV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22476,7 +22476,7 @@ namespace Tensorflow.Operations /// This operation returns true if the queue is closed and false if the queue /// is open. /// - public static Tensor queue_is_closed (Tensor handle, string name = "QueueIsClosed") + public static Tensor queue_is_closed(Tensor handle, string name = "QueueIsClosed") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22500,7 +22500,7 @@ namespace Tensorflow.Operations /// This operation returns true if the queue is closed and false if the queue /// is open. /// - public static Tensor queue_is_closed_v2 (Tensor handle, string name = "QueueIsClosedV2") + public static Tensor queue_is_closed_v2(Tensor handle, string name = "QueueIsClosedV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22521,7 +22521,7 @@ namespace Tensorflow.Operations /// The number of elements in the given queue. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor queue_size (Tensor handle, string name = "QueueSize") + public static Tensor queue_size(Tensor handle, string name = "QueueSize") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22542,7 +22542,7 @@ namespace Tensorflow.Operations /// The number of elements in the given queue. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor queue_size_v2 (Tensor handle, string name = "QueueSizeV2") + public static Tensor queue_size_v2(Tensor handle, string name = "QueueSizeV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -22584,7 +22584,7 @@ namespace Tensorflow.Operations /// corresponding dimension of input, the dimension is cropped. If it is larger, /// the dimension is padded with zeros. /// - public static Tensor r_f_f_t (Tensor input, Tensor fft_length, string name = "RFFT") + public static Tensor r_f_f_t(Tensor input, Tensor fft_length, string name = "RFFT") { var dict = new Dictionary(); dict["input"] = input; @@ -22629,7 +22629,7 @@ namespace Tensorflow.Operations /// corresponding dimension of input, the dimension is cropped. If it is larger, /// the dimension is padded with zeros. /// - public static Tensor r_f_f_t2d (Tensor input, Tensor fft_length, string name = "RFFT2D") + public static Tensor r_f_f_t2d(Tensor input, Tensor fft_length, string name = "RFFT2D") { var dict = new Dictionary(); dict["input"] = input; @@ -22674,7 +22674,7 @@ namespace Tensorflow.Operations /// corresponding dimension of input, the dimension is cropped. If it is larger, /// the dimension is padded with zeros. /// - public static Tensor r_f_f_t3d (Tensor input, Tensor fft_length, string name = "RFFT3D") + public static Tensor r_f_f_t3d(Tensor input, Tensor fft_length, string name = "RFFT3D") { var dict = new Dictionary(); dict["input"] = input; @@ -22705,7 +22705,7 @@ namespace Tensorflow.Operations /// output[..., 2] contains value. All HSV values are in [0,1]. A hue of 0 /// corresponds to pure red, hue 1/3 is pure green, and 2/3 is pure blue. /// - public static Tensor r_g_b_to_h_s_v (Tensor images, string name = "RGBToHSV") + public static Tensor r_g_b_to_h_s_v(Tensor images, string name = "RGBToHSV") { var dict = new Dictionary(); dict["images"] = images; @@ -22745,7 +22745,7 @@ namespace Tensorflow.Operations /// rectangle from that location. The random location is picked so the cropped /// area will fit inside the original image. /// - public static Tensor random_crop (Tensor image, Tensor size, int? seed = null, int? seed2 = null, string name = "RandomCrop") + public static Tensor random_crop(Tensor image, Tensor size, int? seed = null, int? seed2 = null, string name = "RandomCrop") { var dict = new Dictionary(); dict["image"] = image; @@ -22781,7 +22781,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor random_dataset (Tensor seed, Tensor seed2, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RandomDataset") + public static Tensor random_dataset(Tensor seed, Tensor seed2, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RandomDataset") { var dict = new Dictionary(); dict["seed"] = seed; @@ -22825,7 +22825,7 @@ namespace Tensorflow.Operations /// transformation-rejection from pairs of uniform and normal random variables. /// See http://dl.acm.org/citation.cfm?id=358414 /// - public static Tensor random_gamma (Tensor shape, Tensor alpha, int? seed = null, int? seed2 = null, string name = "RandomGamma") + public static Tensor random_gamma(Tensor shape, Tensor alpha, int? seed = null, int? seed2 = null, string name = "RandomGamma") { var dict = new Dictionary(); dict["shape"] = shape; @@ -22851,7 +22851,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor random_gamma_grad (Tensor alpha, Tensor sample, string name = "RandomGammaGrad") + public static Tensor random_gamma_grad(Tensor alpha, Tensor sample, string name = "RandomGammaGrad") { var dict = new Dictionary(); dict["alpha"] = alpha; @@ -22877,7 +22877,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor random_poisson (Tensor shape, Tensor rate, int? seed = null, int? seed2 = null, string name = "RandomPoisson") + public static Tensor random_poisson(Tensor shape, Tensor rate, int? seed = null, int? seed2 = null, string name = "RandomPoisson") { var dict = new Dictionary(); dict["shape"] = shape; @@ -22931,7 +22931,7 @@ namespace Tensorflow.Operations /// See Donald E. Knuth (1969). Seminumerical Algorithms. The Art of Computer /// Programming, Volume 2. Addison Wesley /// - public static Tensor random_poisson_v2 (Tensor shape, Tensor rate, int? seed = null, int? seed2 = null, TF_DataType? dtype = null, string name = "RandomPoissonV2") + public static Tensor random_poisson_v2(Tensor shape, Tensor rate, int? seed = null, int? seed2 = null, TF_DataType? dtype = null, string name = "RandomPoissonV2") { var dict = new Dictionary(); dict["shape"] = shape; @@ -22979,7 +22979,7 @@ namespace Tensorflow.Operations /// [5, 6]] [3, 4]] /// /// - public static Tensor random_shuffle (Tensor value, int? seed = null, int? seed2 = null, string name = "RandomShuffle") + public static Tensor random_shuffle(Tensor value, int? seed = null, int? seed2 = null, string name = "RandomShuffle") { var dict = new Dictionary(); dict["value"] = value; @@ -23035,7 +23035,7 @@ namespace Tensorflow.Operations /// The handle to the queue. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor random_shuffle_queue (TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, int? min_after_dequeue = null, int? seed = null, int? seed2 = null, string container = null, string shared_name = null, string name = "RandomShuffleQueue") + public static Tensor random_shuffle_queue(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, int? min_after_dequeue = null, int? seed = null, int? seed2 = null, string container = null, string shared_name = null, string name = "RandomShuffleQueue") { var dict = new Dictionary(); dict["component_types"] = component_types; @@ -23101,7 +23101,7 @@ namespace Tensorflow.Operations /// The handle to the queue. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor random_shuffle_queue_v2 (TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, int? min_after_dequeue = null, int? seed = null, int? seed2 = null, string container = null, string shared_name = null, string name = "RandomShuffleQueueV2") + public static Tensor random_shuffle_queue_v2(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, int? min_after_dequeue = null, int? seed = null, int? seed2 = null, string container = null, string shared_name = null, string name = "RandomShuffleQueueV2") { var dict = new Dictionary(); dict["component_types"] = component_types; @@ -23151,7 +23151,7 @@ namespace Tensorflow.Operations /// /// The generated values will have mean 0 and standard deviation 1. /// - public static Tensor random_standard_normal (Tensor shape, TF_DataType dtype, int? seed = null, int? seed2 = null, string name = "RandomStandardNormal") + public static Tensor random_standard_normal(Tensor shape, TF_DataType dtype, int? seed = null, int? seed2 = null, string name = "RandomStandardNormal") { var dict = new Dictionary(); dict["shape"] = shape; @@ -23193,7 +23193,7 @@ namespace Tensorflow.Operations /// The generated values follow a uniform distribution in the range [0, 1). The /// lower bound 0 is included in the range, while the upper bound 1 is excluded. /// - public static Tensor random_uniform (Tensor shape, TF_DataType dtype, int? seed = null, int? seed2 = null, string name = "RandomUniform") + public static Tensor random_uniform(Tensor shape, TF_DataType dtype, int? seed = null, int? seed2 = null, string name = "RandomUniform") { var dict = new Dictionary(); dict["shape"] = shape; @@ -23242,7 +23242,7 @@ namespace Tensorflow.Operations /// power of two. The bias is small for values of maxval - minval significantly /// smaller than the range of the output (either 2^32 or 2^64). /// - public static Tensor random_uniform_int (Tensor shape, Tensor minval, Tensor maxval, int? seed = null, int? seed2 = null, string name = "RandomUniformInt") + public static Tensor random_uniform_int(Tensor shape, Tensor minval, Tensor maxval, int? seed = null, int? seed2 = null, string name = "RandomUniformInt") { var dict = new Dictionary(); dict["shape"] = shape; @@ -23288,7 +23288,7 @@ namespace Tensorflow.Operations /// tf.range(start, limit, delta) ==&gt; [3, 6, 9, 12, 15] /// /// - public static Tensor range (Tensor start, Tensor limit, Tensor delta, string name = "Range") + public static Tensor range(Tensor start, Tensor limit, Tensor delta, string name = "Range") { var dict = new Dictionary(); dict["start"] = start; @@ -23322,7 +23322,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor range_dataset (Tensor start, Tensor stop, Tensor step, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RangeDataset") + public static Tensor range_dataset(Tensor start, Tensor stop, Tensor step, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RangeDataset") { var dict = new Dictionary(); dict["start"] = start; @@ -23360,7 +23360,7 @@ namespace Tensorflow.Operations /// of a tensor is the number of indices required to uniquely select each element /// of the tensor. Rank is also known as "order", "degree", or "ndims." /// - public static Tensor rank (Tensor input, string name = "Rank") + public static Tensor rank(Tensor input, string name = "Rank") { var dict = new Dictionary(); dict["input"] = input; @@ -23379,7 +23379,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor read_file (Tensor filename, string name = "ReadFile") + public static Tensor read_file(Tensor filename, string name = "ReadFile") { var dict = new Dictionary(); dict["filename"] = filename; @@ -23411,7 +23411,7 @@ namespace Tensorflow.Operations /// influenced by any of the writes which depend directly or indirectly on this /// operation. /// - public static Tensor read_variable_op (Tensor resource, TF_DataType dtype, string name = "ReadVariableOp") + public static Tensor read_variable_op(Tensor resource, TF_DataType dtype, string name = "ReadVariableOp") { var dict = new Dictionary(); dict["resource"] = resource; @@ -23436,7 +23436,7 @@ namespace Tensorflow.Operations /// This is the same as the number of ReaderRead executions that have /// succeeded. /// - public static Tensor reader_num_records_produced (Tensor reader_handle, string name = "ReaderNumRecordsProduced") + public static Tensor reader_num_records_produced(Tensor reader_handle, string name = "ReaderNumRecordsProduced") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23460,7 +23460,7 @@ namespace Tensorflow.Operations /// This is the same as the number of ReaderRead executions that have /// succeeded. /// - public static Tensor reader_num_records_produced_v2 (Tensor reader_handle, string name = "ReaderNumRecordsProducedV2") + public static Tensor reader_num_records_produced_v2(Tensor reader_handle, string name = "ReaderNumRecordsProducedV2") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23480,7 +23480,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor reader_num_work_units_completed (Tensor reader_handle, string name = "ReaderNumWorkUnitsCompleted") + public static Tensor reader_num_work_units_completed(Tensor reader_handle, string name = "ReaderNumWorkUnitsCompleted") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23500,7 +23500,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor reader_num_work_units_completed_v2 (Tensor reader_handle, string name = "ReaderNumWorkUnitsCompletedV2") + public static Tensor reader_num_work_units_completed_v2(Tensor reader_handle, string name = "ReaderNumWorkUnitsCompletedV2") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23531,7 +23531,7 @@ namespace Tensorflow.Operations /// Reader needs to start reading from a new file since it has finished /// with the previous file). /// - public static (Tensor key, Tensor value) reader_read (Tensor reader_handle, Tensor queue_handle, string name = "ReaderRead") + public static (Tensor key, Tensor value) reader_read(Tensor reader_handle, Tensor queue_handle, string name = "ReaderRead") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23570,7 +23570,7 @@ namespace Tensorflow.Operations /// with the previous file). /// It may return less than num_records even before the last batch. /// - public static (Tensor keys, Tensor values) reader_read_up_to (Tensor reader_handle, Tensor queue_handle, Tensor num_records, string name = "ReaderReadUpTo") + public static (Tensor keys, Tensor values) reader_read_up_to(Tensor reader_handle, Tensor queue_handle, Tensor num_records, string name = "ReaderReadUpTo") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23610,7 +23610,7 @@ namespace Tensorflow.Operations /// with the previous file). /// It may return less than num_records even before the last batch. /// - public static (Tensor keys, Tensor values) reader_read_up_to_v2 (Tensor reader_handle, Tensor queue_handle, Tensor num_records, string name = "ReaderReadUpToV2") + public static (Tensor keys, Tensor values) reader_read_up_to_v2(Tensor reader_handle, Tensor queue_handle, Tensor num_records, string name = "ReaderReadUpToV2") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23646,7 +23646,7 @@ namespace Tensorflow.Operations /// Reader needs to start reading from a new file since it has finished /// with the previous file). /// - public static (Tensor key, Tensor value) reader_read_v2 (Tensor reader_handle, Tensor queue_handle, string name = "ReaderReadV2") + public static (Tensor key, Tensor value) reader_read_v2(Tensor reader_handle, Tensor queue_handle, string name = "ReaderReadV2") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23670,7 +23670,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation reader_reset (Tensor reader_handle, string name = "ReaderReset") + public static Operation reader_reset(Tensor reader_handle, string name = "ReaderReset") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23690,7 +23690,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation reader_reset_v2 (Tensor reader_handle, string name = "ReaderResetV2") + public static Operation reader_reset_v2(Tensor reader_handle, string name = "ReaderResetV2") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23718,7 +23718,7 @@ namespace Tensorflow.Operations /// Not all Readers support being restored, so this can produce an /// Unimplemented error. /// - public static Operation reader_restore_state (Tensor reader_handle, Tensor state, string name = "ReaderRestoreState") + public static Operation reader_restore_state(Tensor reader_handle, Tensor state, string name = "ReaderRestoreState") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23747,7 +23747,7 @@ namespace Tensorflow.Operations /// Not all Readers support being restored, so this can produce an /// Unimplemented error. /// - public static Operation reader_restore_state_v2 (Tensor reader_handle, Tensor state, string name = "ReaderRestoreStateV2") + public static Operation reader_restore_state_v2(Tensor reader_handle, Tensor state, string name = "ReaderRestoreStateV2") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23772,7 +23772,7 @@ namespace Tensorflow.Operations /// Not all Readers support being serialized, so this can produce an /// Unimplemented error. /// - public static Tensor reader_serialize_state (Tensor reader_handle, string name = "ReaderSerializeState") + public static Tensor reader_serialize_state(Tensor reader_handle, string name = "ReaderSerializeState") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23796,7 +23796,7 @@ namespace Tensorflow.Operations /// Not all Readers support being serialized, so this can produce an /// Unimplemented error. /// - public static Tensor reader_serialize_state_v2 (Tensor reader_handle, string name = "ReaderSerializeStateV2") + public static Tensor reader_serialize_state_v2(Tensor reader_handle, string name = "ReaderSerializeStateV2") { var dict = new Dictionary(); dict["reader_handle"] = reader_handle; @@ -23830,7 +23830,7 @@ namespace Tensorflow.Operations /// tf.real(input) ==&gt; [-2.25, 3.25] /// /// - public static Tensor real (Tensor input, TF_DataType? Tout = null, string name = "Real") + public static Tensor real(Tensor input, TF_DataType? Tout = null, string name = "Real") { var dict = new Dictionary(); dict["input"] = input; @@ -23859,7 +23859,7 @@ namespace Tensorflow.Operations /// *NOTE*: Div supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor real_div (Tensor x, Tensor y, string name = "RealDiv") + public static Tensor real_div(Tensor x, Tensor y, string name = "RealDiv") { var dict = new Dictionary(); dict["x"] = x; @@ -23882,7 +23882,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = 1 / x\\). /// - public static Tensor reciprocal (Tensor x, string name = "Reciprocal") + public static Tensor reciprocal(Tensor x, string name = "Reciprocal") { var dict = new Dictionary(); dict["x"] = x; @@ -23907,7 +23907,7 @@ namespace Tensorflow.Operations /// Specifically, grad = -dy * y*y, where y = 1/x, and dy /// is the corresponding input gradient. /// - public static Tensor reciprocal_grad (Tensor y, Tensor dy, string name = "ReciprocalGrad") + public static Tensor reciprocal_grad(Tensor y, Tensor dy, string name = "ReciprocalGrad") { var dict = new Dictionary(); dict["y"] = y; @@ -23950,7 +23950,7 @@ namespace Tensorflow.Operations /// A tensor of shape [batch_size]. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor record_input (string file_pattern, int? file_random_seed = null, float? file_shuffle_shift_ratio = null, int? file_buffer_size = null, int? file_parallelism = null, int? batch_size = null, string compression_type = null, string name = "RecordInput") + public static Tensor record_input(string file_pattern, int? file_random_seed = null, float? file_shuffle_shift_ratio = null, int? file_buffer_size = null, int? file_parallelism = null, int? batch_size = null, string compression_type = null, string name = "RecordInput") { var dict = new Dictionary(); dict["file_pattern"] = file_pattern; @@ -24020,7 +24020,7 @@ namespace Tensorflow.Operations /// tf.reduce_join(a) = tf.reduce_join(a, [1, 0]) ==&gt; "abcd" /// /// - public static Tensor reduce_join (Tensor inputs, Tensor reduction_indices, bool? keep_dims = null, string separator = null, string name = "ReduceJoin") + public static Tensor reduce_join(Tensor inputs, Tensor reduction_indices, bool? keep_dims = null, string separator = null, string name = "ReduceJoin") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -24062,7 +24062,7 @@ namespace Tensorflow.Operations /// it may be changed in the child frame. At most parallel_iterations iterations /// are run in parallel in the child frame. /// - public static Tensor ref_enter (Tensor data, string frame_name, bool? is_constant = null, int? parallel_iterations = null, string name = "RefEnter") + public static Tensor ref_enter(Tensor data, string frame_name, bool? is_constant = null, int? parallel_iterations = null, string name = "RefEnter") { var dict = new Dictionary(); dict["data"] = data; @@ -24091,7 +24091,7 @@ namespace Tensorflow.Operations /// /// Exit makes its input data available to the parent frame. /// - public static Tensor ref_exit (Tensor data, string name = "RefExit") + public static Tensor ref_exit(Tensor data, string name = "RefExit") { var dict = new Dictionary(); dict["data"] = data; @@ -24110,7 +24110,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor ref_identity (Tensor input, string name = "RefIdentity") + public static Tensor ref_identity(Tensor input, string name = "RefIdentity") { var dict = new Dictionary(); dict["input"] = input; @@ -24140,7 +24140,7 @@ namespace Tensorflow.Operations /// Merge forwards the first tensor for become available to output, and sets /// value_index to its index in inputs. /// - public static (Tensor output, Tensor value_index) ref_merge (Tensor[] inputs, string name = "RefMerge") + public static (Tensor output, Tensor value_index) ref_merge(Tensor[] inputs, string name = "RefMerge") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -24164,7 +24164,7 @@ namespace Tensorflow.Operations /// The same tensor as data. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor ref_next_iteration (Tensor data, string name = "RefNextIteration") + public static Tensor ref_next_iteration(Tensor data, string name = "RefNextIteration") { var dict = new Dictionary(); dict["data"] = data; @@ -24188,7 +24188,7 @@ namespace Tensorflow.Operations /// The forwarded tensor. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor ref_select (Tensor index, Tensor[] inputs, string name = "RefSelect") + public static Tensor ref_select(Tensor index, Tensor[] inputs, string name = "RefSelect") { var dict = new Dictionary(); dict["index"] = index; @@ -24221,7 +24221,7 @@ namespace Tensorflow.Operations /// /// See also Switch and Merge. /// - public static (Tensor output_false, Tensor output_true) ref_switch (Tensor data, Tensor pred, string name = "RefSwitch") + public static (Tensor output_false, Tensor output_true) ref_switch(Tensor data, Tensor pred, string name = "RefSwitch") { var dict = new Dictionary(); dict["data"] = data; @@ -24257,7 +24257,7 @@ namespace Tensorflow.Operations /// /// The pattern follows the re2 syntax (https://github.com/google/re2/wiki/Syntax) /// - public static Tensor regex_full_match (Tensor input, Tensor pattern, string name = "RegexFullMatch") + public static Tensor regex_full_match(Tensor input, Tensor pattern, string name = "RegexFullMatch") { var dict = new Dictionary(); dict["input"] = input; @@ -24292,7 +24292,7 @@ namespace Tensorflow.Operations /// /// It follows the re2 syntax (https://github.com/google/re2/wiki/Syntax) /// - public static Tensor regex_replace (Tensor input, Tensor pattern, Tensor rewrite, bool? replace_global = null, string name = "RegexReplace") + public static Tensor regex_replace(Tensor input, Tensor pattern, Tensor rewrite, bool? replace_global = null, string name = "RegexReplace") { var dict = new Dictionary(); dict["input"] = input; @@ -24315,7 +24315,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor relu (Tensor features, string name = "Relu") + public static Tensor relu(Tensor features, string name = "Relu") { var dict = new Dictionary(); dict["features"] = features; @@ -24334,7 +24334,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor relu6 (Tensor features, string name = "Relu6") + public static Tensor relu6(Tensor features, string name = "Relu6") { var dict = new Dictionary(); dict["features"] = features; @@ -24360,7 +24360,7 @@ namespace Tensorflow.Operations /// gradients * (features &gt; 0) * (features &lt; 6). /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor relu6grad (Tensor gradients, Tensor features, string name = "Relu6Grad") + public static Tensor relu6grad(Tensor gradients, Tensor features, string name = "Relu6Grad") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -24386,7 +24386,7 @@ namespace Tensorflow.Operations /// gradients * (features &gt; 0). /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor relu_grad (Tensor gradients, Tensor features, string name = "ReluGrad") + public static Tensor relu_grad(Tensor gradients, Tensor features, string name = "ReluGrad") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -24425,7 +24425,7 @@ namespace Tensorflow.Operations /// to a remote processor and execute that graph. The execution results /// will be passed to consumer nodes as outputs of this node. /// - public static Tensor[] remote_fused_graph_execute (Tensor[] inputs, TF_DataType[] Toutputs, string serialized_remote_fused_graph_execute_info, string name = "RemoteFusedGraphExecute") + public static Tensor[] remote_fused_graph_execute(Tensor[] inputs, TF_DataType[] Toutputs, string serialized_remote_fused_graph_execute_info, string name = "RemoteFusedGraphExecute") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -24458,7 +24458,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor repeat_dataset (Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RepeatDataset") + public static Tensor repeat_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RepeatDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -24494,7 +24494,7 @@ namespace Tensorflow.Operations /// typically used to produce the requested_output_min and requested_output_max for /// Requantize. /// - public static (Tensor output_min, Tensor output_max) requantization_range (Tensor input, Tensor input_min, Tensor input_max, string name = "RequantizationRange") + public static (Tensor output_min, Tensor output_max) requantization_range(Tensor input, Tensor input_min, Tensor input_max, string name = "RequantizationRange") { var dict = new Dictionary(); dict["input"] = input; @@ -24546,7 +24546,7 @@ namespace Tensorflow.Operations /// input_max is 1.0f, and we are dealing with quint16 quantized data, then a 0 /// value in the 16-bit data should be interpreted as -1.0f, and a 65535 means 1.0f. /// - public static (Tensor output, Tensor output_min, Tensor output_max) requantize (Tensor input, Tensor input_min, Tensor input_max, Tensor requested_output_min, Tensor requested_output_max, TF_DataType out_type, string name = "Requantize") + public static (Tensor output, Tensor output_min, Tensor output_max) requantize(Tensor input, Tensor input_min, Tensor input_max, Tensor requested_output_min, Tensor requested_output_max, TF_DataType out_type, string name = "Requantize") { var dict = new Dictionary(); dict["input"] = input; @@ -24635,7 +24635,7 @@ namespace Tensorflow.Operations /// reshape(t, []) ==&gt; 7 /// /// - public static Tensor reshape (Tensor tensor, Tensor shape, string name = "Reshape") + public static Tensor reshape(Tensor tensor, Tensor shape, string name = "Reshape") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -24679,7 +24679,7 @@ namespace Tensorflow.Operations /// input pixel's contribution to the average is weighted by the fraction of its /// area that intersects the footprint. This is the same as OpenCV's INTER_AREA. /// - public static Tensor resize_area (Tensor images, Tensor size, bool? align_corners = null, string name = "ResizeArea") + public static Tensor resize_area(Tensor images, Tensor size, bool? align_corners = null, string name = "ResizeArea") { var dict = new Dictionary(); dict["images"] = images; @@ -24715,7 +24715,7 @@ namespace Tensorflow.Operations /// /// Input images can be of different types but output images are always float. /// - public static Tensor resize_bicubic (Tensor images, Tensor size, bool align_corners = false, bool half_pixel_centers = false, string name = "ResizeBicubic") + public static Tensor resize_bicubic(Tensor images, Tensor size, bool align_corners = false, bool half_pixel_centers = false, string name = "ResizeBicubic") { var dict = new Dictionary(); dict["images"] = images; @@ -24748,7 +24748,7 @@ namespace Tensorflow.Operations /// float or double. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor resize_bicubic_grad (Tensor grads, Tensor original_image, bool? align_corners = null, string name = "ResizeBicubicGrad") + public static Tensor resize_bicubic_grad(Tensor grads, Tensor original_image, bool? align_corners = null, string name = "ResizeBicubicGrad") { var dict = new Dictionary(); dict["grads"] = grads; @@ -24784,7 +24784,7 @@ namespace Tensorflow.Operations /// /// Input images can be of different types but output images are always float. /// - public static Tensor resize_bilinear (Tensor images, Tensor size, bool? align_corners = null, string name = "ResizeBilinear") + public static Tensor resize_bilinear(Tensor images, Tensor size, bool? align_corners = null, string name = "ResizeBilinear") { var dict = new Dictionary(); dict["images"] = images; @@ -24818,7 +24818,7 @@ namespace Tensorflow.Operations /// float or double. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor resize_bilinear_grad (Tensor grads, Tensor original_image, bool? align_corners = null, string name = "ResizeBilinearGrad") + public static Tensor resize_bilinear_grad(Tensor grads, Tensor original_image, bool? align_corners = null, string name = "ResizeBilinearGrad") { var dict = new Dictionary(); dict["grads"] = grads; @@ -24851,7 +24851,7 @@ namespace Tensorflow.Operations /// [batch, new_height, new_width, channels]. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor resize_nearest_neighbor (Tensor images, Tensor size, bool? align_corners = null, string name = "ResizeNearestNeighbor") + public static Tensor resize_nearest_neighbor(Tensor images, Tensor size, bool? align_corners = null, string name = "ResizeNearestNeighbor") { var dict = new Dictionary(); dict["images"] = images; @@ -24884,7 +24884,7 @@ namespace Tensorflow.Operations /// with respect to the input image. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor resize_nearest_neighbor_grad (Tensor grads, Tensor size, bool? align_corners = null, string name = "ResizeNearestNeighborGrad") + public static Tensor resize_nearest_neighbor_grad(Tensor grads, Tensor size, bool? align_corners = null, string name = "ResizeNearestNeighborGrad") { var dict = new Dictionary(); dict["grads"] = grads; @@ -24941,7 +24941,7 @@ namespace Tensorflow.Operations /// v_t &lt;- max(beta2 * v_{t-1}, abs(g)) /// variable &lt;- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon) /// - public static Operation resource_apply_ada_max (Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ResourceApplyAdaMax") + public static Operation resource_apply_ada_max(Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ResourceApplyAdaMax") { var dict = new Dictionary(); dict["var"] = var; @@ -24999,7 +24999,7 @@ namespace Tensorflow.Operations /// update_accum = rho() * update_accum + (1 - rho()) * update.square(); /// var -= update; /// - public static Operation resource_apply_adadelta (Tensor var, Tensor accum, Tensor accum_update, Tensor lr, Tensor rho, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ResourceApplyAdadelta") + public static Operation resource_apply_adadelta(Tensor var, Tensor accum, Tensor accum_update, Tensor lr, Tensor rho, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ResourceApplyAdadelta") { var dict = new Dictionary(); dict["var"] = var; @@ -25047,7 +25047,7 @@ namespace Tensorflow.Operations /// accum += grad * grad /// var -= lr * grad * (1 / sqrt(accum)) /// - public static Operation resource_apply_adagrad (Tensor var, Tensor accum, Tensor lr, Tensor grad, bool? use_locking = null, bool? update_slots = null, string name = "ResourceApplyAdagrad") + public static Operation resource_apply_adagrad(Tensor var, Tensor accum, Tensor lr, Tensor grad, bool? use_locking = null, bool? update_slots = null, string name = "ResourceApplyAdagrad") { var dict = new Dictionary(); dict["var"] = var; @@ -25099,7 +25099,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation resource_apply_adagrad_d_a (Tensor var, Tensor gradient_accumulator, Tensor gradient_squared_accumulator, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor global_step, bool? use_locking = null, string name = "ResourceApplyAdagradDA") + public static Operation resource_apply_adagrad_d_a(Tensor var, Tensor gradient_accumulator, Tensor gradient_squared_accumulator, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor global_step, bool? use_locking = null, string name = "ResourceApplyAdagradDA") { var dict = new Dictionary(); dict["var"] = var; @@ -25169,7 +25169,7 @@ namespace Tensorflow.Operations /// $$v_t := beta_2 * v_{t-1} + (1 - beta_2) * g * g$$ /// $$variable := variable - lr_t * m_t / (\sqrt{v_t} + \epsilon)$$ /// - public static Operation resource_apply_adam (Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor beta2_power, Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool? use_locking = null, bool? use_nesterov = null, string name = "ResourceApplyAdam") + public static Operation resource_apply_adam(Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor beta2_power, Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool? use_locking = null, bool? use_nesterov = null, string name = "ResourceApplyAdam") { var dict = new Dictionary(); dict["var"] = var; @@ -25230,7 +25230,7 @@ namespace Tensorflow.Operations /// update &lt;- (alpha + sign_decay * sign(g) *sign(m)) * g /// variable &lt;- variable - lr_t * update /// - public static Operation resource_apply_add_sign (Tensor var, Tensor m, Tensor lr, Tensor alpha, Tensor sign_decay, Tensor beta, Tensor grad, bool? use_locking = null, string name = "ResourceApplyAddSign") + public static Operation resource_apply_add_sign(Tensor var, Tensor m, Tensor lr, Tensor alpha, Tensor sign_decay, Tensor beta, Tensor grad, bool? use_locking = null, string name = "ResourceApplyAddSign") { var dict = new Dictionary(); dict["var"] = var; @@ -25306,7 +25306,7 @@ namespace Tensorflow.Operations /// mom &lt;- momentum * mom_{t-1} + lr * grad / sqrt(ms - mg * mg + epsilon) /// var &lt;- var - mom /// - public static Operation resource_apply_centered_r_m_s_prop (Tensor var, Tensor mg, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ResourceApplyCenteredRMSProp") + public static Operation resource_apply_centered_r_m_s_prop(Tensor var, Tensor mg, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ResourceApplyCenteredRMSProp") { var dict = new Dictionary(); dict["var"] = var; @@ -25369,7 +25369,7 @@ namespace Tensorflow.Operations /// var = (sign(linear) * l1 - linear) / quadratic if |linear| &gt; l1 else 0.0 /// accum = accum_new /// - public static Operation resource_apply_ftrl (Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor lr_power, bool? use_locking = null, string name = "ResourceApplyFtrl") + public static Operation resource_apply_ftrl(Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor lr_power, bool? use_locking = null, string name = "ResourceApplyFtrl") { var dict = new Dictionary(); dict["var"] = var; @@ -25435,7 +25435,7 @@ namespace Tensorflow.Operations /// var = (sign(linear) * l1 - linear) / quadratic if |linear| &gt; l1 else 0.0 /// accum = accum_new /// - public static Operation resource_apply_ftrl_v2 (Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor l2_shrinkage, Tensor lr_power, bool? use_locking = null, string name = "ResourceApplyFtrlV2") + public static Operation resource_apply_ftrl_v2(Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor lr, Tensor l1, Tensor l2, Tensor l2_shrinkage, Tensor lr_power, bool? use_locking = null, string name = "ResourceApplyFtrlV2") { var dict = new Dictionary(); dict["var"] = var; @@ -25475,7 +25475,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation resource_apply_gradient_descent (Tensor var, Tensor alpha, Tensor delta, bool? use_locking = null, string name = "ResourceApplyGradientDescent") + public static Operation resource_apply_gradient_descent(Tensor var, Tensor alpha, Tensor delta, bool? use_locking = null, string name = "ResourceApplyGradientDescent") { var dict = new Dictionary(); dict["var"] = var; @@ -25527,7 +25527,7 @@ namespace Tensorflow.Operations /// accum = accum * momentum + grad /// var -= lr * accum /// - public static Operation resource_apply_momentum (Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor momentum, bool? use_locking = null, bool? use_nesterov = null, string name = "ResourceApplyMomentum") + public static Operation resource_apply_momentum(Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor momentum, bool? use_locking = null, bool? use_nesterov = null, string name = "ResourceApplyMomentum") { var dict = new Dictionary(); dict["var"] = var; @@ -25583,7 +25583,7 @@ namespace Tensorflow.Operations /// update &lt;- exp(logbase * sign_decay * sign(g) * sign(m_t)) * g /// variable &lt;- variable - lr_t * update /// - public static Operation resource_apply_power_sign (Tensor var, Tensor m, Tensor lr, Tensor logbase, Tensor sign_decay, Tensor beta, Tensor grad, bool? use_locking = null, string name = "ResourceApplyPowerSign") + public static Operation resource_apply_power_sign(Tensor var, Tensor m, Tensor lr, Tensor logbase, Tensor sign_decay, Tensor beta, Tensor grad, bool? use_locking = null, string name = "ResourceApplyPowerSign") { var dict = new Dictionary(); dict["var"] = var; @@ -25635,7 +25635,7 @@ namespace Tensorflow.Operations /// prox_v = var - lr * grad * (1 / sqrt(accum)) /// var = sign(prox_v)/(1+lr*l2) * max{|prox_v|-lr*l1,0} /// - public static Operation resource_apply_proximal_adagrad (Tensor var, Tensor accum, Tensor lr, Tensor l1, Tensor l2, Tensor grad, bool? use_locking = null, string name = "ResourceApplyProximalAdagrad") + public static Operation resource_apply_proximal_adagrad(Tensor var, Tensor accum, Tensor lr, Tensor l1, Tensor l2, Tensor grad, bool? use_locking = null, string name = "ResourceApplyProximalAdagrad") { var dict = new Dictionary(); dict["var"] = var; @@ -25682,7 +25682,7 @@ namespace Tensorflow.Operations /// prox_v = var - alpha * delta /// var = sign(prox_v)/(1+alpha*l2) * max{|prox_v|-alpha*l1,0} /// - public static Operation resource_apply_proximal_gradient_descent (Tensor var, Tensor alpha, Tensor l1, Tensor l2, Tensor delta, bool? use_locking = null, string name = "ResourceApplyProximalGradientDescent") + public static Operation resource_apply_proximal_gradient_descent(Tensor var, Tensor alpha, Tensor l1, Tensor l2, Tensor delta, bool? use_locking = null, string name = "ResourceApplyProximalGradientDescent") { var dict = new Dictionary(); dict["var"] = var; @@ -25745,7 +25745,7 @@ namespace Tensorflow.Operations /// mom &lt;- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon) /// var &lt;- var - mom /// - public static Operation resource_apply_r_m_s_prop (Tensor var, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ResourceApplyRMSProp") + public static Operation resource_apply_r_m_s_prop(Tensor var, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, bool? use_locking = null, string name = "ResourceApplyRMSProp") { var dict = new Dictionary(); dict["var"] = var; @@ -25784,7 +25784,7 @@ namespace Tensorflow.Operations /// input, the values produced will all be distinct. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor resource_count_up_to (Tensor resource, int limit, TF_DataType T, string name = "ResourceCountUpTo") + public static Tensor resource_count_up_to(Tensor resource, int limit, TF_DataType T, string name = "ResourceCountUpTo") { var dict = new Dictionary(); dict["resource"] = resource; @@ -25827,7 +25827,7 @@ namespace Tensorflow.Operations /// output[i, ..., j, :, ... :] = params[indices[i, ..., j], :, ..., :] /// /// - public static Tensor resource_gather (Tensor resource, Tensor indices, TF_DataType dtype, bool? validate_indices = null, string name = "ResourceGather") + public static Tensor resource_gather(Tensor resource, Tensor indices, TF_DataType dtype, bool? validate_indices = null, string name = "ResourceGather") { var dict = new Dictionary(); dict["resource"] = resource; @@ -25878,7 +25878,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src='https://www.tensorflow.org/images/ScatterAdd.png' alt&gt; /// &lt;/div&gt; /// - public static Operation resource_scatter_add (Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterAdd") + public static Operation resource_scatter_add(Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterAdd") { var dict = new Dictionary(); dict["resource"] = resource; @@ -25927,7 +25927,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src='https://www.tensorflow.org/images/ScatterAdd.png' alt&gt; /// &lt;/div&gt; /// - public static Operation resource_scatter_div (Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterDiv") + public static Operation resource_scatter_div(Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterDiv") { var dict = new Dictionary(); dict["resource"] = resource; @@ -25976,7 +25976,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src='https://www.tensorflow.org/images/ScatterAdd.png' alt&gt; /// &lt;/div&gt; /// - public static Operation resource_scatter_max (Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterMax") + public static Operation resource_scatter_max(Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterMax") { var dict = new Dictionary(); dict["resource"] = resource; @@ -26025,7 +26025,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src='https://www.tensorflow.org/images/ScatterAdd.png' alt&gt; /// &lt;/div&gt; /// - public static Operation resource_scatter_min (Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterMin") + public static Operation resource_scatter_min(Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterMin") { var dict = new Dictionary(); dict["resource"] = resource; @@ -26074,7 +26074,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src='https://www.tensorflow.org/images/ScatterAdd.png' alt&gt; /// &lt;/div&gt; /// - public static Operation resource_scatter_mul (Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterMul") + public static Operation resource_scatter_mul(Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterMul") { var dict = new Dictionary(); dict["resource"] = resource; @@ -26146,7 +26146,7 @@ namespace Tensorflow.Operations /// See tf.scatter_nd for more details about how to make updates to /// slices. /// - public static Operation resource_scatter_nd_add (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ResourceScatterNdAdd") + public static Operation resource_scatter_nd_add(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ResourceScatterNdAdd") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -26220,7 +26220,7 @@ namespace Tensorflow.Operations /// See tf.scatter_nd for more details about how to make updates to /// slices. /// - public static Operation resource_scatter_nd_update (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ResourceScatterNdUpdate") + public static Operation resource_scatter_nd_update(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ResourceScatterNdUpdate") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -26271,7 +26271,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src='https://www.tensorflow.org/images/ScatterAdd.png' alt&gt; /// &lt;/div&gt; /// - public static Operation resource_scatter_sub (Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterSub") + public static Operation resource_scatter_sub(Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterSub") { var dict = new Dictionary(); dict["resource"] = resource; @@ -26311,7 +26311,7 @@ namespace Tensorflow.Operations /// # High rank indices (for each i, ..., j) /// ref[indices[i, ..., j], ...] = updates[i, ..., j, ...] /// - public static Operation resource_scatter_update (Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterUpdate") + public static Operation resource_scatter_update(Tensor resource, Tensor indices, Tensor updates, string name = "ResourceScatterUpdate") { var dict = new Dictionary(); dict["resource"] = resource; @@ -26357,7 +26357,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation resource_sparse_apply_adadelta (Tensor var, Tensor accum, Tensor accum_update, Tensor lr, Tensor rho, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyAdadelta") + public static Operation resource_sparse_apply_adadelta(Tensor var, Tensor accum, Tensor accum_update, Tensor lr, Tensor rho, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyAdadelta") { var dict = new Dictionary(); dict["var"] = var; @@ -26410,7 +26410,7 @@ namespace Tensorflow.Operations /// accum += grad * grad /// var -= lr * grad * (1 / sqrt(accum)) /// - public static Operation resource_sparse_apply_adagrad (Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor indices, bool? use_locking = null, bool? update_slots = null, string name = "ResourceSparseApplyAdagrad") + public static Operation resource_sparse_apply_adagrad(Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor indices, bool? use_locking = null, bool? update_slots = null, string name = "ResourceSparseApplyAdagrad") { var dict = new Dictionary(); dict["var"] = var; @@ -26466,7 +26466,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation resource_sparse_apply_adagrad_d_a (Tensor var, Tensor gradient_accumulator, Tensor gradient_squared_accumulator, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor global_step, bool? use_locking = null, string name = "ResourceSparseApplyAdagradDA") + public static Operation resource_sparse_apply_adagrad_d_a(Tensor var, Tensor gradient_accumulator, Tensor gradient_squared_accumulator, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor global_step, bool? use_locking = null, string name = "ResourceSparseApplyAdagradDA") { var dict = new Dictionary(); dict["var"] = var; @@ -26545,7 +26545,7 @@ namespace Tensorflow.Operations /// mom &lt;- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon) /// var &lt;- var - mom /// - public static Operation resource_sparse_apply_centered_r_m_s_prop (Tensor var, Tensor mg, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyCenteredRMSProp") + public static Operation resource_sparse_apply_centered_r_m_s_prop(Tensor var, Tensor mg, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyCenteredRMSProp") { var dict = new Dictionary(); dict["var"] = var; @@ -26613,7 +26613,7 @@ namespace Tensorflow.Operations /// var = (sign(linear) * l1 - linear) / quadratic if |linear| &gt; l1 else 0.0 /// accum = accum_new /// - public static Operation resource_sparse_apply_ftrl (Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor lr_power, bool? use_locking = null, string name = "ResourceSparseApplyFtrl") + public static Operation resource_sparse_apply_ftrl(Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor lr_power, bool? use_locking = null, string name = "ResourceSparseApplyFtrl") { var dict = new Dictionary(); dict["var"] = var; @@ -26684,7 +26684,7 @@ namespace Tensorflow.Operations /// var = (sign(linear) * l1 - linear) / quadratic if |linear| &gt; l1 else 0.0 /// accum = accum_new /// - public static Operation resource_sparse_apply_ftrl_v2 (Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor l2_shrinkage, Tensor lr_power, bool? use_locking = null, string name = "ResourceSparseApplyFtrlV2") + public static Operation resource_sparse_apply_ftrl_v2(Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor l2_shrinkage, Tensor lr_power, bool? use_locking = null, string name = "ResourceSparseApplyFtrlV2") { var dict = new Dictionary(); dict["var"] = var; @@ -26748,7 +26748,7 @@ namespace Tensorflow.Operations /// accum = accum * momentum + grad /// var -= lr * accum /// - public static Operation resource_sparse_apply_momentum (Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor indices, Tensor momentum, bool? use_locking = null, bool? use_nesterov = null, string name = "ResourceSparseApplyMomentum") + public static Operation resource_sparse_apply_momentum(Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor indices, Tensor momentum, bool? use_locking = null, bool? use_nesterov = null, string name = "ResourceSparseApplyMomentum") { var dict = new Dictionary(); dict["var"] = var; @@ -26806,7 +26806,7 @@ namespace Tensorflow.Operations /// prox_v -= lr * grad * (1 / sqrt(accum)) /// var = sign(prox_v)/(1+lr*l2) * max{|prox_v|-lr*l1,0} /// - public static Operation resource_sparse_apply_proximal_adagrad (Tensor var, Tensor accum, Tensor lr, Tensor l1, Tensor l2, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyProximalAdagrad") + public static Operation resource_sparse_apply_proximal_adagrad(Tensor var, Tensor accum, Tensor lr, Tensor l1, Tensor l2, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyProximalAdagrad") { var dict = new Dictionary(); dict["var"] = var; @@ -26858,7 +26858,7 @@ namespace Tensorflow.Operations /// prox_v = var - alpha * grad /// var = sign(prox_v)/(1+alpha*l2) * max{|prox_v|-alpha*l1,0} /// - public static Operation resource_sparse_apply_proximal_gradient_descent (Tensor var, Tensor alpha, Tensor l1, Tensor l2, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyProximalGradientDescent") + public static Operation resource_sparse_apply_proximal_gradient_descent(Tensor var, Tensor alpha, Tensor l1, Tensor l2, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyProximalGradientDescent") { var dict = new Dictionary(); dict["var"] = var; @@ -26925,7 +26925,7 @@ namespace Tensorflow.Operations /// mom &lt;- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon) /// var &lt;- var - mom /// - public static Operation resource_sparse_apply_r_m_s_prop (Tensor var, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyRMSProp") + public static Operation resource_sparse_apply_r_m_s_prop(Tensor var, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "ResourceSparseApplyRMSProp") { var dict = new Dictionary(); dict["var"] = var; @@ -26980,7 +26980,7 @@ namespace Tensorflow.Operations /// NOTE this op currently does not support broadcasting and so value's /// shape must be exactly the shape produced by the slice of ref. /// - public static Operation resource_strided_slice_assign (Tensor referecne, Tensor begin, Tensor end, Tensor strides, Tensor value, int? begin_mask = null, int? end_mask = null, int? ellipsis_mask = null, int? new_axis_mask = null, int? shrink_axis_mask = null, string name = "ResourceStridedSliceAssign") + public static Operation resource_strided_slice_assign(Tensor referecne, Tensor begin, Tensor end, Tensor strides, Tensor value, int? begin_mask = null, int? end_mask = null, int? ellipsis_mask = null, int? new_axis_mask = null, int? shrink_axis_mask = null, string name = "ResourceStridedSliceAssign") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -27046,7 +27046,7 @@ namespace Tensorflow.Operations /// /// See also RestoreSlice. /// - public static Tensor restore (Tensor file_pattern, Tensor tensor_name, TF_DataType dt, int? preferred_shard = null, string name = "Restore") + public static Tensor restore(Tensor file_pattern, Tensor tensor_name, TF_DataType dt, int? preferred_shard = null, string name = "Restore") { var dict = new Dictionary(); dict["file_pattern"] = file_pattern; @@ -27096,7 +27096,7 @@ namespace Tensorflow.Operations /// The shape_and_slice input has the same format as the /// elements of the shapes_and_slices input of the SaveSlices op. /// - public static Tensor restore_slice (Tensor file_pattern, Tensor tensor_name, Tensor shape_and_slice, TF_DataType dt, int? preferred_shard = null, string name = "RestoreSlice") + public static Tensor restore_slice(Tensor file_pattern, Tensor tensor_name, Tensor shape_and_slice, TF_DataType dt, int? preferred_shard = null, string name = "RestoreSlice") { var dict = new Dictionary(); dict["file_pattern"] = file_pattern; @@ -27150,7 +27150,7 @@ namespace Tensorflow.Operations /// /// Callers must ensure all the named tensors are indeed stored in the checkpoint. /// - public static Tensor[] restore_v2 (Tensor prefix, Tensor tensor_names, Tensor shape_and_slices, TF_DataType[] dtypes, string name = "RestoreV2") + public static Tensor[] restore_v2(Tensor prefix, Tensor tensor_names, Tensor shape_and_slices, TF_DataType[] dtypes, string name = "RestoreV2") { var dict = new Dictionary(); dict["prefix"] = prefix; @@ -27225,7 +27225,7 @@ namespace Tensorflow.Operations /// [12, 13, 14, 15]]]] /// /// - public static Tensor reverse (Tensor tensor, Tensor dims, string name = "Reverse") + public static Tensor reverse(Tensor tensor, Tensor dims, string name = "Reverse") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -27314,7 +27314,7 @@ namespace Tensorflow.Operations /// output[2:, :, 3, :, ...] = input[2:, :, 3, :, ...] /// /// - public static Tensor reverse_sequence (Tensor input, Tensor seq_lengths, int seq_dim, int? batch_dim = null, string name = "ReverseSequence") + public static Tensor reverse_sequence(Tensor input, Tensor seq_lengths, int seq_dim, int? batch_dim = null, string name = "ReverseSequence") { var dict = new Dictionary(); dict["input"] = input; @@ -27391,7 +27391,7 @@ namespace Tensorflow.Operations /// [12, 13, 14, 15]]]] /// /// - public static Tensor reverse_v2 (Tensor tensor, Tensor axis, string name = "ReverseV2") + public static Tensor reverse_v2(Tensor tensor, Tensor axis, string name = "ReverseV2") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -27420,7 +27420,7 @@ namespace Tensorflow.Operations /// If y is negative, or greater than or equal to than the width of x in bits /// the result is implementation defined. /// - public static Tensor right_shift (Tensor x, Tensor y, string name = "RightShift") + public static Tensor right_shift(Tensor x, Tensor y, string name = "RightShift") { var dict = new Dictionary(); dict["x"] = x; @@ -27451,7 +27451,7 @@ namespace Tensorflow.Operations /// rint([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]) ==&gt; [-2., -2., -0., 0., 2., 2., 2.] /// /// - public static Tensor rint (Tensor x, string name = "Rint") + public static Tensor rint(Tensor x, string name = "Rint") { var dict = new Dictionary(); dict["x"] = x; @@ -27507,7 +27507,7 @@ namespace Tensorflow.Operations /// roll(t, shift=[2, -3], axis=[1, 1]) ==&gt; [[1, 2, 3, 4, 0], [6, 7, 8, 9, 5]] /// /// - public static Tensor roll (Tensor input, Tensor shift, Tensor axis, string name = "Roll") + public static Tensor roll(Tensor input, Tensor shift, Tensor axis, string name = "Roll") { var dict = new Dictionary(); dict["input"] = input; @@ -27532,7 +27532,7 @@ namespace Tensorflow.Operations /// Rounds half to even. Also known as bankers rounding. If you want to round /// according to the current system rounding mode use std::cint. /// - public static Tensor round (Tensor x, string name = "Round") + public static Tensor round(Tensor x, string name = "Round") { var dict = new Dictionary(); dict["x"] = x; @@ -27628,7 +27628,7 @@ namespace Tensorflow.Operations /// /// See the TryRpc op if you prefer to handle RPC failures manually in the graph. /// - public static Tensor rpc (Tensor address, Tensor method, Tensor request, string protocol = null, bool? fail_fast = null, int? timeout_in_ms = null, string name = "Rpc") + public static Tensor rpc(Tensor address, Tensor method, Tensor request, string protocol = null, bool? fail_fast = null, int? timeout_in_ms = null, string name = "Rpc") { var dict = new Dictionary(); dict["address"] = address; @@ -27658,7 +27658,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = 1 / \sqrt{x}\\). /// - public static Tensor rsqrt (Tensor x, string name = "Rsqrt") + public static Tensor rsqrt(Tensor x, string name = "Rsqrt") { var dict = new Dictionary(); dict["x"] = x; @@ -27683,7 +27683,7 @@ namespace Tensorflow.Operations /// Specifically, grad = dy * -0.5 * y^3, where y = rsqrt(x), and dy /// is the corresponding input gradient. /// - public static Tensor rsqrt_grad (Tensor y, Tensor dy, string name = "RsqrtGrad") + public static Tensor rsqrt_grad(Tensor y, Tensor dy, string name = "RsqrtGrad") { var dict = new Dictionary(); dict["y"] = y; @@ -27787,7 +27787,7 @@ namespace Tensorflow.Operations /// bounding box covering the whole image. If use_image_if_no_bounding_boxes is /// false and no bounding boxes are supplied, an error is raised. /// - public static (Tensor begin, Tensor size, Tensor bboxes) sample_distorted_bounding_box (Tensor image_size, Tensor bounding_boxes, int? seed = null, int? seed2 = null, float? min_object_covered = null, float[] aspect_ratio_range = null, float[] area_range = null, int? max_attempts = null, bool? use_image_if_no_bounding_boxes = null, string name = "SampleDistortedBoundingBox") + public static (Tensor begin, Tensor size, Tensor bboxes) sample_distorted_bounding_box(Tensor image_size, Tensor bounding_boxes, int? seed = null, int? seed2 = null, float? min_object_covered = null, float[] aspect_ratio_range = null, float[] area_range = null, int? max_attempts = null, bool? use_image_if_no_bounding_boxes = null, string name = "SampleDistortedBoundingBox") { var dict = new Dictionary(); dict["image_size"] = image_size; @@ -27909,7 +27909,7 @@ namespace Tensorflow.Operations /// bounding box covering the whole image. If use_image_if_no_bounding_boxes is /// false and no bounding boxes are supplied, an error is raised. /// - public static (Tensor begin, Tensor size, Tensor bboxes) sample_distorted_bounding_box_v2 (Tensor image_size, Tensor bounding_boxes, Tensor min_object_covered, int? seed = null, int? seed2 = null, float[] aspect_ratio_range = null, float[] area_range = null, int? max_attempts = null, bool? use_image_if_no_bounding_boxes = null, string name = "SampleDistortedBoundingBoxV2") + public static (Tensor begin, Tensor size, Tensor bboxes) sample_distorted_bounding_box_v2(Tensor image_size, Tensor bounding_boxes, Tensor min_object_covered, int? seed = null, int? seed2 = null, float[] aspect_ratio_range = null, float[] area_range = null, int? max_attempts = null, bool? use_image_if_no_bounding_boxes = null, string name = "SampleDistortedBoundingBoxV2") { var dict = new Dictionary(); dict["image_size"] = image_size; @@ -27960,7 +27960,7 @@ namespace Tensorflow.Operations /// /// See also SaveSlices. /// - public static Operation save (Tensor filename, Tensor tensor_names, Tensor[] data, string name = "Save") + public static Operation save(Tensor filename, Tensor tensor_names, Tensor[] data, string name = "Save") { var dict = new Dictionary(); dict["filename"] = filename; @@ -28016,7 +28016,7 @@ namespace Tensorflow.Operations /// /// See also Save. /// - public static Operation save_slices (Tensor filename, Tensor tensor_names, Tensor shapes_and_slices, Tensor[] data, string name = "SaveSlices") + public static Operation save_slices(Tensor filename, Tensor tensor_names, Tensor shapes_and_slices, Tensor[] data, string name = "SaveSlices") { var dict = new Dictionary(); dict["filename"] = filename; @@ -28055,7 +28055,7 @@ namespace Tensorflow.Operations /// specific slices of full tensors, "shape_and_slices" should be non-empty strings /// and correspondingly well-formed. /// - public static Operation save_v2 (Tensor prefix, Tensor tensor_names, Tensor shape_and_slices, Tensor[] tensors, string name = "SaveV2") + public static Operation save_v2(Tensor prefix, Tensor tensor_names, Tensor shape_and_slices, Tensor[] tensors, string name = "SaveV2") { var dict = new Dictionary(); dict["prefix"] = prefix; @@ -28066,7 +28066,7 @@ namespace Tensorflow.Operations return op; } - public static Tensor scale_and_translate (Tensor images_t, Tensor new_size, Tensor[] scale, Tensor zeroes, string kernel_type, bool antialias) + public static Tensor scale_and_translate(Tensor images_t, Tensor new_size, Tensor[] scale, Tensor zeroes, string kernel_type, bool antialias) { throw new NotImplementedException("scale_and_translate"); } @@ -28091,7 +28091,7 @@ namespace Tensorflow.Operations /// The input tags and values must have the same shape. The generated summary /// has a summary value for each tag-value pair in tags and values. /// - public static Tensor scalar_summary (Tensor tags, Tensor values, string name = "ScalarSummary") + public static Tensor scalar_summary(Tensor tags, Tensor values, string name = "ScalarSummary") { var dict = new Dictionary(); dict["tags"] = tags; @@ -28148,7 +28148,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/ScatterAdd.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor scatter_add (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterAdd") + public static Tensor scatter_add(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterAdd") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28206,7 +28206,7 @@ namespace Tensorflow.Operations /// /// Requires updates.shape = indices.shape + ref.shape[1:] or updates.shape = []. /// - public static Tensor scatter_div (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterDiv") + public static Tensor scatter_div(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterDiv") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28266,7 +28266,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/ScatterAdd.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor scatter_max (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterMax") + public static Tensor scatter_max(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterMax") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28326,7 +28326,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/ScatterAdd.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor scatter_min (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterMin") + public static Tensor scatter_min(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterMin") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28384,7 +28384,7 @@ namespace Tensorflow.Operations /// /// Requires updates.shape = indices.shape + ref.shape[1:] or updates.shape = []. /// - public static Tensor scatter_mul (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterMul") + public static Tensor scatter_mul(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterMul") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28496,7 +28496,7 @@ namespace Tensorflow.Operations /// Note that on CPU, if an out of bound index is found, an error is returned. /// On GPU, if an out of bound index is found, the index is ignored. /// - public static Tensor scatter_nd (Tensor indices, Tensor updates, Tensor shape, string name = "ScatterNd") + public static Tensor scatter_nd(Tensor indices, Tensor updates, Tensor shape, string name = "ScatterNd") { var dict = new Dictionary(); dict["indices"] = indices; @@ -28566,7 +28566,7 @@ namespace Tensorflow.Operations /// See tf.scatter_nd for more details about how to make updates to /// slices. /// - public static Tensor scatter_nd_add (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterNdAdd") + public static Tensor scatter_nd_add(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterNdAdd") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28635,7 +28635,7 @@ namespace Tensorflow.Operations /// /// See tf.scatter_nd for more details about how to make updates to slices. /// - public static Tensor scatter_nd_non_aliasing_add (Tensor input, Tensor indices, Tensor updates, string name = "ScatterNdNonAliasingAdd") + public static Tensor scatter_nd_non_aliasing_add(Tensor input, Tensor indices, Tensor updates, string name = "ScatterNdNonAliasingAdd") { var dict = new Dictionary(); dict["input"] = input; @@ -28705,7 +28705,7 @@ namespace Tensorflow.Operations /// See tf.scatter_nd for more details about how to make updates to /// slices. /// - public static Tensor scatter_nd_sub (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterNdSub") + public static Tensor scatter_nd_sub(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterNdSub") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28781,7 +28781,7 @@ namespace Tensorflow.Operations /// /// See also tf.scatter_update and tf.batch_scatter_update. /// - public static Tensor scatter_nd_update (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterNdUpdate") + public static Tensor scatter_nd_update(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterNdUpdate") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28841,7 +28841,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/ScatterSub.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor scatter_sub (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterSub") + public static Tensor scatter_sub(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterSub") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28906,7 +28906,7 @@ namespace Tensorflow.Operations /// /// See also tf.batch_scatter_update and tf.scatter_nd_update. /// - public static Tensor scatter_update (Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterUpdate") + public static Tensor scatter_update(Tensor referecne, Tensor indices, Tensor updates, bool? use_locking = null, string name = "ScatterUpdate") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -28932,7 +28932,7 @@ namespace Tensorflow.Operations /// vector. Each row contains the low and high parts of the fingerprint. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor sdca_fprint (Tensor input, string name = "SdcaFprint") + public static Tensor sdca_fprint(Tensor input, string name = "SdcaFprint") { var dict = new Dictionary(); dict["input"] = input; @@ -29036,7 +29036,7 @@ namespace Tensorflow.Operations /// [Stochastic Dual Coordinate Ascent with Adaptive Probabilities](https://arxiv.org/abs/1502.08053).&lt;br&gt; /// Dominik Csiba, Zheng Qu, Peter Richtarik. 2015 /// - public static (Tensor out_example_state_data, Tensor[] out_delta_sparse_weights, Tensor[] out_delta_dense_weights) sdca_optimizer (Tensor[] sparse_example_indices, Tensor[] sparse_feature_indices, Tensor[] sparse_feature_values, Tensor[] dense_features, Tensor example_weights, Tensor example_labels, Tensor[] sparse_indices, Tensor[] sparse_weights, Tensor[] dense_weights, Tensor example_state_data, string loss_type, float l1, float l2, int num_loss_partitions, int num_inner_iterations, bool? adaptative = null, string name = "SdcaOptimizer") + public static (Tensor out_example_state_data, Tensor[] out_delta_sparse_weights, Tensor[] out_delta_dense_weights) sdca_optimizer(Tensor[] sparse_example_indices, Tensor[] sparse_feature_indices, Tensor[] sparse_feature_values, Tensor[] dense_features, Tensor example_weights, Tensor example_labels, Tensor[] sparse_indices, Tensor[] sparse_weights, Tensor[] dense_weights, Tensor example_state_data, string loss_type, float l1, float l2, int num_loss_partitions, int num_inner_iterations, bool? adaptative = null, string name = "SdcaOptimizer") { var dict = new Dictionary(); dict["sparse_example_indices"] = sparse_example_indices; @@ -29085,7 +29085,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation sdca_shrink_l1 (Tensor[] weights, float l1, float l2, string name = "SdcaShrinkL1") + public static Operation sdca_shrink_l1(Tensor[] weights, float l1, float l2, string name = "SdcaShrinkL1") { var dict = new Dictionary(); dict["weights"] = weights; @@ -29127,7 +29127,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/SegmentMax.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor segment_max (Tensor data, Tensor segment_ids, string name = "SegmentMax") + public static Tensor segment_max(Tensor data, Tensor segment_ids, string name = "SegmentMax") { var dict = new Dictionary(); dict["data"] = data; @@ -29169,7 +29169,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/SegmentMean.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor segment_mean (Tensor data, Tensor segment_ids, string name = "SegmentMean") + public static Tensor segment_mean(Tensor data, Tensor segment_ids, string name = "SegmentMean") { var dict = new Dictionary(); dict["data"] = data; @@ -29210,7 +29210,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/SegmentMin.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor segment_min (Tensor data, Tensor segment_ids, string name = "SegmentMin") + public static Tensor segment_min(Tensor data, Tensor segment_ids, string name = "SegmentMin") { var dict = new Dictionary(); dict["data"] = data; @@ -29251,7 +29251,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/SegmentProd.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor segment_prod (Tensor data, Tensor segment_ids, string name = "SegmentProd") + public static Tensor segment_prod(Tensor data, Tensor segment_ids, string name = "SegmentProd") { var dict = new Dictionary(); dict["data"] = data; @@ -29292,7 +29292,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/SegmentSum.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor segment_sum (Tensor data, Tensor segment_ids, string name = "SegmentSum") + public static Tensor segment_sum(Tensor data, Tensor segment_ids, string name = "SegmentSum") { var dict = new Dictionary(); dict["data"] = data; @@ -29361,7 +29361,7 @@ namespace Tensorflow.Operations /// /// /// - public static Tensor select (Tensor condition, Tensor t, Tensor e, string name = "Select") + public static Tensor select(Tensor condition, Tensor t, Tensor e, string name = "Select") { var dict = new Dictionary(); dict["condition"] = condition; @@ -29393,7 +29393,7 @@ namespace Tensorflow.Operations /// eigenvalues, and subsequent [...,1:, :] containing the eigenvectors. The eigenvalues /// are sorted in non-decreasing order. /// - public static Tensor self_adjoint_eig (Tensor input, string name = "SelfAdjointEig") + public static Tensor self_adjoint_eig(Tensor input, string name = "SelfAdjointEig") { var dict = new Dictionary(); dict["input"] = input; @@ -29433,7 +29433,7 @@ namespace Tensorflow.Operations /// e = self_adjoint_eig(a, compute_v=False) /// /// - public static (Tensor e, Tensor v) self_adjoint_eig_v2 (Tensor input, bool? compute_v = null, string name = "SelfAdjointEigV2") + public static (Tensor e, Tensor v) self_adjoint_eig_v2(Tensor input, bool? compute_v = null, string name = "SelfAdjointEigV2") { var dict = new Dictionary(); dict["input"] = input; @@ -29466,7 +29466,7 @@ namespace Tensorflow.Operations /// /// See [Self-Normalizing Neural Networks](https://arxiv.org/abs/1706.02515) /// - public static Tensor selu (Tensor features, string name = "Selu") + public static Tensor selu(Tensor features, string name = "Selu") { var dict = new Dictionary(); dict["features"] = features; @@ -29491,7 +29491,7 @@ namespace Tensorflow.Operations /// if outputs &lt; 0, scale * gradients otherwise. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor selu_grad (Tensor gradients, Tensor outputs, string name = "SeluGrad") + public static Tensor selu_grad(Tensor gradients, Tensor outputs, string name = "SeluGrad") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -29514,7 +29514,7 @@ namespace Tensorflow.Operations /// resource. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor serialize_iterator (Tensor resource_handle, string name = "SerializeIterator") + public static Tensor serialize_iterator(Tensor resource_handle, string name = "SerializeIterator") { var dict = new Dictionary(); dict["resource_handle"] = resource_handle; @@ -29553,7 +29553,7 @@ namespace Tensorflow.Operations /// /// The minibatch size N is extracted from sparse_shape[0]. /// - public static Tensor serialize_many_sparse (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape, TF_DataType? out_type = null, string name = "SerializeManySparse") + public static Tensor serialize_many_sparse(Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape, TF_DataType? out_type = null, string name = "SerializeManySparse") { var dict = new Dictionary(); dict["sparse_indices"] = sparse_indices; @@ -29587,7 +29587,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor serialize_sparse (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape, TF_DataType? out_type = null, string name = "SerializeSparse") + public static Tensor serialize_sparse(Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape, TF_DataType? out_type = null, string name = "SerializeSparse") { var dict = new Dictionary(); dict["sparse_indices"] = sparse_indices; @@ -29612,7 +29612,7 @@ namespace Tensorflow.Operations /// A serialized TensorProto proto of the input tensor. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor serialize_tensor (Tensor tensor, string name = "SerializeTensor") + public static Tensor serialize_tensor(Tensor tensor, string name = "SerializeTensor") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -29651,7 +29651,7 @@ namespace Tensorflow.Operations /// If validate_indices is True, this op validates the order and range of set /// indices. /// - public static Tensor set_size (Tensor set_indices, Tensor set_values, Tensor set_shape, bool? validate_indices = null, string name = "SetSize") + public static Tensor set_size(Tensor set_indices, Tensor set_values, Tensor set_shape, bool? validate_indices = null, string name = "SetSize") { var dict = new Dictionary(); dict["set_indices"] = set_indices; @@ -29686,7 +29686,7 @@ namespace Tensorflow.Operations /// shape(t) ==&gt; [2, 2, 3] /// /// - public static Tensor shape (Tensor input, TF_DataType? out_type = null, string name = "Shape") + public static Tensor shape(Tensor input, TF_DataType? out_type = null, string name = "Shape") { var dict = new Dictionary(); dict["input"] = input; @@ -29712,7 +29712,7 @@ namespace Tensorflow.Operations /// /// This operation returns N 1-D integer tensors representing shape of input[i]s. /// - public static Tensor[] shape_n (Tensor[] input, TF_DataType? out_type = null, string name = "ShapeN") + public static Tensor[] shape_n(Tensor[] input, TF_DataType? out_type = null, string name = "ShapeN") { var dict = new Dictionary(); dict["input"] = input; @@ -29742,7 +29742,7 @@ namespace Tensorflow.Operations /// /// %s-%05d-of-%05d, basename, shard, num_shards. /// - public static Tensor sharded_filename (Tensor basename, Tensor shard, Tensor num_shards, string name = "ShardedFilename") + public static Tensor sharded_filename(Tensor basename, Tensor shard, Tensor num_shards, string name = "ShardedFilename") { var dict = new Dictionary(); dict["basename"] = basename; @@ -29765,7 +29765,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor sharded_filespec (Tensor basename, Tensor num_shards, string name = "ShardedFilespec") + public static Tensor sharded_filespec(Tensor basename, Tensor num_shards, string name = "ShardedFilespec") { var dict = new Dictionary(); dict["basename"] = basename; @@ -29811,7 +29811,7 @@ namespace Tensorflow.Operations /// /// pseudorandomly. /// - public static Tensor shuffle_and_repeat_dataset (Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ShuffleAndRepeatDataset") + public static Tensor shuffle_and_repeat_dataset(Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ShuffleAndRepeatDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -29862,7 +29862,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor shuffle_dataset (Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, TF_DataType[] output_types, TensorShape[] output_shapes, bool? reshuffle_each_iteration = null, string name = "ShuffleDataset") + public static Tensor shuffle_dataset(Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, TF_DataType[] output_types, TensorShape[] output_shapes, bool? reshuffle_each_iteration = null, string name = "ShuffleDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -29889,7 +29889,7 @@ namespace Tensorflow.Operations /// /// an error if no system is running. /// - public static Operation shutdown_distributed_t_p_u (string name = "ShutdownDistributedTPU") + public static Operation shutdown_distributed_t_p_u(string name = "ShutdownDistributedTPU") { var dict = new Dictionary(); var op = tf.OpDefLib._apply_op_helper("ShutdownDistributedTPU", name: name, keywords: dict); @@ -29910,7 +29910,7 @@ namespace Tensorflow.Operations /// /// Specifically, y = 1 / (1 + exp(-x)). /// - public static Tensor sigmoid (Tensor x, string name = "Sigmoid") + public static Tensor sigmoid(Tensor x, string name = "Sigmoid") { var dict = new Dictionary(); dict["x"] = x; @@ -29935,7 +29935,7 @@ namespace Tensorflow.Operations /// Specifically, grad = dy * y * (1 - y), where y = sigmoid(x), and /// dy is the corresponding input gradient. /// - public static Tensor sigmoid_grad (Tensor y, Tensor dy, string name = "SigmoidGrad") + public static Tensor sigmoid_grad(Tensor y, Tensor dy, string name = "SigmoidGrad") { var dict = new Dictionary(); dict["y"] = y; @@ -29960,7 +29960,7 @@ namespace Tensorflow.Operations /// /// For complex numbers, y = sign(x) = x / |x| if x != 0, otherwise y = 0. /// - public static Tensor sign (Tensor x, string name = "Sign") + public static Tensor sign(Tensor x, string name = "Sign") { var dict = new Dictionary(); dict["x"] = x; @@ -29979,7 +29979,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor sin (Tensor x, string name = "Sin") + public static Tensor sin(Tensor x, string name = "Sin") { var dict = new Dictionary(); dict["x"] = x; @@ -29998,7 +29998,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor sinh (Tensor x, string name = "Sinh") + public static Tensor sinh(Tensor x, string name = "Sinh") { var dict = new Dictionary(); dict["x"] = x; @@ -30021,7 +30021,7 @@ namespace Tensorflow.Operations /// /// A placeholder for input pipeline graph optimizations. /// - public static Tensor sink_dataset (Tensor input_dataset, string name = "SinkDataset") + public static Tensor sink_dataset(Tensor input_dataset, string name = "SinkDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -30053,7 +30053,7 @@ namespace Tensorflow.Operations /// size(t) ==&gt; 12 /// /// - public static Tensor size (Tensor input, TF_DataType? out_type = null, string name = "Size") + public static Tensor size(Tensor input, TF_DataType? out_type = null, string name = "Size") { var dict = new Dictionary(); dict["input"] = input; @@ -30084,7 +30084,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor skip_dataset (Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SkipDataset") + public static Tensor skip_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SkipDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -30131,7 +30131,7 @@ namespace Tensorflow.Operations /// labels : A vector of word ids. /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor vocab_word, Tensor vocab_freq, Tensor words_per_epoch, Tensor current_epoch, Tensor total_words_processed, Tensor examples, Tensor labels) skipgram (string filename, int batch_size, int? window_size = null, int? min_count = null, float? subsample = null, string name = "Skipgram") + public static (Tensor vocab_word, Tensor vocab_freq, Tensor words_per_epoch, Tensor current_epoch, Tensor total_words_processed, Tensor examples, Tensor labels) skipgram(string filename, int batch_size, int? window_size = null, int? min_count = null, float? subsample = null, string name = "Skipgram") { var dict = new Dictionary(); dict["filename"] = filename; @@ -30183,7 +30183,7 @@ namespace Tensorflow.Operations /// *Requirements*: /// 0 &lt;= begin[i] &lt;= begin[i] + size[i] &lt;= Di for i in [0, n) /// - public static Tensor slice (Tensor input, Tensor begin, Tensor size, string name = "Slice") + public static Tensor slice(Tensor input, Tensor begin, Tensor size, string name = "Slice") { var dict = new Dictionary(); dict["input"] = input; @@ -30222,7 +30222,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor slide_dataset (Tensor input_dataset, Tensor window_size, Tensor window_shift, Tensor window_stride, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SlideDataset") + public static Tensor slide_dataset(Tensor input_dataset, Tensor window_size, Tensor window_shift, Tensor window_stride, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SlideDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -30246,7 +30246,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor snapshot (Tensor input, string name = "Snapshot") + public static Tensor snapshot(Tensor input, string name = "Snapshot") { var dict = new Dictionary(); dict["input"] = input; @@ -30272,7 +30272,7 @@ namespace Tensorflow.Operations /// /// $$softmax[i, j] = exp(logits[i, j]) / sum_j(exp(logits[i, j]))$$ /// - public static Tensor softmax (Tensor logits, string name = "Softmax") + public static Tensor softmax(Tensor logits, string name = "Softmax") { var dict = new Dictionary(); dict["logits"] = logits; @@ -30303,7 +30303,7 @@ namespace Tensorflow.Operations /// /// Inputs are the logits, not probabilities. /// - public static (Tensor loss, Tensor backprop) softmax_cross_entropy_with_logits (Tensor features, Tensor labels, string name = "SoftmaxCrossEntropyWithLogits") + public static (Tensor loss, Tensor backprop) softmax_cross_entropy_with_logits(Tensor features, Tensor labels, string name = "SoftmaxCrossEntropyWithLogits") { var dict = new Dictionary(); dict["features"] = features; @@ -30326,7 +30326,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor softplus (Tensor features, string name = "Softplus") + public static Tensor softplus(Tensor features, string name = "Softplus") { var dict = new Dictionary(); dict["features"] = features; @@ -30350,7 +30350,7 @@ namespace Tensorflow.Operations /// The gradients: gradients / (1 + exp(-features)). /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor softplus_grad (Tensor gradients, Tensor features, string name = "SoftplusGrad") + public static Tensor softplus_grad(Tensor gradients, Tensor features, string name = "SoftplusGrad") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -30370,7 +30370,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor softsign (Tensor features, string name = "Softsign") + public static Tensor softsign(Tensor features, string name = "Softsign") { var dict = new Dictionary(); dict["features"] = features; @@ -30394,7 +30394,7 @@ namespace Tensorflow.Operations /// The gradients: gradients / (1 + abs(features)) ** 2. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor softsign_grad (Tensor gradients, Tensor features, string name = "SoftsignGrad") + public static Tensor softsign_grad(Tensor gradients, Tensor features, string name = "SoftsignGrad") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -30514,7 +30514,7 @@ namespace Tensorflow.Operations /// the zero-padding, both height and width of the input must be divisible by the /// block size. /// - public static Tensor space_to_batch (Tensor input, Tensor paddings, int block_size, string name = "SpaceToBatch") + public static Tensor space_to_batch(Tensor input, Tensor paddings, int block_size, string name = "SpaceToBatch") { var dict = new Dictionary(); dict["input"] = input; @@ -30660,7 +30660,7 @@ namespace Tensorflow.Operations /// input are optionally zero padded according to paddings. See below for a /// precise description. /// - public static Tensor space_to_batch_n_d (Tensor input, Tensor block_shape, Tensor paddings, string name = "SpaceToBatchND") + public static Tensor space_to_batch_n_d(Tensor input, Tensor block_shape, Tensor paddings, string name = "SpaceToBatchND") { var dict = new Dictionary(); dict["input"] = input; @@ -30772,7 +30772,7 @@ namespace Tensorflow.Operations /// [13, 14, 15, 16]]]] /// /// - public static Tensor space_to_depth (Tensor input, int block_size, string data_format = null, string name = "SpaceToDepth") + public static Tensor space_to_depth(Tensor input, int block_size, string data_format = null, string name = "SpaceToDepth") { var dict = new Dictionary(); dict["input"] = input; @@ -30819,7 +30819,7 @@ namespace Tensorflow.Operations /// Does not add if local_step is smaller than the accumulator's /// global_step. /// - public static Operation sparse_accumulator_apply_gradient (Tensor handle, Tensor local_step, Tensor gradient_indices, Tensor gradient_values, Tensor gradient_shape, bool has_known_shape, string name = "SparseAccumulatorApplyGradient") + public static Operation sparse_accumulator_apply_gradient(Tensor handle, Tensor local_step, Tensor gradient_indices, Tensor gradient_values, Tensor gradient_shape, bool has_known_shape, string name = "SparseAccumulatorApplyGradient") { var dict = new Dictionary(); dict["handle"] = handle; @@ -30864,7 +30864,7 @@ namespace Tensorflow.Operations /// the recorded global_step in the accumulator by 1, and resets the /// aggregate to 0. /// - public static (Tensor indices, Tensor values, Tensor shape) sparse_accumulator_take_gradient (Tensor handle, Tensor num_required, TF_DataType dtype, string name = "SparseAccumulatorTakeGradient") + public static (Tensor indices, Tensor values, Tensor shape) sparse_accumulator_take_gradient(Tensor handle, Tensor num_required, TF_DataType dtype, string name = "SparseAccumulatorTakeGradient") { var dict = new Dictionary(); dict["handle"] = handle; @@ -30928,7 +30928,7 @@ namespace Tensorflow.Operations /// /// In the following shapes, nnz is the count after taking thresh into account. /// - public static (Tensor sum_indices, Tensor sum_values, Tensor sum_shape) sparse_add (Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b_indices, Tensor b_values, Tensor b_shape, Tensor thresh, string name = "SparseAdd") + public static (Tensor sum_indices, Tensor sum_values, Tensor sum_shape) sparse_add(Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b_indices, Tensor b_values, Tensor b_shape, Tensor thresh, string name = "SparseAdd") { var dict = new Dictionary(); dict["a_indices"] = a_indices; @@ -30980,7 +30980,7 @@ namespace Tensorflow.Operations /// non-empty values of the sum, and outputs the gradients w.r.t. the non-empty /// values of A and B. /// - public static (Tensor a_val_grad, Tensor b_val_grad) sparse_add_grad (Tensor backprop_val_grad, Tensor a_indices, Tensor b_indices, Tensor sum_indices, string name = "SparseAddGrad") + public static (Tensor a_val_grad, Tensor b_val_grad) sparse_add_grad(Tensor backprop_val_grad, Tensor a_indices, Tensor b_indices, Tensor sum_indices, string name = "SparseAddGrad") { var dict = new Dictionary(); dict["backprop_val_grad"] = backprop_val_grad; @@ -31031,7 +31031,7 @@ namespace Tensorflow.Operations /// Same as "var". /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor sparse_apply_adadelta (Tensor var, Tensor accum, Tensor accum_update, Tensor lr, Tensor rho, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyAdadelta") + public static Tensor sparse_apply_adadelta(Tensor var, Tensor accum, Tensor accum_update, Tensor lr, Tensor rho, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyAdadelta") { var dict = new Dictionary(); dict["var"] = var; @@ -31085,7 +31085,7 @@ namespace Tensorflow.Operations /// $$accum += grad * grad$$ /// $$var -= lr * grad * (1 / sqrt(accum))$$ /// - public static Tensor sparse_apply_adagrad (Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor indices, bool? use_locking = null, bool? update_slots = null, string name = "SparseApplyAdagrad") + public static Tensor sparse_apply_adagrad(Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor indices, bool? use_locking = null, bool? update_slots = null, string name = "SparseApplyAdagrad") { var dict = new Dictionary(); dict["var"] = var; @@ -31142,7 +31142,7 @@ namespace Tensorflow.Operations /// Same as "var". /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor sparse_apply_adagrad_d_a (Tensor var, Tensor gradient_accumulator, Tensor gradient_squared_accumulator, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor global_step, bool? use_locking = null, string name = "SparseApplyAdagradDA") + public static Tensor sparse_apply_adagrad_d_a(Tensor var, Tensor gradient_accumulator, Tensor gradient_squared_accumulator, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor global_step, bool? use_locking = null, string name = "SparseApplyAdagradDA") { var dict = new Dictionary(); dict["var"] = var; @@ -31222,7 +31222,7 @@ namespace Tensorflow.Operations /// $$mom &lt;- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon)$$ /// $$var &lt;- var - mom$$ /// - public static Tensor sparse_apply_centered_r_m_s_prop (Tensor var, Tensor mg, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyCenteredRMSProp") + public static Tensor sparse_apply_centered_r_m_s_prop(Tensor var, Tensor mg, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyCenteredRMSProp") { var dict = new Dictionary(); dict["var"] = var; @@ -31291,7 +31291,7 @@ namespace Tensorflow.Operations /// $$var = (sign(linear) * l1 - linear) / quadratic\ if\ |linear| &gt; l1\ else\ 0.0$$ /// $$accum = accum_{new}$$ /// - public static Tensor sparse_apply_ftrl (Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor lr_power, bool? use_locking = null, string name = "SparseApplyFtrl") + public static Tensor sparse_apply_ftrl(Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor lr_power, bool? use_locking = null, string name = "SparseApplyFtrl") { var dict = new Dictionary(); dict["var"] = var; @@ -31363,7 +31363,7 @@ namespace Tensorflow.Operations /// var = (sign(linear) * l1 - linear) / quadratic if |linear| &gt; l1 else 0.0 /// accum = accum_new /// - public static Tensor sparse_apply_ftrl_v2 (Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor l2_shrinkage, Tensor lr_power, bool? use_locking = null, string name = "SparseApplyFtrlV2") + public static Tensor sparse_apply_ftrl_v2(Tensor var, Tensor accum, Tensor linear, Tensor grad, Tensor indices, Tensor lr, Tensor l1, Tensor l2, Tensor l2_shrinkage, Tensor lr_power, bool? use_locking = null, string name = "SparseApplyFtrlV2") { var dict = new Dictionary(); dict["var"] = var; @@ -31428,7 +31428,7 @@ namespace Tensorflow.Operations /// $$accum = accum * momentum + grad$$ /// $$var -= lr * accum$$ /// - public static Tensor sparse_apply_momentum (Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor indices, Tensor momentum, bool? use_locking = null, bool? use_nesterov = null, string name = "SparseApplyMomentum") + public static Tensor sparse_apply_momentum(Tensor var, Tensor accum, Tensor lr, Tensor grad, Tensor indices, Tensor momentum, bool? use_locking = null, bool? use_nesterov = null, string name = "SparseApplyMomentum") { var dict = new Dictionary(); dict["var"] = var; @@ -31487,7 +31487,7 @@ namespace Tensorflow.Operations /// $$prox_v -= lr * grad * (1 / sqrt(accum))$$ /// $$var = sign(prox_v)/(1+lr*l2) * max{|prox_v|-lr*l1,0}$$ /// - public static Tensor sparse_apply_proximal_adagrad (Tensor var, Tensor accum, Tensor lr, Tensor l1, Tensor l2, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyProximalAdagrad") + public static Tensor sparse_apply_proximal_adagrad(Tensor var, Tensor accum, Tensor lr, Tensor l1, Tensor l2, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyProximalAdagrad") { var dict = new Dictionary(); dict["var"] = var; @@ -31540,7 +31540,7 @@ namespace Tensorflow.Operations /// $$prox_v = var - alpha * grad$$ /// $$var = sign(prox_v)/(1+alpha*l2) * max{|prox_v|-alpha*l1,0}$$ /// - public static Tensor sparse_apply_proximal_gradient_descent (Tensor var, Tensor alpha, Tensor l1, Tensor l2, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyProximalGradientDescent") + public static Tensor sparse_apply_proximal_gradient_descent(Tensor var, Tensor alpha, Tensor l1, Tensor l2, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyProximalGradientDescent") { var dict = new Dictionary(); dict["var"] = var; @@ -31608,7 +31608,7 @@ namespace Tensorflow.Operations /// $$mom &lt;- momentum * mom_{t-1} + lr * grad / sqrt(ms + epsilon)$$ /// $$var &lt;- var - mom$$ /// - public static Tensor sparse_apply_r_m_s_prop (Tensor var, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyRMSProp") + public static Tensor sparse_apply_r_m_s_prop(Tensor var, Tensor ms, Tensor mom, Tensor lr, Tensor rho, Tensor momentum, Tensor epsilon, Tensor grad, Tensor indices, bool? use_locking = null, string name = "SparseApplyRMSProp") { var dict = new Dictionary(); dict["var"] = var; @@ -31696,7 +31696,7 @@ namespace Tensorflow.Operations /// [ a] concat [ d e ] = [ a d e ] /// [b c ] [ ] [b c ] /// - public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_concat (Tensor[] indices, Tensor[] values, Tensor[] shapes, int concat_dim, string name = "SparseConcat") + public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_concat(Tensor[] indices, Tensor[] values, Tensor[] shapes, int concat_dim, string name = "SparseConcat") { var dict = new Dictionary(); dict["indices"] = indices; @@ -31745,7 +31745,7 @@ namespace Tensorflow.Operations /// resets the aggregate to 0, and increments the global_step recorded by /// the accumulator. /// - public static Tensor sparse_conditional_accumulator (TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "SparseConditionalAccumulator") + public static Tensor sparse_conditional_accumulator(TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "SparseConditionalAccumulator") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -31843,7 +31843,7 @@ namespace Tensorflow.Operations /// Fingerprint64("g"), FingerprintCat64( /// Fingerprint64("e"), Fingerprint64("c"))) /// - public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_cross (Tensor[] indices, Tensor[] values, Tensor[] shapes, Tensor[] dense_inputs, bool hashed_output, int num_buckets, int hash_key, TF_DataType out_type, TF_DataType internal_type, string name = "SparseCross") + public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_cross(Tensor[] indices, Tensor[] values, Tensor[] shapes, Tensor[] dense_inputs, bool hashed_output, int num_buckets, int hash_key, TF_DataType out_type, TF_DataType internal_type, string name = "SparseCross") { var dict = new Dictionary(); dict["indices"] = indices; @@ -31896,7 +31896,7 @@ namespace Tensorflow.Operations /// indices and shape, but possibly with different non-zero values. The output of /// this Op is the resultant non-zero values. /// - public static Tensor sparse_dense_cwise_add (Tensor sp_indices, Tensor sp_values, Tensor sp_shape, Tensor dense, string name = "SparseDenseCwiseAdd") + public static Tensor sparse_dense_cwise_add(Tensor sp_indices, Tensor sp_values, Tensor sp_shape, Tensor dense, string name = "SparseDenseCwiseAdd") { var dict = new Dictionary(); dict["sp_indices"] = sp_indices; @@ -31934,7 +31934,7 @@ namespace Tensorflow.Operations /// *Limitation*: this Op only broadcasts the dense side to the sparse side, but not /// the other direction. /// - public static Tensor sparse_dense_cwise_div (Tensor sp_indices, Tensor sp_values, Tensor sp_shape, Tensor dense, string name = "SparseDenseCwiseDiv") + public static Tensor sparse_dense_cwise_div(Tensor sp_indices, Tensor sp_values, Tensor sp_shape, Tensor dense, string name = "SparseDenseCwiseDiv") { var dict = new Dictionary(); dict["sp_indices"] = sp_indices; @@ -31976,7 +31976,7 @@ namespace Tensorflow.Operations /// *Limitation*: this Op only broadcasts the dense side to the sparse side, but not /// the other direction. /// - public static Tensor sparse_dense_cwise_mul (Tensor sp_indices, Tensor sp_values, Tensor sp_shape, Tensor dense, string name = "SparseDenseCwiseMul") + public static Tensor sparse_dense_cwise_mul(Tensor sp_indices, Tensor sp_values, Tensor sp_shape, Tensor dense, string name = "SparseDenseCwiseMul") { var dict = new Dictionary(); dict["sp_indices"] = sp_indices; @@ -32054,7 +32054,7 @@ namespace Tensorflow.Operations /// /// reverse_index_map[j] = out_j s.t. indices[j, :] == output_indices[out_j, :] /// - public static (Tensor output_indices, Tensor output_values, Tensor empty_row_indicator, Tensor reverse_index_map) sparse_fill_empty_rows (Tensor indices, Tensor values, Tensor dense_shape, Tensor default_value, string name = "SparseFillEmptyRows") + public static (Tensor output_indices, Tensor output_values, Tensor empty_row_indicator, Tensor reverse_index_map) sparse_fill_empty_rows(Tensor indices, Tensor values, Tensor dense_shape, Tensor default_value, string name = "SparseFillEmptyRows") { var dict = new Dictionary(); dict["indices"] = indices; @@ -32098,7 +32098,7 @@ namespace Tensorflow.Operations /// d_default_value = sum_{k : 0 .. N_full - 1} ( /// grad_values[k] * 1{k not in reverse_index_map}) /// - public static (Tensor d_values, Tensor d_default_value) sparse_fill_empty_rows_grad (Tensor reverse_index_map, Tensor grad_values, string name = "SparseFillEmptyRowsGrad") + public static (Tensor d_values, Tensor d_default_value) sparse_fill_empty_rows_grad(Tensor reverse_index_map, Tensor grad_values, string name = "SparseFillEmptyRowsGrad") { var dict = new Dictionary(); dict["reverse_index_map"] = reverse_index_map; @@ -32142,7 +32142,7 @@ namespace Tensorflow.Operations /// The gradient computation of this operation will only take advantage of sparsity /// in the input gradient when that gradient comes from a Relu. /// - public static Tensor sparse_mat_mul (Tensor a, Tensor b, bool? transpose_a = null, bool? transpose_b = null, bool? a_is_sparse = null, bool? b_is_sparse = null, string name = "SparseMatMul") + public static Tensor sparse_mat_mul(Tensor a, Tensor b, bool? transpose_a = null, bool? transpose_b = null, bool? a_is_sparse = null, bool? b_is_sparse = null, string name = "SparseMatMul") { var dict = new Dictionary(); dict["a"] = a; @@ -32199,7 +32199,7 @@ namespace Tensorflow.Operations /// with a single element is returned. Additionally, the axes can be negative, /// which are interpreted according to the indexing rules in Python. /// - public static Tensor sparse_reduce_max (Tensor input_indices, Tensor input_values, Tensor input_shape, Tensor reduction_axes, bool? keep_dims = null, string name = "SparseReduceMax") + public static Tensor sparse_reduce_max(Tensor input_indices, Tensor input_values, Tensor input_shape, Tensor reduction_axes, bool? keep_dims = null, string name = "SparseReduceMax") { var dict = new Dictionary(); dict["input_indices"] = input_indices; @@ -32255,7 +32255,7 @@ namespace Tensorflow.Operations /// with a single element is returned. Additionally, the axes can be negative, /// which are interpreted according to the indexing rules in Python. /// - public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_reduce_max_sparse (Tensor input_indices, Tensor input_values, Tensor input_shape, Tensor reduction_axes, bool? keep_dims = null, string name = "SparseReduceMaxSparse") + public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_reduce_max_sparse(Tensor input_indices, Tensor input_values, Tensor input_shape, Tensor reduction_axes, bool? keep_dims = null, string name = "SparseReduceMaxSparse") { var dict = new Dictionary(); dict["input_indices"] = input_indices; @@ -32312,7 +32312,7 @@ namespace Tensorflow.Operations /// with a single element is returned. Additionally, the axes can be negative, /// which are interpreted according to the indexing rules in Python. /// - public static Tensor sparse_reduce_sum (Tensor input_indices, Tensor input_values, Tensor input_shape, Tensor reduction_axes, bool? keep_dims = null, string name = "SparseReduceSum") + public static Tensor sparse_reduce_sum(Tensor input_indices, Tensor input_values, Tensor input_shape, Tensor reduction_axes, bool? keep_dims = null, string name = "SparseReduceSum") { var dict = new Dictionary(); dict["input_indices"] = input_indices; @@ -32368,7 +32368,7 @@ namespace Tensorflow.Operations /// with a single element is returned. Additionally, the axes can be negative, /// which are interpreted according to the indexing rules in Python. /// - public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_reduce_sum_sparse (Tensor input_indices, Tensor input_values, Tensor input_shape, Tensor reduction_axes, bool? keep_dims = null, string name = "SparseReduceSumSparse") + public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_reduce_sum_sparse(Tensor input_indices, Tensor input_values, Tensor input_shape, Tensor reduction_axes, bool? keep_dims = null, string name = "SparseReduceSumSparse") { var dict = new Dictionary(); dict["input_indices"] = input_indices; @@ -32418,7 +32418,7 @@ namespace Tensorflow.Operations /// If the tensor has rank R and N non-empty values, input_indices has /// shape [N, R], input_values has length N, and input_shape has length R. /// - public static (Tensor output_indices, Tensor output_values) sparse_reorder (Tensor input_indices, Tensor input_values, Tensor input_shape, string name = "SparseReorder") + public static (Tensor output_indices, Tensor output_values) sparse_reorder(Tensor input_indices, Tensor input_values, Tensor input_shape, string name = "SparseReorder") { var dict = new Dictionary(); dict["input_indices"] = input_indices; @@ -32473,7 +32473,7 @@ namespace Tensorflow.Operations /// input_shape has length R_in, output_indices has shape [N, R_out], and /// output_shape has length R_out. /// - public static (Tensor output_indices, Tensor output_shape) sparse_reshape (Tensor input_indices, Tensor input_shape, Tensor new_shape, string name = "SparseReshape") + public static (Tensor output_indices, Tensor output_shape) sparse_reshape(Tensor input_indices, Tensor input_shape, Tensor new_shape, string name = "SparseReshape") { var dict = new Dictionary(); dict["input_indices"] = input_indices; @@ -32513,7 +32513,7 @@ namespace Tensorflow.Operations /// Like SegmentMean, but segment_ids can have rank less than data's first /// dimension, selecting a subset of dimension 0, specified by indices. /// - public static Tensor sparse_segment_mean (Tensor data, Tensor indices, Tensor segment_ids, string name = "SparseSegmentMean") + public static Tensor sparse_segment_mean(Tensor data, Tensor indices, Tensor segment_ids, string name = "SparseSegmentMean") { var dict = new Dictionary(); dict["data"] = data; @@ -32548,7 +32548,7 @@ namespace Tensorflow.Operations /// Returns tensor "output" with same shape as grad, except for dimension 0 whose /// value is output_dim0. /// - public static Tensor sparse_segment_mean_grad (Tensor grad, Tensor indices, Tensor segment_ids, Tensor output_dim0, string name = "SparseSegmentMeanGrad") + public static Tensor sparse_segment_mean_grad(Tensor grad, Tensor indices, Tensor segment_ids, Tensor output_dim0, string name = "SparseSegmentMeanGrad") { var dict = new Dictionary(); dict["grad"] = grad; @@ -32589,7 +32589,7 @@ namespace Tensorflow.Operations /// [the section on segmentation](https://tensorflow.org/api_guides/python/math_ops#Segmentation) /// for an explanation of segments. /// - public static Tensor sparse_segment_mean_with_num_segments (Tensor data, Tensor indices, Tensor segment_ids, Tensor num_segments, string name = "SparseSegmentMeanWithNumSegments") + public static Tensor sparse_segment_mean_with_num_segments(Tensor data, Tensor indices, Tensor segment_ids, Tensor num_segments, string name = "SparseSegmentMeanWithNumSegments") { var dict = new Dictionary(); dict["data"] = data; @@ -32626,7 +32626,7 @@ namespace Tensorflow.Operations /// [the section on segmentation](https://tensorflow.org/api_guides/python/math_ops#Segmentation) /// for an explanation of segments. /// - public static Tensor sparse_segment_sqrt_n (Tensor data, Tensor indices, Tensor segment_ids, string name = "SparseSegmentSqrtN") + public static Tensor sparse_segment_sqrt_n(Tensor data, Tensor indices, Tensor segment_ids, string name = "SparseSegmentSqrtN") { var dict = new Dictionary(); dict["data"] = data; @@ -32661,7 +32661,7 @@ namespace Tensorflow.Operations /// Returns tensor "output" with same shape as grad, except for dimension 0 whose /// value is output_dim0. /// - public static Tensor sparse_segment_sqrt_n_grad (Tensor grad, Tensor indices, Tensor segment_ids, Tensor output_dim0, string name = "SparseSegmentSqrtNGrad") + public static Tensor sparse_segment_sqrt_n_grad(Tensor grad, Tensor indices, Tensor segment_ids, Tensor output_dim0, string name = "SparseSegmentSqrtNGrad") { var dict = new Dictionary(); dict["grad"] = grad; @@ -32704,7 +32704,7 @@ namespace Tensorflow.Operations /// [the section on segmentation](https://tensorflow.org/api_guides/python/math_ops#Segmentation) /// for an explanation of segments. /// - public static Tensor sparse_segment_sqrt_n_with_num_segments (Tensor data, Tensor indices, Tensor segment_ids, Tensor num_segments, string name = "SparseSegmentSqrtNWithNumSegments") + public static Tensor sparse_segment_sqrt_n_with_num_segments(Tensor data, Tensor indices, Tensor segment_ids, Tensor num_segments, string name = "SparseSegmentSqrtNWithNumSegments") { var dict = new Dictionary(); dict["data"] = data; @@ -32765,7 +32765,7 @@ namespace Tensorflow.Operations /// tf.segment_sum(c, tf.constant([0, 0, 1])) /// /// - public static Tensor sparse_segment_sum (Tensor data, Tensor indices, Tensor segment_ids, string name = "SparseSegmentSum") + public static Tensor sparse_segment_sum(Tensor data, Tensor indices, Tensor segment_ids, string name = "SparseSegmentSum") { var dict = new Dictionary(); dict["data"] = data; @@ -32826,7 +32826,7 @@ namespace Tensorflow.Operations /// # [ 0 0 0 0]] /// /// - public static Tensor sparse_segment_sum_with_num_segments (Tensor data, Tensor indices, Tensor segment_ids, Tensor num_segments, string name = "SparseSegmentSumWithNumSegments") + public static Tensor sparse_segment_sum_with_num_segments(Tensor data, Tensor indices, Tensor segment_ids, Tensor num_segments, string name = "SparseSegmentSumWithNumSegments") { var dict = new Dictionary(); dict["data"] = data; @@ -32886,7 +32886,7 @@ namespace Tensorflow.Operations /// [ d e ] /// [ ] /// - public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_slice (Tensor indices, Tensor values, Tensor shape, Tensor start, Tensor size, string name = "SparseSlice") + public static (Tensor output_indices, Tensor output_values, Tensor output_shape) sparse_slice(Tensor indices, Tensor values, Tensor shape, Tensor start, Tensor size, string name = "SparseSlice") { var dict = new Dictionary(); dict["indices"] = indices; @@ -32930,7 +32930,7 @@ namespace Tensorflow.Operations /// the sliced SparseTensor, and outputs the gradients w.r.t. /// the non-empty values of input SparseTensor. /// - public static Tensor sparse_slice_grad (Tensor backprop_val_grad, Tensor input_indices, Tensor input_start, Tensor output_indices, string name = "SparseSliceGrad") + public static Tensor sparse_slice_grad(Tensor backprop_val_grad, Tensor input_indices, Tensor input_start, Tensor output_indices, string name = "SparseSliceGrad") { var dict = new Dictionary(); dict["backprop_val_grad"] = backprop_val_grad; @@ -32978,7 +32978,7 @@ namespace Tensorflow.Operations /// Hence, the SparseTensor result has exactly the same non-zero indices and /// shape. /// - public static Tensor sparse_softmax (Tensor sp_indices, Tensor sp_values, Tensor sp_shape, string name = "SparseSoftmax") + public static Tensor sparse_softmax(Tensor sp_indices, Tensor sp_values, Tensor sp_shape, string name = "SparseSoftmax") { var dict = new Dictionary(); dict["sp_indices"] = sp_indices; @@ -33015,7 +33015,7 @@ namespace Tensorflow.Operations /// /// Inputs are the logits, not probabilities. /// - public static (Tensor loss, Tensor backprop) sparse_softmax_cross_entropy_with_logits (Tensor features, Tensor labels, string name = "SparseSoftmaxCrossEntropyWithLogits") + public static (Tensor loss, Tensor backprop) sparse_softmax_cross_entropy_with_logits(Tensor features, Tensor labels, string name = "SparseSoftmaxCrossEntropyWithLogits") { var dict = new Dictionary(); dict["features"] = features; @@ -33061,7 +33061,7 @@ namespace Tensorflow.Operations /// /// Assumes the two SparseTensors have the same shape, i.e., no broadcasting. /// - public static (Tensor output_indices, Tensor output_values) sparse_sparse_maximum (Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b_indices, Tensor b_values, Tensor b_shape, string name = "SparseSparseMaximum") + public static (Tensor output_indices, Tensor output_values) sparse_sparse_maximum(Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b_indices, Tensor b_values, Tensor b_shape, string name = "SparseSparseMaximum") { var dict = new Dictionary(); dict["a_indices"] = a_indices; @@ -33111,7 +33111,7 @@ namespace Tensorflow.Operations /// /// Assumes the two SparseTensors have the same shape, i.e., no broadcasting. /// - public static (Tensor output_indices, Tensor output_values) sparse_sparse_minimum (Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b_indices, Tensor b_values, Tensor b_shape, string name = "SparseSparseMinimum") + public static (Tensor output_indices, Tensor output_values) sparse_sparse_minimum(Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b_indices, Tensor b_values, Tensor b_shape, string name = "SparseSparseMinimum") { var dict = new Dictionary(); dict["a_indices"] = a_indices; @@ -33180,7 +33180,7 @@ namespace Tensorflow.Operations /// [ d e ] /// [ ] /// - public static (Tensor[] output_indices, Tensor[] output_values, Tensor[] output_shape) sparse_split (Tensor split_dim, Tensor indices, Tensor values, Tensor shape, int num_split, string name = "SparseSplit") + public static (Tensor[] output_indices, Tensor[] output_values, Tensor[] output_shape) sparse_split(Tensor split_dim, Tensor indices, Tensor values, Tensor shape, int num_split, string name = "SparseSplit") { var dict = new Dictionary(); dict["split_dim"] = split_dim; @@ -33220,7 +33220,7 @@ namespace Tensorflow.Operations /// /// This Op does not require a_indices be sorted in standard lexicographic order. /// - public static Tensor sparse_tensor_dense_add (Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b, string name = "SparseTensorDenseAdd") + public static Tensor sparse_tensor_dense_add(Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b, string name = "SparseTensorDenseAdd") { var dict = new Dictionary(); dict["a_indices"] = a_indices; @@ -33271,7 +33271,7 @@ namespace Tensorflow.Operations /// A should be sorted in order of increasing dimension 1 (i.e., "column major" /// order instead of "row major" order). /// - public static Tensor sparse_tensor_dense_mat_mul (Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b, bool? adjoint_a = null, bool? adjoint_b = null, string name = "SparseTensorDenseMatMul") + public static Tensor sparse_tensor_dense_mat_mul(Tensor a_indices, Tensor a_values, Tensor a_shape, Tensor b, bool? adjoint_a = null, bool? adjoint_b = null, string name = "SparseTensorDenseMatMul") { var dict = new Dictionary(); dict["a_indices"] = a_indices; @@ -33301,7 +33301,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor sparse_tensor_slice_dataset (Tensor indices, Tensor values, Tensor dense_shape, string name = "SparseTensorSliceDataset") + public static Tensor sparse_tensor_slice_dataset(Tensor indices, Tensor values, Tensor dense_shape, string name = "SparseTensorSliceDataset") { var dict = new Dictionary(); dict["indices"] = indices; @@ -33361,7 +33361,7 @@ namespace Tensorflow.Operations /// contain any repeats. If validate_indices is true, these properties /// are checked during execution. /// - public static Tensor sparse_to_dense (Tensor sparse_indices, Tensor output_shape, Tensor sparse_values, Tensor default_value, bool? validate_indices = null, string name = "SparseToDense") + public static Tensor sparse_to_dense(Tensor sparse_indices, Tensor output_shape, Tensor sparse_values, Tensor default_value, bool? validate_indices = null, string name = "SparseToDense") { var dict = new Dictionary(); dict["sparse_indices"] = sparse_indices; @@ -33445,7 +33445,7 @@ namespace Tensorflow.Operations /// dimension contains the result of set_operation applied to the corresponding /// [0...n-1] dimension of set. /// - public static (Tensor result_indices, Tensor result_values, Tensor result_shape) sparse_to_sparse_set_operation (Tensor set1_indices, Tensor set1_values, Tensor set1_shape, Tensor set2_indices, Tensor set2_values, Tensor set2_shape, string set_operation, bool? validate_indices = null, string name = "SparseToSparseSetOperation") + public static (Tensor result_indices, Tensor result_values, Tensor result_shape) sparse_to_sparse_set_operation(Tensor set1_indices, Tensor set1_values, Tensor set1_shape, Tensor set2_indices, Tensor set2_values, Tensor set2_shape, string set_operation, bool? validate_indices = null, string name = "SparseToSparseSetOperation") { var dict = new Dictionary(); dict["set1_indices"] = set1_indices; @@ -33489,7 +33489,7 @@ namespace Tensorflow.Operations /// values.shape[split_dim] / num_split. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor[] split (Tensor split_dim, Tensor value, int num_split, string name = "Split") + public static Tensor[] split(Tensor split_dim, Tensor value, int num_split, string name = "Split") { var dict = new Dictionary(); dict["split_dim"] = split_dim; @@ -33528,7 +33528,7 @@ namespace Tensorflow.Operations /// size_splits[i]. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor[] split_v (Tensor value, Tensor size_splits, Tensor split_dim, int num_split, string name = "SplitV") + public static Tensor[] split_v(Tensor value, Tensor size_splits, Tensor split_dim, int num_split, string name = "SplitV") { var dict = new Dictionary(); dict["value"] = value; @@ -33565,7 +33565,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor sql_dataset (Tensor driver_name, Tensor data_source_name, Tensor query, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SqlDataset") + public static Tensor sql_dataset(Tensor driver_name, Tensor data_source_name, Tensor query, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SqlDataset") { var dict = new Dictionary(); dict["driver_name"] = driver_name; @@ -33591,7 +33591,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = \sqrt{x} = x^{1/2}\\). /// - public static Tensor sqrt (Tensor x, string name = "Sqrt") + public static Tensor sqrt(Tensor x, string name = "Sqrt") { var dict = new Dictionary(); dict["x"] = x; @@ -33616,7 +33616,7 @@ namespace Tensorflow.Operations /// Specifically, grad = dy * 0.5 / y, where y = sqrt(x), and dy /// is the corresponding input gradient. /// - public static Tensor sqrt_grad (Tensor y, Tensor dy, string name = "SqrtGrad") + public static Tensor sqrt_grad(Tensor y, Tensor dy, string name = "SqrtGrad") { var dict = new Dictionary(); dict["y"] = y; @@ -33639,7 +33639,7 @@ namespace Tensorflow.Operations /// /// I.e., \\(y = x * x = x^2\\). /// - public static Tensor square (Tensor x, string name = "Square") + public static Tensor square(Tensor x, string name = "Square") { var dict = new Dictionary(); dict["x"] = x; @@ -33664,7 +33664,7 @@ namespace Tensorflow.Operations /// *NOTE*: SquaredDifference supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor squared_difference (Tensor x, Tensor y, string name = "SquaredDifference") + public static Tensor squared_difference(Tensor x, Tensor y, string name = "SquaredDifference") { var dict = new Dictionary(); dict["x"] = x; @@ -33712,7 +33712,7 @@ namespace Tensorflow.Operations /// shape(squeeze(t, [2, 4])) ==&gt; [1, 2, 3, 1] /// /// - public static Tensor squeeze (Tensor input, int[] squeeze_dims = null, string name = "Squeeze") + public static Tensor squeeze(Tensor input, int[] squeeze_dims = null, string name = "Squeeze") { var dict = new Dictionary(); dict["input"] = input; @@ -33736,7 +33736,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stack (TF_DataType elem_type, string stack_name = null, string name = "Stack") + public static Tensor stack(TF_DataType elem_type, string stack_name = null, string name = "Stack") { var dict = new Dictionary(); dict["elem_type"] = elem_type; @@ -33757,7 +33757,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation stack_close (Tensor handle, string name = "StackClose") + public static Operation stack_close(Tensor handle, string name = "StackClose") { var dict = new Dictionary(); dict["handle"] = handle; @@ -33777,7 +33777,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation stack_close_v2 (Tensor handle, string name = "StackCloseV2") + public static Operation stack_close_v2(Tensor handle, string name = "StackCloseV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -33799,7 +33799,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stack_pop (Tensor handle, TF_DataType elem_type, string name = "StackPop") + public static Tensor stack_pop(Tensor handle, TF_DataType elem_type, string name = "StackPop") { var dict = new Dictionary(); dict["handle"] = handle; @@ -33825,7 +33825,7 @@ namespace Tensorflow.Operations /// The tensor that is popped from the top of the stack. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stack_pop_v2 (Tensor handle, TF_DataType elem_type, string name = "StackPopV2") + public static Tensor stack_pop_v2(Tensor handle, TF_DataType elem_type, string name = "StackPopV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -33849,7 +33849,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stack_push (Tensor handle, Tensor elem, bool? swap_memory = null, string name = "StackPush") + public static Tensor stack_push(Tensor handle, Tensor elem, bool? swap_memory = null, string name = "StackPush") { var dict = new Dictionary(); dict["handle"] = handle; @@ -33879,7 +33879,7 @@ namespace Tensorflow.Operations /// The same tensor as the input 'elem'. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stack_push_v2 (Tensor handle, Tensor elem, bool? swap_memory = null, string name = "StackPushV2") + public static Tensor stack_push_v2(Tensor handle, Tensor elem, bool? swap_memory = null, string name = "StackPushV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -33912,7 +33912,7 @@ namespace Tensorflow.Operations /// The handle to the stack. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stack_v2 (Tensor max_size, TF_DataType elem_type, string stack_name = null, string name = "StackV2") + public static Tensor stack_v2(Tensor max_size, TF_DataType elem_type, string stack_name = null, string name = "StackV2") { var dict = new Dictionary(); dict["max_size"] = max_size; @@ -33955,7 +33955,7 @@ namespace Tensorflow.Operations /// The basic functionality of this Op is similar to a queue with many /// fewer capabilities and options. This Op is optimized for performance. /// - public static Operation stage (Tensor[] values, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "Stage") + public static Operation stage(Tensor[] values, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "Stage") { var dict = new Dictionary(); dict["values"] = values; @@ -33991,7 +33991,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation stage_clear (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "StageClear") + public static Operation stage_clear(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "StageClear") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -34034,7 +34034,7 @@ namespace Tensorflow.Operations /// this op will block until it does. This Op is optimized for /// performance. /// - public static Tensor[] stage_peek (Tensor index, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "StagePeek") + public static Tensor[] stage_peek(Tensor index, TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "StagePeek") { var dict = new Dictionary(); dict["index"] = index; @@ -34073,7 +34073,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stage_size (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "StageSize") + public static Tensor stage_size(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "StageSize") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -34112,7 +34112,7 @@ namespace Tensorflow.Operations /// contains the drawn class labels with range [0, num_classes). /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stateless_multinomial (Tensor logits, Tensor num_samples, Tensor seed, TF_DataType? output_dtype = null, string name = "StatelessMultinomial") + public static Tensor stateless_multinomial(Tensor logits, Tensor num_samples, Tensor seed, TF_DataType? output_dtype = null, string name = "StatelessMultinomial") { var dict = new Dictionary(); dict["logits"] = logits; @@ -34148,7 +34148,7 @@ namespace Tensorflow.Operations /// /// The outputs are a deterministic function of shape and seed. /// - public static Tensor stateless_random_normal (Tensor shape, Tensor seed, TF_DataType? dtype = null, string name = "StatelessRandomNormal") + public static Tensor stateless_random_normal(Tensor shape, Tensor seed, TF_DataType? dtype = null, string name = "StatelessRandomNormal") { var dict = new Dictionary(); dict["shape"] = shape; @@ -34184,7 +34184,7 @@ namespace Tensorflow.Operations /// /// The outputs are a deterministic function of shape and seed. /// - public static Tensor stateless_random_uniform (Tensor shape, Tensor seed, TF_DataType? dtype = null, string name = "StatelessRandomUniform") + public static Tensor stateless_random_uniform(Tensor shape, Tensor seed, TF_DataType? dtype = null, string name = "StatelessRandomUniform") { var dict = new Dictionary(); dict["shape"] = shape; @@ -34221,7 +34221,7 @@ namespace Tensorflow.Operations /// /// The outputs are a deterministic function of shape and seed. /// - public static Tensor stateless_truncated_normal (Tensor shape, Tensor seed, TF_DataType? dtype = null, string name = "StatelessTruncatedNormal") + public static Tensor stateless_truncated_normal(Tensor shape, Tensor seed, TF_DataType? dtype = null, string name = "StatelessTruncatedNormal") { var dict = new Dictionary(); dict["shape"] = shape; @@ -34260,7 +34260,7 @@ namespace Tensorflow.Operations /// /// It follows the re2 syntax (https://github.com/google/re2/wiki/Syntax) /// - public static Tensor static_regex_replace (Tensor input, string pattern, string rewrite, bool? replace_global = null, string name = "StaticRegexReplace") + public static Tensor static_regex_replace(Tensor input, string pattern, string rewrite, bool? replace_global = null, string name = "StaticRegexReplace") { var dict = new Dictionary(); dict["input"] = input; @@ -34285,7 +34285,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stats_aggregator_handle (string container = null, string shared_name = null, string name = "StatsAggregatorHandle") + public static Tensor stats_aggregator_handle(string container = null, string shared_name = null, string name = "StatsAggregatorHandle") { var dict = new Dictionary(); if (container != null) @@ -34307,7 +34307,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor stats_aggregator_summary (Tensor iterator, string name = "StatsAggregatorSummary") + public static Tensor stats_aggregator_summary(Tensor iterator, string name = "StatsAggregatorSummary") { var dict = new Dictionary(); dict["iterator"] = iterator; @@ -34347,7 +34347,7 @@ namespace Tensorflow.Operations /// * Adversarial training, where no backprop should happen through the adversarial /// example generation process. /// - public static Tensor stop_gradient (Tensor input, string name = "StopGradient") + public static Tensor stop_gradient(Tensor input, string name = "StopGradient") { var dict = new Dictionary(); dict["input"] = input; @@ -34505,7 +34505,7 @@ namespace Tensorflow.Operations /// 0 != strides[i] for i in [0, m) /// ellipsis_mask must be a power of two (only one ellipsis) /// - public static Tensor strided_slice (Tensor input, Tensor begin, Tensor end, Tensor strides, int? begin_mask = null, int? end_mask = null, int? ellipsis_mask = null, int? new_axis_mask = null, int? shrink_axis_mask = null, string name = "StridedSlice") + public static Tensor strided_slice(Tensor input, Tensor begin, Tensor end, Tensor strides, int? begin_mask = null, int? end_mask = null, int? ellipsis_mask = null, int? new_axis_mask = null, int? shrink_axis_mask = null, string name = "StridedSlice") { var dict = new Dictionary(); dict["input"] = input; @@ -34563,7 +34563,7 @@ namespace Tensorflow.Operations /// NOTE this op currently does not support broadcasting and so value's /// shape must be exactly the shape produced by the slice of ref. /// - public static Tensor strided_slice_assign (Tensor referecne, Tensor begin, Tensor end, Tensor strides, Tensor value, int? begin_mask = null, int? end_mask = null, int? ellipsis_mask = null, int? new_axis_mask = null, int? shrink_axis_mask = null, string name = "StridedSliceAssign") + public static Tensor strided_slice_assign(Tensor referecne, Tensor begin, Tensor end, Tensor strides, Tensor value, int? begin_mask = null, int? end_mask = null, int? ellipsis_mask = null, int? new_axis_mask = null, int? shrink_axis_mask = null, string name = "StridedSliceAssign") { var dict = new Dictionary(); dict["ref"] = referecne; @@ -34624,7 +34624,7 @@ namespace Tensorflow.Operations /// dy is the input gradient to be propagated and shape is the /// shape of StridedSlice's input. /// - public static Tensor strided_slice_grad (Tensor shape, Tensor begin, Tensor end, Tensor strides, Tensor dy, int? begin_mask = null, int? end_mask = null, int? ellipsis_mask = null, int? new_axis_mask = null, int? shrink_axis_mask = null, string name = "StridedSliceGrad") + public static Tensor strided_slice_grad(Tensor shape, Tensor begin, Tensor end, Tensor strides, Tensor dy, int? begin_mask = null, int? end_mask = null, int? ellipsis_mask = null, int? new_axis_mask = null, int? shrink_axis_mask = null, string name = "StridedSliceGrad") { var dict = new Dictionary(); dict["shape"] = shape; @@ -34666,7 +34666,7 @@ namespace Tensorflow.Operations /// /// with the given separator (default is an empty separator). /// - public static Tensor string_join (Tensor[] inputs, string separator = null, string name = "StringJoin") + public static Tensor string_join(Tensor[] inputs, string separator = null, string name = "StringJoin") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -34722,7 +34722,7 @@ namespace Tensorflow.Operations /// shape = [2, 3] /// values = ['hello', 'world', 'a', 'b', 'c'] /// - public static (Tensor indices, Tensor values, Tensor shape) string_split (Tensor input, Tensor delimiter, bool? skip_empty = null, string name = "StringSplit") + public static (Tensor indices, Tensor values, Tensor shape) string_split(Tensor input, Tensor delimiter, bool? skip_empty = null, string name = "StringSplit") { var dict = new Dictionary(); dict["input"] = input; @@ -34785,7 +34785,7 @@ namespace Tensorflow.Operations /// /// Note that the above mentioned behavior matches python's str.split. /// - public static (Tensor indices, Tensor values, Tensor shape) string_split_v2 (Tensor input, Tensor sep, int? maxsplit = null, string name = "StringSplitV2") + public static (Tensor indices, Tensor values, Tensor shape) string_split_v2(Tensor input, Tensor sep, int? maxsplit = null, string name = "StringSplitV2") { var dict = new Dictionary(); dict["input"] = input; @@ -34813,7 +34813,7 @@ namespace Tensorflow.Operations /// A string Tensor of the same shape as the input. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor string_strip (Tensor input, string name = "StringStrip") + public static Tensor string_strip(Tensor input, string name = "StringStrip") { var dict = new Dictionary(); dict["input"] = input; @@ -34845,7 +34845,7 @@ namespace Tensorflow.Operations /// This functionality will be deprecated and it's recommended to use /// tf.string_to_hash_bucket_fast() or tf.string_to_hash_bucket_strong(). /// - public static Tensor string_to_hash_bucket (Tensor string_tensor, int num_buckets, string name = "StringToHashBucket") + public static Tensor string_to_hash_bucket(Tensor string_tensor, int num_buckets, string name = "StringToHashBucket") { var dict = new Dictionary(); dict["string_tensor"] = string_tensor; @@ -34879,7 +34879,7 @@ namespace Tensorflow.Operations /// to the same bucket. To prevent this problem, use a strong hash function with /// tf.string_to_hash_bucket_strong. /// - public static Tensor string_to_hash_bucket_fast (Tensor input, int num_buckets, string name = "StringToHashBucketFast") + public static Tensor string_to_hash_bucket_fast(Tensor input, int num_buckets, string name = "StringToHashBucketFast") { var dict = new Dictionary(); dict["input"] = input; @@ -34922,7 +34922,7 @@ namespace Tensorflow.Operations /// that hash to the same bucket. This comes at a cost of roughly 4x higher compute /// time than tf.string_to_hash_bucket_fast. /// - public static Tensor string_to_hash_bucket_strong (Tensor input, int num_buckets, int[] key, string name = "StringToHashBucketStrong") + public static Tensor string_to_hash_bucket_strong(Tensor input, int num_buckets, int[] key, string name = "StringToHashBucketStrong") { var dict = new Dictionary(); dict["input"] = input; @@ -34951,7 +34951,7 @@ namespace Tensorflow.Operations /// (Note that int32 overflow results in an error while float overflow /// results in a rounded value.) /// - public static Tensor string_to_number (Tensor string_tensor, TF_DataType? out_type = null, string name = "StringToNumber") + public static Tensor string_to_number(Tensor string_tensor, TF_DataType? out_type = null, string name = "StringToNumber") { var dict = new Dictionary(); dict["string_tensor"] = string_tensor; @@ -34978,7 +34978,7 @@ namespace Tensorflow.Operations /// *NOTE*: Subtract supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor sub (Tensor x, Tensor y, string name = "Sub") + public static Tensor sub(Tensor x, Tensor y, string name = "Sub") { var dict = new Dictionary(); dict["x"] = x; @@ -35083,7 +35083,7 @@ namespace Tensorflow.Operations /// output = [b'hir', b'ee', b'n'] /// /// - public static Tensor substr (Tensor input, Tensor pos, Tensor len, string name = "Substr") + public static Tensor substr(Tensor input, Tensor pos, Tensor len, string name = "Substr") { var dict = new Dictionary(); dict["input"] = input; @@ -35119,7 +35119,7 @@ namespace Tensorflow.Operations /// axis. If keep_dims is true, the reduced dimensions are /// retained with length 1. /// - public static Tensor sum (Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Sum") + public static Tensor sum(Tensor input, Tensor reduction_indices, bool? keep_dims = null, string name = "Sum") { var dict = new Dictionary(); dict["input"] = input; @@ -35174,7 +35174,7 @@ namespace Tensorflow.Operations /// s, _, _ = svd(a, compute_uv=False) /// /// - public static (Tensor s, Tensor u, Tensor v) svd (Tensor input, bool? compute_uv = null, bool? full_matrices = null, string name = "Svd") + public static (Tensor s, Tensor u, Tensor v) svd(Tensor input, bool? compute_uv = null, bool? full_matrices = null, string name = "Svd") { var dict = new Dictionary(); dict["input"] = input; @@ -35214,7 +35214,7 @@ namespace Tensorflow.Operations /// /// See also RefSwitch and Merge. /// - public static (Tensor output_false, Tensor output_true) switch_ (Tensor data, Tensor pred, string name = "Switch") + public static (Tensor output_false, Tensor output_true) switch_(Tensor data, Tensor pred, string name = "Switch") { var dict = new Dictionary(); dict["data"] = data; @@ -35247,7 +35247,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor t_f_record_dataset (Tensor filenames, Tensor compression_type, Tensor buffer_size, string name = "TFRecordDataset") + public static Tensor t_f_record_dataset(Tensor filenames, Tensor compression_type, Tensor buffer_size, string name = "TFRecordDataset") { var dict = new Dictionary(); dict["filenames"] = filenames; @@ -35277,7 +35277,7 @@ namespace Tensorflow.Operations /// The handle to reference the Reader. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor t_f_record_reader (string container = null, string shared_name = null, string compression_type = null, string name = "TFRecordReader") + public static Tensor t_f_record_reader(string container = null, string shared_name = null, string compression_type = null, string name = "TFRecordReader") { var dict = new Dictionary(); if (container != null) @@ -35310,7 +35310,7 @@ namespace Tensorflow.Operations /// The handle to reference the Reader. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor t_f_record_reader_v2 (string container = null, string shared_name = null, string compression_type = null, string name = "TFRecordReaderV2") + public static Tensor t_f_record_reader_v2(string container = null, string shared_name = null, string compression_type = null, string name = "TFRecordReaderV2") { var dict = new Dictionary(); if (container != null) @@ -35355,7 +35355,7 @@ namespace Tensorflow.Operations /// differentiation of graphs containing embeddings via the TPU Embedding Python /// libraries. /// - public static Tensor t_p_u_embedding_activations (Tensor embedding_variable, Tensor sliced_activations, int table_id, int lookup_id, string name = "TPUEmbeddingActivations") + public static Tensor t_p_u_embedding_activations(Tensor embedding_variable, Tensor sliced_activations, int table_id, int lookup_id, string name = "TPUEmbeddingActivations") { var dict = new Dictionary(); dict["embedding_variable"] = embedding_variable; @@ -35409,7 +35409,7 @@ namespace Tensorflow.Operations /// There should be at most one TPUEmbeddingEnqueueSparseBatch op in a signle /// training step per TPU shard. /// - public static Operation t_p_u_embedding_enqueue_sparse_batch (Tensor[] sample_indices, Tensor[] embedding_indices, Tensor[] aggregation_weights, int? device_ordinal = null, string name = "TPUEmbeddingEnqueueSparseBatch") + public static Operation t_p_u_embedding_enqueue_sparse_batch(Tensor[] sample_indices, Tensor[] embedding_indices, Tensor[] aggregation_weights, int? device_ordinal = null, string name = "TPUEmbeddingEnqueueSparseBatch") { var dict = new Dictionary(); dict["sample_indices"] = sample_indices; @@ -35459,7 +35459,7 @@ namespace Tensorflow.Operations /// trainable variables and optimizer state from TPU memory. This op enables /// functionality equivalent to AdagradOptimizer. /// - public static Operation t_p_u_embedding_load_adagrad_parameters (Tensor parameters, Tensor accumulators, string tpu_embedding_config, int table_id, int num_hosts, int host_id, string name = "TPUEmbeddingLoadAdagradParameters") + public static Operation t_p_u_embedding_load_adagrad_parameters(Tensor parameters, Tensor accumulators, string tpu_embedding_config, int table_id, int num_hosts, int host_id, string name = "TPUEmbeddingLoadAdagradParameters") { var dict = new Dictionary(); dict["parameters"] = parameters; @@ -35506,7 +35506,7 @@ namespace Tensorflow.Operations /// trainable variables and optimizer state from TPU memory. This op enables /// functionality equivalent to GradientDescentOptimizer. /// - public static Operation t_p_u_embedding_load_gradient_descent_parameters (Tensor parameters, string tpu_embedding_config, int table_id, int num_hosts, int host_id, string name = "TPUEmbeddingLoadGradientDescentParameters") + public static Operation t_p_u_embedding_load_gradient_descent_parameters(Tensor parameters, string tpu_embedding_config, int table_id, int num_hosts, int host_id, string name = "TPUEmbeddingLoadGradientDescentParameters") { var dict = new Dictionary(); dict["parameters"] = parameters; @@ -35546,7 +35546,7 @@ namespace Tensorflow.Operations /// Tensor of activations per table specified in the model. There can be at most /// one ReceieveActivations op in the TPU graph. /// - public static Tensor[] t_p_u_embedding_receive_activations (int num_tables, string tpu_embedding_config, string name = "TPUEmbeddingReceiveActivations") + public static Tensor[] t_p_u_embedding_receive_activations(int num_tables, string tpu_embedding_config, string name = "TPUEmbeddingReceiveActivations") { var dict = new Dictionary(); dict["num_tables"] = num_tables; @@ -35590,7 +35590,7 @@ namespace Tensorflow.Operations /// trainable variables and optimizer state from TPU memory. This op enables /// functionality equivalent to AdagradOptimizer. /// - public static (Tensor parameters, Tensor accumulators) t_p_u_embedding_retrieve_adagrad_parameters (string tpu_embedding_config, int table_id, int num_hosts, int host_id, string name = "TPUEmbeddingRetrieveAdagradParameters") + public static (Tensor parameters, Tensor accumulators) t_p_u_embedding_retrieve_adagrad_parameters(string tpu_embedding_config, int table_id, int num_hosts, int host_id, string name = "TPUEmbeddingRetrieveAdagradParameters") { var dict = new Dictionary(); dict["tpu_embedding_config"] = tpu_embedding_config; @@ -35634,7 +35634,7 @@ namespace Tensorflow.Operations /// trainable variables and optimizer state from TPU memory. This op enables /// functionality equivalent to GradientDescentOptimizer. /// - public static Tensor t_p_u_embedding_retrieve_gradient_descent_parameters (string tpu_embedding_config, int table_id, int num_hosts, int host_id, string name = "TPUEmbeddingRetrieveGradientDescentParameters") + public static Tensor t_p_u_embedding_retrieve_gradient_descent_parameters(string tpu_embedding_config, int table_id, int num_hosts, int host_id, string name = "TPUEmbeddingRetrieveGradientDescentParameters") { var dict = new Dictionary(); dict["tpu_embedding_config"] = tpu_embedding_config; @@ -35668,7 +35668,7 @@ namespace Tensorflow.Operations /// from these gradients via the optimizer specified in the configuration given /// to tpu.initialize_system. /// - public static Operation t_p_u_embedding_send_gradients (Tensor[] gradients, string tpu_embedding_config, string name = "TPUEmbeddingSendGradients") + public static Operation t_p_u_embedding_send_gradients(Tensor[] gradients, string tpu_embedding_config, string name = "TPUEmbeddingSendGradients") { var dict = new Dictionary(); dict["gradients"] = gradients; @@ -35688,7 +35688,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor t_p_u_replicated_input (Tensor[] inputs, string name = "TPUReplicatedInput") + public static Tensor t_p_u_replicated_input(Tensor[] inputs, string name = "TPUReplicatedInput") { var dict = new Dictionary(); dict["inputs"] = inputs; @@ -35710,7 +35710,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor[] t_p_u_replicated_output (Tensor input, int num_replicas, string name = "TPUReplicatedOutput") + public static Tensor[] t_p_u_replicated_output(Tensor input, int num_replicas, string name = "TPUReplicatedOutput") { var dict = new Dictionary(); dict["input"] = input; @@ -35743,7 +35743,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor take_dataset (Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "TakeDataset") + public static Tensor take_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "TakeDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -35834,7 +35834,7 @@ namespace Tensorflow.Operations /// shape = [2 50] /// /// - public static (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape) take_many_sparse_from_tensors_map (Tensor sparse_handles, TF_DataType dtype, string container = null, string shared_name = null, string name = "TakeManySparseFromTensorsMap") + public static (Tensor sparse_indices, Tensor sparse_values, Tensor sparse_shape) take_many_sparse_from_tensors_map(Tensor sparse_handles, TF_DataType dtype, string container = null, string shared_name = null, string name = "TakeManySparseFromTensorsMap") { var dict = new Dictionary(); dict["sparse_handles"] = sparse_handles; @@ -35862,7 +35862,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tan (Tensor x, string name = "Tan") + public static Tensor tan(Tensor x, string name = "Tan") { var dict = new Dictionary(); dict["x"] = x; @@ -35881,7 +35881,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tanh (Tensor x, string name = "Tanh") + public static Tensor tanh(Tensor x, string name = "Tanh") { var dict = new Dictionary(); dict["x"] = x; @@ -35906,7 +35906,7 @@ namespace Tensorflow.Operations /// Specifically, grad = dy * (1 - y*y), where y = tanh(x), and dy /// is the corresponding input gradient. /// - public static Tensor tanh_grad (Tensor y, Tensor dy, string name = "TanhGrad") + public static Tensor tanh_grad(Tensor y, Tensor dy, string name = "TanhGrad") { var dict = new Dictionary(); dict["y"] = y; @@ -35953,7 +35953,7 @@ namespace Tensorflow.Operations /// var = state_ops.assign_add(var, [[6.0, 7.0]]) /// final = state_ops._destroy_temporary_variable(var, var_name=var_name) /// - public static Tensor temporary_variable (TensorShape shape, TF_DataType dtype, string var_name = null, string name = "TemporaryVariable") + public static Tensor temporary_variable(TensorShape shape, TF_DataType dtype, string var_name = null, string name = "TemporaryVariable") { var dict = new Dictionary(); dict["shape"] = shape; @@ -35975,7 +35975,7 @@ namespace Tensorflow.Operations /// /// Returns the description of the operation /// - public static Operation tensor_array_close_v2 (Tensor handle, string name = "TensorArrayCloseV2") + public static Operation tensor_array_close_v2(Tensor handle, string name = "TensorArrayCloseV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -35999,7 +35999,7 @@ namespace Tensorflow.Operations /// This enables the user to close and release the resource in the middle /// of a step/run. /// - public static Operation tensor_array_close_v3 (Tensor handle, string name = "TensorArrayCloseV3") + public static Operation tensor_array_close_v3(Tensor handle, string name = "TensorArrayCloseV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36028,7 +36028,7 @@ namespace Tensorflow.Operations /// lengths : /// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. /// - public static (Tensor value, Tensor lengths) tensor_array_concat_v2 (Tensor handle, Tensor flow_in, TF_DataType dtype, TensorShape element_shape_except0 = null, string name = "TensorArrayConcatV2") + public static (Tensor value, Tensor lengths) tensor_array_concat_v2(Tensor handle, Tensor flow_in, TF_DataType dtype, TensorShape element_shape_except0 = null, string name = "TensorArrayConcatV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36089,7 +36089,7 @@ namespace Tensorflow.Operations /// /// All elements must have the same shape (excepting the first dimension). /// - public static (Tensor value, Tensor lengths) tensor_array_concat_v3 (Tensor handle, Tensor flow_in, TF_DataType dtype, TensorShape element_shape_except0 = null, string name = "TensorArrayConcatV3") + public static (Tensor value, Tensor lengths) tensor_array_concat_v3(Tensor handle, Tensor flow_in, TF_DataType dtype, TensorShape element_shape_except0 = null, string name = "TensorArrayConcatV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36124,7 +36124,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_gather_v2 (Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, TensorShape element_shape = null, string name = "TensorArrayGatherV2") + public static Tensor tensor_array_gather_v2(Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, TensorShape element_shape = null, string name = "TensorArrayGatherV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36169,7 +36169,7 @@ namespace Tensorflow.Operations /// /// All elements selected by indices must have the same shape. /// - public static Tensor tensor_array_gather_v3 (Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, TensorShape element_shape = null, string name = "TensorArrayGatherV3") + public static Tensor tensor_array_gather_v3(Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, TensorShape element_shape = null, string name = "TensorArrayGatherV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36198,7 +36198,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_grad_v2 (Tensor handle, Tensor flow_in, string source, string name = "TensorArrayGradV2") + public static Tensor tensor_array_grad_v2(Tensor handle, Tensor flow_in, string source, string name = "TensorArrayGradV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36269,7 +36269,7 @@ namespace Tensorflow.Operations /// name when performing the creation / lookup, so that each separate gradient /// calculation gets its own TensorArray accumulator. /// - public static (Tensor grad_handle, Tensor flow_out) tensor_array_grad_v3 (Tensor handle, Tensor flow_in, string source, string name = "TensorArrayGradV3") + public static (Tensor grad_handle, Tensor flow_out) tensor_array_grad_v3(Tensor handle, Tensor flow_in, string source, string name = "TensorArrayGradV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36316,7 +36316,7 @@ namespace Tensorflow.Operations /// computed. This enables multiple gradients for the same TensorArray to be /// calculated using the same accumulator. /// - public static (Tensor grad_handle, Tensor flow_out) tensor_array_grad_with_shape (Tensor handle, Tensor flow_in, Tensor shape_to_prepend, string source, string name = "TensorArrayGradWithShape") + public static (Tensor grad_handle, Tensor flow_out) tensor_array_grad_with_shape(Tensor handle, Tensor flow_in, Tensor shape_to_prepend, string source, string name = "TensorArrayGradWithShape") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36348,7 +36348,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_read_v2 (Tensor handle, Tensor index, Tensor flow_in, TF_DataType dtype, string name = "TensorArrayReadV2") + public static Tensor tensor_array_read_v2(Tensor handle, Tensor index, Tensor flow_in, TF_DataType dtype, string name = "TensorArrayReadV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36381,7 +36381,7 @@ namespace Tensorflow.Operations /// The tensor that is read from the TensorArray. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_read_v3 (Tensor handle, Tensor index, Tensor flow_in, TF_DataType dtype, string name = "TensorArrayReadV3") + public static Tensor tensor_array_read_v3(Tensor handle, Tensor index, Tensor flow_in, TF_DataType dtype, string name = "TensorArrayReadV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36409,7 +36409,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_scatter_v2 (Tensor handle, Tensor indices, Tensor value, Tensor flow_in, string name = "TensorArrayScatterV2") + public static Tensor tensor_array_scatter_v2(Tensor handle, Tensor indices, Tensor value, Tensor flow_in, string name = "TensorArrayScatterV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36445,7 +36445,7 @@ namespace Tensorflow.Operations /// /// indices must be a vector, its length must match the first dim of value. /// - public static Tensor tensor_array_scatter_v3 (Tensor handle, Tensor indices, Tensor value, Tensor flow_in, string name = "TensorArrayScatterV3") + public static Tensor tensor_array_scatter_v3(Tensor handle, Tensor indices, Tensor value, Tensor flow_in, string name = "TensorArrayScatterV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36469,7 +36469,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_size_v2 (Tensor handle, Tensor flow_in, string name = "TensorArraySizeV2") + public static Tensor tensor_array_size_v2(Tensor handle, Tensor flow_in, string name = "TensorArraySizeV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36494,7 +36494,7 @@ namespace Tensorflow.Operations /// The current size of the TensorArray. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_size_v3 (Tensor handle, Tensor flow_in, string name = "TensorArraySizeV3") + public static Tensor tensor_array_size_v3(Tensor handle, Tensor flow_in, string name = "TensorArraySizeV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36520,7 +36520,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_split_v2 (Tensor handle, Tensor value, Tensor lengths, Tensor flow_in, string name = "TensorArraySplitV2") + public static Tensor tensor_array_split_v2(Tensor handle, Tensor value, Tensor lengths, Tensor flow_in, string name = "TensorArraySplitV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36580,7 +36580,7 @@ namespace Tensorflow.Operations /// nt x d0 x d1 x ... /// /// - public static Tensor tensor_array_split_v3 (Tensor handle, Tensor value, Tensor lengths, Tensor flow_in, string name = "TensorArraySplitV3") + public static Tensor tensor_array_split_v3(Tensor handle, Tensor value, Tensor lengths, Tensor flow_in, string name = "TensorArraySplitV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36613,7 +36613,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_v2 (Tensor size, TF_DataType dtype, TensorShape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, string tensor_array_name = null, string name = "TensorArrayV2") + public static Tensor tensor_array_v2(Tensor size, TF_DataType dtype, TensorShape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, string tensor_array_name = null, string name = "TensorArrayV2") { var dict = new Dictionary(); dict["size"] = size; @@ -36679,7 +36679,7 @@ namespace Tensorflow.Operations /// /// Write data via Write and read via Read or Pack. /// - public static (Tensor handle, Tensor flow) tensor_array_v3 (Tensor size, TF_DataType dtype, TensorShape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, bool? identical_element_shapes = null, string tensor_array_name = null, string name = "TensorArrayV3") + public static (Tensor handle, Tensor flow) tensor_array_v3(Tensor size, TF_DataType dtype, TensorShape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, bool? identical_element_shapes = null, string tensor_array_name = null, string name = "TensorArrayV3") { var dict = new Dictionary(); dict["size"] = size; @@ -36718,7 +36718,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_write_v2 (Tensor handle, Tensor index, Tensor value, Tensor flow_in, string name = "TensorArrayWriteV2") + public static Tensor tensor_array_write_v2(Tensor handle, Tensor index, Tensor value, Tensor flow_in, string name = "TensorArrayWriteV2") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36751,7 +36751,7 @@ namespace Tensorflow.Operations /// A float scalar that enforces proper chaining of operations. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_array_write_v3 (Tensor handle, Tensor index, Tensor value, Tensor flow_in, string name = "TensorArrayWriteV3") + public static Tensor tensor_array_write_v3(Tensor handle, Tensor index, Tensor value, Tensor flow_in, string name = "TensorArrayWriteV3") { var dict = new Dictionary(); dict["handle"] = handle; @@ -36776,7 +36776,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_dataset (Tensor[] components, TensorShape[] output_shapes, string name = "TensorDataset") + public static Tensor tensor_dataset(Tensor[] components, TensorShape[] output_shapes, string name = "TensorDataset") { var dict = new Dictionary(); dict["components"] = components; @@ -36803,7 +36803,7 @@ namespace Tensorflow.Operations /// input_handle: the list /// element_shape: the shape of elements of the list /// - public static Tensor tensor_list_element_shape (Tensor input_handle, TF_DataType shape_type, string name = "TensorListElementShape") + public static Tensor tensor_list_element_shape(Tensor input_handle, TF_DataType shape_type, string name = "TensorListElementShape") { var dict = new Dictionary(); dict["input_handle"] = input_handle; @@ -36831,7 +36831,7 @@ namespace Tensorflow.Operations /// tensor: The input tensor. /// output_handle: The list. /// - public static Tensor tensor_list_from_tensor (Tensor tensor, Tensor element_shape, string name = "TensorListFromTensor") + public static Tensor tensor_list_from_tensor(Tensor tensor, Tensor element_shape, string name = "TensorListFromTensor") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -36864,7 +36864,7 @@ namespace Tensorflow.Operations /// indices: The indices used to index into the list. /// values: The tensor. /// - public static Tensor tensor_list_gather (Tensor input_handle, Tensor indices, TF_DataType element_dtype, string name = "TensorListGather") + public static Tensor tensor_list_gather(Tensor input_handle, Tensor indices, TF_DataType element_dtype, string name = "TensorListGather") { var dict = new Dictionary(); dict["input_handle"] = input_handle; @@ -36897,7 +36897,7 @@ namespace Tensorflow.Operations /// /// /// - public static Tensor tensor_list_get_item (Tensor input_handle, Tensor index, TF_DataType element_dtype, string name = "TensorListGetItem") + public static Tensor tensor_list_get_item(Tensor input_handle, Tensor index, TF_DataType element_dtype, string name = "TensorListGetItem") { var dict = new Dictionary(); dict["input_handle"] = input_handle; @@ -36922,7 +36922,7 @@ namespace Tensorflow.Operations /// input_handle: the input list /// length: the number of tensors in the list /// - public static Tensor tensor_list_length (Tensor input_handle, string name = "TensorListLength") + public static Tensor tensor_list_length(Tensor input_handle, string name = "TensorListLength") { var dict = new Dictionary(); dict["input_handle"] = input_handle; @@ -36955,7 +36955,7 @@ namespace Tensorflow.Operations /// element_dtype: the type of elements in the list /// element_shape: the shape of the output tensor /// - public static (Tensor output_handle, Tensor tensor) tensor_list_pop_back (Tensor input_handle, TF_DataType element_dtype, string name = "TensorListPopBack") + public static (Tensor output_handle, Tensor tensor) tensor_list_pop_back(Tensor input_handle, TF_DataType element_dtype, string name = "TensorListPopBack") { var dict = new Dictionary(); dict["input_handle"] = input_handle; @@ -36987,7 +36987,7 @@ namespace Tensorflow.Operations /// element_dtype: the type of elements in the list. /// element_shape: a shape compatible with that of elements in the list. /// - public static Tensor tensor_list_push_back (Tensor input_handle, Tensor tensor, string name = "TensorListPushBack") + public static Tensor tensor_list_push_back(Tensor input_handle, Tensor tensor, string name = "TensorListPushBack") { var dict = new Dictionary(); dict["input_handle"] = input_handle; @@ -37018,7 +37018,7 @@ namespace Tensorflow.Operations /// handle: the output list /// element_dtype: the desired type of elements in the list. /// - public static Tensor tensor_list_reserve (Tensor element_shape, Tensor num_elements, TF_DataType element_dtype, string name = "TensorListReserve") + public static Tensor tensor_list_reserve(Tensor element_shape, Tensor num_elements, TF_DataType element_dtype, string name = "TensorListReserve") { var dict = new Dictionary(); dict["element_shape"] = element_shape; @@ -37053,7 +37053,7 @@ namespace Tensorflow.Operations /// the shape of the tensor). /// output_handle: The TensorList. /// - public static Tensor tensor_list_scatter (Tensor tensor, Tensor indices, Tensor element_shape, string name = "TensorListScatter") + public static Tensor tensor_list_scatter(Tensor tensor, Tensor indices, Tensor element_shape, string name = "TensorListScatter") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -37085,7 +37085,7 @@ namespace Tensorflow.Operations /// output_handle: the new list, with the element in the proper position /// /// - public static Tensor tensor_list_set_item (Tensor input_handle, Tensor index, Tensor item, string name = "TensorListSetItem") + public static Tensor tensor_list_set_item(Tensor input_handle, Tensor index, Tensor item, string name = "TensorListSetItem") { var dict = new Dictionary(); dict["input_handle"] = input_handle; @@ -37119,7 +37119,7 @@ namespace Tensorflow.Operations /// num_elements: optional. If not -1, the number of elements in the list. /// /// - public static Tensor tensor_list_stack (Tensor input_handle, TF_DataType element_dtype, int? num_elements = null, string name = "TensorListStack") + public static Tensor tensor_list_stack(Tensor input_handle, TF_DataType element_dtype, int? num_elements = null, string name = "TensorListStack") { var dict = new Dictionary(); dict["input_handle"] = input_handle; @@ -37144,7 +37144,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_slice_dataset (Tensor[] components, TensorShape[] output_shapes, string name = "TensorSliceDataset") + public static Tensor tensor_slice_dataset(Tensor[] components, TensorShape[] output_shapes, string name = "TensorSliceDataset") { var dict = new Dictionary(); dict["components"] = components; @@ -37179,7 +37179,7 @@ namespace Tensorflow.Operations /// a tag as well as a serialized SummaryMetadata proto string that contains /// plugin-specific data. We will keep this op to maintain backwards compatibility. /// - public static Tensor tensor_summary (Tensor tensor, string description = null, string[] labels = null, string display_name = null, string name = "TensorSummary") + public static Tensor tensor_summary(Tensor tensor, string description = null, string[] labels = null, string display_name = null, string name = "TensorSummary") { var dict = new Dictionary(); dict["tensor"] = tensor; @@ -37212,7 +37212,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor tensor_summary_v2 (Tensor tag, Tensor tensor, Tensor serialized_summary_metadata, string name = "TensorSummaryV2") + public static Tensor tensor_summary_v2(Tensor tag, Tensor tensor, Tensor serialized_summary_metadata, string name = "TensorSummaryV2") { var dict = new Dictionary(); dict["tag"] = tag; @@ -37242,7 +37242,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor text_line_dataset (Tensor filenames, Tensor compression_type, Tensor buffer_size, string name = "TextLineDataset") + public static Tensor text_line_dataset(Tensor filenames, Tensor compression_type, Tensor buffer_size, string name = "TextLineDataset") { var dict = new Dictionary(); dict["filenames"] = filenames; @@ -37273,7 +37273,7 @@ namespace Tensorflow.Operations /// The handle to reference the Reader. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor text_line_reader (int? skip_header_lines = null, string container = null, string shared_name = null, string name = "TextLineReader") + public static Tensor text_line_reader(int? skip_header_lines = null, string container = null, string shared_name = null, string name = "TextLineReader") { var dict = new Dictionary(); if (skip_header_lines.HasValue) @@ -37307,7 +37307,7 @@ namespace Tensorflow.Operations /// The handle to reference the Reader. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor text_line_reader_v2 (int? skip_header_lines = null, string container = null, string shared_name = null, string name = "TextLineReaderV2") + public static Tensor text_line_reader_v2(int? skip_header_lines = null, string container = null, string shared_name = null, string name = "TextLineReaderV2") { var dict = new Dictionary(); if (skip_header_lines.HasValue) @@ -37380,7 +37380,7 @@ namespace Tensorflow.Operations /// the sampled candidates must be chosen independently of the context and of the /// true labels. /// - public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) thread_unsafe_unigram_candidate_sampler (Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, int? seed = null, int? seed2 = null, string name = "ThreadUnsafeUnigramCandidateSampler") + public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) thread_unsafe_unigram_candidate_sampler(Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, int? seed = null, int? seed2 = null, string name = "ThreadUnsafeUnigramCandidateSampler") { var dict = new Dictionary(); dict["true_classes"] = true_classes; @@ -37422,7 +37422,7 @@ namespace Tensorflow.Operations /// dimension. For example, tiling [a b c d] by [2] produces /// [a b c d a b c d]. /// - public static Tensor tile (Tensor input, Tensor multiples, string name = "Tile") + public static Tensor tile(Tensor input, Tensor multiples, string name = "Tile") { var dict = new Dictionary(); dict["input"] = input; @@ -37449,7 +37449,7 @@ namespace Tensorflow.Operations /// along each dimension, TileGrad takes in multiples and aggregates /// each repeated tile of input into output. /// - public static Tensor tile_grad (Tensor input, Tensor multiples, string name = "TileGrad") + public static Tensor tile_grad(Tensor input, Tensor multiples, string name = "TileGrad") { var dict = new Dictionary(); dict["input"] = input; @@ -37473,7 +37473,7 @@ namespace Tensorflow.Operations /// Note: the timestamp is computed when the op is executed, not when it is added /// to the graph. /// - public static Tensor timestamp (string name = "Timestamp") + public static Tensor timestamp(string name = "Timestamp") { var dict = new Dictionary(); var op = tf.OpDefLib._apply_op_helper("Timestamp", name: name, keywords: dict); @@ -37518,7 +37518,7 @@ namespace Tensorflow.Operations /// /// If k varies dynamically, use TopKV2 below. /// - public static (Tensor values, Tensor indices) top_k (Tensor input, int k, bool? sorted = null, string name = "TopK") + public static (Tensor values, Tensor indices) top_k(Tensor input, int k, bool? sorted = null, string name = "TopK") { var dict = new Dictionary(); dict["input"] = input; @@ -37567,7 +37567,7 @@ namespace Tensorflow.Operations /// /// If two elements are equal, the lower-index element appears first. /// - public static (Tensor values, Tensor indices) top_k_v2 (Tensor input, Tensor k, bool? sorted = null, string name = "TopKV2") + public static (Tensor values, Tensor indices) top_k_v2(Tensor input, Tensor k, bool? sorted = null, string name = "TopKV2") { var dict = new Dictionary(); dict["input"] = input; @@ -37598,7 +37598,7 @@ namespace Tensorflow.Operations /// The output y has the same rank as x. The shapes of x and y satisfy: /// y.shape[i] == x.shape[perm[i]] for i in [0, 1, ..., rank(x) - 1] /// - public static Tensor transpose (Tensor x, Tensor perm, string name = "Transpose") + public static Tensor transpose(Tensor x, Tensor perm, string name = "Transpose") { var dict = new Dictionary(); dict["x"] = x; @@ -37629,7 +37629,7 @@ namespace Tensorflow.Operations /// *NOTE*: TruncateDiv supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor truncate_div (Tensor x, Tensor y, string name = "TruncateDiv") + public static Tensor truncate_div(Tensor x, Tensor y, string name = "TruncateDiv") { var dict = new Dictionary(); dict["x"] = x; @@ -37658,7 +37658,7 @@ namespace Tensorflow.Operations /// *NOTE*: TruncateMod supports broadcasting. More about broadcasting /// [here](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) /// - public static Tensor truncate_mod (Tensor x, Tensor y, string name = "TruncateMod") + public static Tensor truncate_mod(Tensor x, Tensor y, string name = "TruncateMod") { var dict = new Dictionary(); dict["x"] = x; @@ -37698,7 +37698,7 @@ namespace Tensorflow.Operations /// deviation 1, except that values whose magnitude is more than 2 standard /// deviations from the mean are dropped and re-picked. /// - public static Tensor truncated_normal (Tensor shape, TF_DataType dtype, int? seed = null, int? seed2 = null, string name = "TruncatedNormal") + public static Tensor truncated_normal(Tensor shape, TF_DataType dtype, int? seed = null, int? seed2 = null, string name = "TruncatedNormal") { var dict = new Dictionary(); dict["shape"] = shape; @@ -37805,7 +37805,7 @@ namespace Tensorflow.Operations /// will contain valid response values for those minibatch entries whose RPCs did /// not fail; the rest of the entries will have empty strings. /// - public static (Tensor response, Tensor status_code, Tensor status_message) try_rpc (Tensor address, Tensor method, Tensor request, string protocol = null, bool? fail_fast = null, int? timeout_in_ms = null, string name = "TryRpc") + public static (Tensor response, Tensor status_code, Tensor status_message) try_rpc(Tensor address, Tensor method, Tensor request, string protocol = null, bool? fail_fast = null, int? timeout_in_ms = null, string name = "TryRpc") { var dict = new Dictionary(); dict["address"] = address; @@ -37867,7 +37867,7 @@ namespace Tensorflow.Operations /// assumed to possibly belong to the same batch. If left empty, the op name will /// be used as the shared name. /// - public static Tensor unbatch (Tensor batched_tensor, Tensor batch_index, Tensor id, int timeout_micros, string container = null, string shared_name = null, string name = "Unbatch") + public static Tensor unbatch(Tensor batched_tensor, Tensor batch_index, Tensor id, int timeout_micros, string container = null, string shared_name = null, string name = "Unbatch") { var dict = new Dictionary(); dict["batched_tensor"] = batched_tensor; @@ -37899,7 +37899,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor unbatch_dataset (Tensor input_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "UnbatchDataset") + public static Tensor unbatch_dataset(Tensor input_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "UnbatchDataset") { var dict = new Dictionary(); dict["input_dataset"] = input_dataset; @@ -37946,7 +37946,7 @@ namespace Tensorflow.Operations /// are assumed to possibly belong to the same batch. If left empty, the op name /// will be used as the shared name. /// - public static Tensor unbatch_grad (Tensor original_input, Tensor batch_index, Tensor grad, Tensor id, string container = null, string shared_name = null, string name = "UnbatchGrad") + public static Tensor unbatch_grad(Tensor original_input, Tensor batch_index, Tensor grad, Tensor id, string container = null, string shared_name = null, string name = "UnbatchGrad") { var dict = new Dictionary(); dict["original_input"] = original_input; @@ -38021,7 +38021,7 @@ namespace Tensorflow.Operations /// the sampled candidates must be chosen independently of the context and of the /// true labels. /// - public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) uniform_candidate_sampler (Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, int? seed = null, int? seed2 = null, string name = "UniformCandidateSampler") + public static (Tensor sampled_candidates, Tensor true_expected_count, Tensor sampled_expected_count) uniform_candidate_sampler(Tensor true_classes, int num_true, int num_sampled, bool unique, int range_max, int? seed = null, int? seed2 = null, string name = "UniformCandidateSampler") { var dict = new Dictionary(); dict["true_classes"] = true_classes; @@ -38075,7 +38075,7 @@ namespace Tensorflow.Operations /// idx ==&gt; [0, 0, 1, 2, 2, 2, 3, 4, 4] /// /// - public static (Tensor y, Tensor idx) unique (Tensor x, TF_DataType? out_idx = null, string name = "Unique") + public static (Tensor y, Tensor idx) unique(Tensor x, TF_DataType? out_idx = null, string name = "Unique") { var dict = new Dictionary(); dict["x"] = x; @@ -38155,7 +38155,7 @@ namespace Tensorflow.Operations /// idx ==&gt; [0, 1, 1] /// /// - public static (Tensor y, Tensor idx) unique_v2 (Tensor x, Tensor axis, TF_DataType? out_idx = null, string name = "UniqueV2") + public static (Tensor y, Tensor idx) unique_v2(Tensor x, Tensor axis, TF_DataType? out_idx = null, string name = "UniqueV2") { var dict = new Dictionary(); dict["x"] = x; @@ -38206,7 +38206,7 @@ namespace Tensorflow.Operations /// count ==&gt; [2, 1, 3, 1, 2] /// /// - public static (Tensor y, Tensor idx, Tensor count) unique_with_counts (Tensor x, TF_DataType? out_idx = null, string name = "UniqueWithCounts") + public static (Tensor y, Tensor idx, Tensor count) unique_with_counts(Tensor x, TF_DataType? out_idx = null, string name = "UniqueWithCounts") { var dict = new Dictionary(); dict["x"] = x; @@ -38292,7 +38292,7 @@ namespace Tensorflow.Operations /// count ==&gt; [1, 2] /// /// - public static (Tensor y, Tensor idx, Tensor count) unique_with_counts_v2 (Tensor x, Tensor axis, TF_DataType? out_idx = null, string name = "UniqueWithCountsV2") + public static (Tensor y, Tensor idx, Tensor count) unique_with_counts_v2(Tensor x, Tensor axis, TF_DataType? out_idx = null, string name = "UniqueWithCountsV2") { var dict = new Dictionary(); dict["x"] = x; @@ -38341,7 +38341,7 @@ namespace Tensorflow.Operations /// /// This is the opposite of pack. /// - public static Tensor[] unpack (Tensor value, int num, int? axis = null, string name = "Unpack") + public static Tensor[] unpack(Tensor value, int num, int? axis = null, string name = "Unpack") { var dict = new Dictionary(); dict["value"] = value; @@ -38380,7 +38380,7 @@ namespace Tensorflow.Operations /// Equivalent to np.unravel_index /// @end_compatibility /// - public static Tensor unravel_index (Tensor indices, Tensor dims, string name = "UnravelIndex") + public static Tensor unravel_index(Tensor indices, Tensor dims, string name = "UnravelIndex") { var dict = new Dictionary(); dict["indices"] = indices; @@ -38435,7 +38435,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/UnsortedSegmentMax.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor unsorted_segment_max (Tensor data, Tensor segment_ids, Tensor num_segments, string name = "UnsortedSegmentMax") + public static Tensor unsorted_segment_max(Tensor data, Tensor segment_ids, Tensor num_segments, string name = "UnsortedSegmentMax") { var dict = new Dictionary(); dict["data"] = data; @@ -38483,7 +38483,7 @@ namespace Tensorflow.Operations /// If the given segment ID i is negative, then the corresponding value is /// dropped, and will not be included in the result. /// - public static Tensor unsorted_segment_min (Tensor data, Tensor segment_ids, Tensor num_segments, string name = "UnsortedSegmentMin") + public static Tensor unsorted_segment_min(Tensor data, Tensor segment_ids, Tensor num_segments, string name = "UnsortedSegmentMin") { var dict = new Dictionary(); dict["data"] = data; @@ -38530,7 +38530,7 @@ namespace Tensorflow.Operations /// If the given segment ID i is negative, then the corresponding value is /// dropped, and will not be included in the result. /// - public static Tensor unsorted_segment_prod (Tensor data, Tensor segment_ids, Tensor num_segments, string name = "UnsortedSegmentProd") + public static Tensor unsorted_segment_prod(Tensor data, Tensor segment_ids, Tensor num_segments, string name = "UnsortedSegmentProd") { var dict = new Dictionary(); dict["data"] = data; @@ -38580,7 +38580,7 @@ namespace Tensorflow.Operations /// &lt;img style="width:100%" src="https://www.tensorflow.org/images/UnsortedSegmentSum.png" alt&gt; /// &lt;/div&gt; /// - public static Tensor unsorted_segment_sum (Tensor data, Tensor segment_ids, Tensor num_segments, string name = "UnsortedSegmentSum") + public static Tensor unsorted_segment_sum(Tensor data, Tensor segment_ids, Tensor num_segments, string name = "UnsortedSegmentSum") { var dict = new Dictionary(); dict["data"] = data; @@ -38614,7 +38614,7 @@ namespace Tensorflow.Operations /// The basic functionality is similar to dequeue with many fewer /// capabilities and options. This Op is optimized for performance. /// - public static Tensor[] unstage (TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "Unstage") + public static Tensor[] unstage(TF_DataType[] dtypes, int? capacity = null, int? memory_limit = null, string container = null, string shared_name = null, string name = "Unstage") { var dict = new Dictionary(); dict["dtypes"] = dtypes; @@ -38656,7 +38656,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor var_handle_op (TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "VarHandleOp") + public static Tensor var_handle_op(TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "VarHandleOp") { var dict = new Dictionary(); dict["dtype"] = dtype; @@ -38683,7 +38683,7 @@ namespace Tensorflow.Operations /// initialized. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor var_is_initialized_op (Tensor resource, string name = "VarIsInitializedOp") + public static Tensor var_is_initialized_op(Tensor resource, string name = "VarIsInitializedOp") { var dict = new Dictionary(); dict["resource"] = resource; @@ -38710,7 +38710,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor variable (TensorShape shape, TF_DataType dtype, string container = null, string shared_name = null, string name = "Variable") + public static Tensor variable(TensorShape shape, TF_DataType dtype, string container = null, string shared_name = null, string name = "Variable") { var dict = new Dictionary(); dict["shape"] = shape; @@ -38746,7 +38746,7 @@ namespace Tensorflow.Operations /// shape(t) ==&gt; [2, 2, 3] /// /// - public static Tensor variable_shape (Tensor input, TF_DataType? out_type = null, string name = "VariableShape") + public static Tensor variable_shape(Tensor input, TF_DataType? out_type = null, string name = "VariableShape") { var dict = new Dictionary(); dict["input"] = input; @@ -38787,7 +38787,7 @@ namespace Tensorflow.Operations /// TODO(zhifengc/mrry): Adds a pointer to a more detail document /// about sharing states in tensorflow. /// - public static Tensor variable_v2 (TensorShape shape, TF_DataType dtype, string container = null, string shared_name = null, string name = "VariableV2") + public static Tensor variable_v2(TensorShape shape, TF_DataType dtype, string container = null, string shared_name = null, string name = "VariableV2") { var dict = new Dictionary(); dict["shape"] = shape; @@ -38872,7 +38872,7 @@ namespace Tensorflow.Operations /// [2, 1, 1]] /// /// - public static Tensor where (Tensor input, string name = "Where") + public static Tensor where(Tensor input, string name = "Where") { var dict = new Dictionary(); dict["input"] = input; @@ -38902,7 +38902,7 @@ namespace Tensorflow.Operations /// To use, enqueue filenames in a Queue. The output of ReaderRead will /// be a filename (key) and the contents of that file (value). /// - public static Tensor whole_file_reader (string container = null, string shared_name = null, string name = "WholeFileReader") + public static Tensor whole_file_reader(string container = null, string shared_name = null, string name = "WholeFileReader") { var dict = new Dictionary(); if (container != null) @@ -38935,7 +38935,7 @@ namespace Tensorflow.Operations /// To use, enqueue filenames in a Queue. The output of ReaderRead will /// be a filename (key) and the contents of that file (value). /// - public static Tensor whole_file_reader_v2 (string container = null, string shared_name = null, string name = "WholeFileReaderV2") + public static Tensor whole_file_reader_v2(string container = null, string shared_name = null, string name = "WholeFileReaderV2") { var dict = new Dictionary(); if (container != null) @@ -38963,7 +38963,7 @@ namespace Tensorflow.Operations /// Heartbeats may be sent periodically to indicate the coordinator is still active, /// to retrieve the current worker status and to expedite shutdown when necessary. /// - public static Tensor worker_heartbeat (Tensor request, string name = "WorkerHeartbeat") + public static Tensor worker_heartbeat(Tensor request, string name = "WorkerHeartbeat") { var dict = new Dictionary(); dict["request"] = request; @@ -38989,7 +38989,7 @@ namespace Tensorflow.Operations /// /// creates directory if not existing. /// - public static Operation write_file (Tensor filename, Tensor contents, string name = "WriteFile") + public static Operation write_file(Tensor filename, Tensor contents, string name = "WriteFile") { var dict = new Dictionary(); dict["filename"] = filename; @@ -39011,7 +39011,7 @@ namespace Tensorflow.Operations /// a tensor of the same shape and type as x but filled with zeros. /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor zeros_like (Tensor x, string name = "ZerosLike") + public static Tensor zeros_like(Tensor x, string name = "ZerosLike") { var dict = new Dictionary(); dict["x"] = x; @@ -39038,7 +39038,7 @@ namespace Tensorflow.Operations /// /// \\(\zeta(x, q) = \sum_{n=0}^{\infty} (q + n)^{-x}\\) /// - public static Tensor zeta (Tensor x, Tensor q, string name = "Zeta") + public static Tensor zeta(Tensor x, Tensor q, string name = "Zeta") { var dict = new Dictionary(); dict["x"] = x; @@ -39064,7 +39064,7 @@ namespace Tensorflow.Operations /// /// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. /// - public static Tensor zip_dataset (Tensor[] input_datasets, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ZipDataset") + public static Tensor zip_dataset(Tensor[] input_datasets, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ZipDataset") { var dict = new Dictionary(); dict["input_datasets"] = input_datasets; diff --git a/src/TensorFlowNET.Core/Operations/gen_random_ops.cs b/src/TensorFlowNET.Core/Operations/gen_random_ops.cs index a56a4cdc..dda9dfa0 100644 --- a/src/TensorFlowNET.Core/Operations/gen_random_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_random_ops.cs @@ -13,9 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ******************************************************************************/ -using System; -using System.Linq; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow @@ -51,7 +48,7 @@ namespace Tensorflow if (!seed2.HasValue) seed2 = 0; - var _op = tf.OpDefLib._apply_op_helper("RandomStandardNormal", + var _op = tf.OpDefLib._apply_op_helper("RandomStandardNormal", name: name, args: new { shape, dtype, seed, seed2 }); @@ -113,7 +110,7 @@ namespace Tensorflow var _op = tf.OpDefLib._apply_op_helper("RandomUniform", name: name, - args: new { shape, dtype, seed, seed2}); + args: new { shape, dtype, seed, seed2 }); return _op.outputs[0]; } @@ -126,7 +123,7 @@ namespace Tensorflow /// /// /// - public static Tensor random_shuffle(Tensor value, int seed = 0, int seed2 = 0, + public static Tensor random_shuffle(Tensor value, int seed = 0, int seed2 = 0, string name = null) { var _op = tf.OpDefLib._apply_op_helper("RandomShuffle", @@ -145,7 +142,7 @@ namespace Tensorflow /// /// /// - public static Tensor truncated_normal(Tensor shape, TF_DataType dtype, int? seed = 0, + public static Tensor truncated_normal(Tensor shape, TF_DataType dtype, int? seed = 0, int? seed2 = 0, string name = null) { if (!seed.HasValue) @@ -162,7 +159,7 @@ namespace Tensorflow "seed", seed, "seed2", seed2, "dtype", dtype); - + return results[0]; } @@ -173,7 +170,7 @@ namespace Tensorflow return _op.output; } - public static Tensor multinomial(Tensor logits, int num_samples, int? seed = 0, + public static Tensor multinomial(Tensor logits, int num_samples, int? seed = 0, int? seed2 = 0, TF_DataType output_dtype = TF_DataType.TF_INT64, string name = null) { if (!seed.HasValue) diff --git a/src/TensorFlowNET.Core/Operations/gen_resource_variable_ops.cs b/src/TensorFlowNET.Core/Operations/gen_resource_variable_ops.cs index 8d6a5cfa..34717a21 100644 --- a/src/TensorFlowNET.Core/Operations/gen_resource_variable_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_resource_variable_ops.cs @@ -14,9 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Linq; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow @@ -84,7 +81,7 @@ namespace Tensorflow if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "VarIsInitializedOp", name, + "VarIsInitializedOp", name, null, resource); @@ -105,14 +102,14 @@ namespace Tensorflow /// /// /// - public static Tensor var_handle_op(TF_DataType dtype, TensorShape shape, - string container ="", string shared_name = "", string name = null) + public static Tensor var_handle_op(TF_DataType dtype, TensorShape shape, + string container = "", string shared_name = "", string name = null) { - if(tf.Context.executing_eagerly()) + if (tf.Context.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "VarHandleOp", name, - null, + "VarHandleOp", name, + null, "container", container, "shared_name", shared_name, "dtype", dtype, @@ -121,7 +118,8 @@ namespace Tensorflow return results[0]; } - var _op = tf.OpDefLib._apply_op_helper("VarHandleOp", name, new { + var _op = tf.OpDefLib._apply_op_helper("VarHandleOp", name, new + { dtype, shape, container, @@ -143,7 +141,7 @@ namespace Tensorflow if (tf.executing_eagerly()) { var results = tf.Runner.TFE_FastPathExecute(tf.Context, tf.Context.DeviceName, - "ReadVariableOp", name, + "ReadVariableOp", name, null, resource, "dtype", dtype); @@ -160,7 +158,7 @@ namespace Tensorflow return _op.output; } - public static Tensor resource_gather(Tensor resource, Tensor indices, TF_DataType dtype, + public static Tensor resource_gather(Tensor resource, Tensor indices, TF_DataType dtype, int batch_dims = 0, bool validate_indices = true, string name = null) { var _op = tf.OpDefLib._apply_op_helper("ResourceGather", name, new diff --git a/src/TensorFlowNET.Core/Operations/gen_sparse_ops.cs b/src/TensorFlowNET.Core/Operations/gen_sparse_ops.cs index 44639005..73829b29 100644 --- a/src/TensorFlowNET.Core/Operations/gen_sparse_ops.cs +++ b/src/TensorFlowNET.Core/Operations/gen_sparse_ops.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System.Collections.Generic; using static Tensorflow.Binding; namespace Tensorflow @@ -31,8 +30,8 @@ namespace Tensorflow /// /// /// - public static Tensor sparse_to_dense(Tensor sparse_indices, - int[] output_shape, + public static Tensor sparse_to_dense(Tensor sparse_indices, + int[] output_shape, T sparse_values, T default_value, bool validate_indices = true, diff --git a/src/TensorFlowNET.Core/Operations/image_ops_impl.cs b/src/TensorFlowNET.Core/Operations/image_ops_impl.cs index e4ca8ec4..39a4575a 100644 --- a/src/TensorFlowNET.Core/Operations/image_ops_impl.cs +++ b/src/TensorFlowNET.Core/Operations/image_ops_impl.cs @@ -15,9 +15,7 @@ ******************************************************************************/ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using Tensorflow.Framework; using Tensorflow.Operations; using static Tensorflow.Binding; @@ -29,17 +27,18 @@ namespace Tensorflow internal static Operation _assert(Tensor cond, Type ex_type, string msg) { if (_is_tensor(cond)) - return control_flow_ops.Assert(cond, new object[] {msg}); + return control_flow_ops.Assert(cond, new object[] { msg }); else if (cond != null) - { - Exception ex_type2 = (Exception)Activator.CreateInstance(ex_type, msg, ex_type); - throw ex_type2; - } else - { - Operation x = null; - return x; - } + { + Exception ex_type2 = (Exception)Activator.CreateInstance(ex_type, msg, ex_type); + throw ex_type2; + } + else + { + Operation x = null; + return x; + } } internal static bool _is_tensor(object x) @@ -61,12 +60,15 @@ namespace Tensorflow var static_shape = image.TensorShape.with_rank(rank).as_list(); var dynamic_shape = array_ops.unstack(array_ops.shape(image), rank); - int[] ss_storage = null; + int[] ss_storage = null; int[] ds_storage = null; // var sd = static_shape.Zip(dynamic_shape, (first, second) => storage[storage.Length] = first; - var sd = static_shape.Zip(dynamic_shape, (ss, ds) => {ss_storage[ss_storage.Length] = ss; - ds_storage[ds_storage.Length] = (int)ds; - return true;}); + var sd = static_shape.Zip(dynamic_shape, (ss, ds) => + { + ss_storage[ss_storage.Length] = ss; + ds_storage[ds_storage.Length] = (int)ds; + return true; + }); if (ss_storage != null) return ss_storage; @@ -86,7 +88,8 @@ namespace Tensorflow if (image.TensorShape.ndim == Unknown) { image_shape = image.TensorShape.with_rank(3); - } else + } + else { image_shape = image.TensorShape.with_rank_at_least(3); } @@ -95,11 +98,11 @@ namespace Tensorflow { throw new ValueError("'image' must be at least three-dimensional."); } - if (require_static &! image_shape.is_fully_defined()) + if (require_static & !image_shape.is_fully_defined()) { throw new ValueError("\'image\' must be fully defined."); } - for (int x = 1; x < 4; x++) + for (int x = 1; x < 4; x++) { if (image_shape.dims[x] == 0) { @@ -130,9 +133,10 @@ namespace Tensorflow message: "'image' must be at least three-dimensional." ) }; - } else + } + else { - return new Operation[] {}; + return new Operation[] { }; } } @@ -142,8 +146,9 @@ namespace Tensorflow if (image_shape == image_shape.unknown_shape()) { // c# defaults null types to 0 anyhow, so this should be a pretty equivalent port - result.set_shape(new TensorShape(new int[] {0, 0, 0})); - } else + result.set_shape(new TensorShape(new int[] { 0, 0, 0 })); + } + else { result.set_shape(image_shape); } @@ -160,44 +165,46 @@ namespace Tensorflow => _random_flip(image: image, flip_index: 1, seed: seed, - scope_name: "random_flip_left_right"); + scope_name: "random_flip_left_right"); internal static Tensor _random_flip(Tensor image, int flip_index, int seed, string scope_name) { - return tf_with(ops.name_scope(null, scope_name, new [] {image}), scope => - { - image = ops.convert_to_tensor(image, name: "image"); - image = _AssertAtLeast3DImage(image); - TensorShape shape = image.shape; - if (shape.ndim == 3 || shape.ndim == Unknown) - { - Tensor uniform_random = random_ops.random_uniform(new int[] {}, 0f, 1.0f, seed: seed); - var mirror_cond = gen_math_ops.less(uniform_random, .5); - - var result = control_flow_ops.cond( - pred: mirror_cond, - true_fn: () => gen_array_ops.reverse(image, new {flip_index}), - false_fn: () => image, - name: scope - ); - return fix_image_flip_shape(image, result); - } else if (shape.ndim == 4) - { - var batch_size = array_ops.shape(image); - var uniform_random = random_ops.random_uniform(batch_size.shape, - 0f, - 1.0f, - seed: seed); - var flips = math_ops.round( - array_ops.reshape(uniform_random, shape: array_ops.constant(value: new object[] {batch_size[0], 1, 1, 1}))); - flips = math_ops.cast(flips, image.dtype); - var flipped_input = gen_array_ops.reverse(image, new int[] {flip_index + 1}); - return flips * flipped_input + (1 - flips) * image; - } else - { - throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", shape)); - } - }); + return tf_with(ops.name_scope(null, scope_name, new[] { image }), scope => + { + image = ops.convert_to_tensor(image, name: "image"); + image = _AssertAtLeast3DImage(image); + TensorShape shape = image.shape; + if (shape.ndim == 3 || shape.ndim == Unknown) + { + Tensor uniform_random = random_ops.random_uniform(new int[] { }, 0f, 1.0f, seed: seed); + var mirror_cond = gen_math_ops.less(uniform_random, .5); + + var result = control_flow_ops.cond( + pred: mirror_cond, + true_fn: () => gen_array_ops.reverse(image, new { flip_index }), + false_fn: () => image, + name: scope + ); + return fix_image_flip_shape(image, result); + } + else if (shape.ndim == 4) + { + var batch_size = array_ops.shape(image); + var uniform_random = random_ops.random_uniform(batch_size.shape, + 0f, + 1.0f, + seed: seed); + var flips = math_ops.round( + array_ops.reshape(uniform_random, shape: array_ops.constant(value: new object[] { batch_size[0], 1, 1, 1 }))); + flips = math_ops.cast(flips, image.dtype); + var flipped_input = gen_array_ops.reverse(image, new int[] { flip_index + 1 }); + return flips * flipped_input + (1 - flips) * image; + } + else + { + throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", shape)); + } + }); } public static Tensor flip_left_right(Tensor image) @@ -208,113 +215,124 @@ namespace Tensorflow internal static Tensor _flip(Tensor image, int flip_index, string scope_name) { - return tf_with(ops.name_scope(null, scope_name, new {image}), delegate - { - image = ops.convert_to_tensor(image, name: "image"); - image = _AssertAtLeast3DImage(image); - TensorShape shape = image.shape; - if (shape.ndim == 3 || shape.ndim == Unknown) - { - return fix_image_flip_shape(image, gen_array_ops.reverse(image, new {flip_index})); - } else if (shape.ndim == 4) - { - return gen_array_ops.reverse(image, new [] {flip_index + 1}); - } else - { - throw new ValueError("\'image\' must have either 3 or 4 dimensions."); - } - }); + return tf_with(ops.name_scope(null, scope_name, new { image }), delegate + { + image = ops.convert_to_tensor(image, name: "image"); + image = _AssertAtLeast3DImage(image); + TensorShape shape = image.shape; + if (shape.ndim == 3 || shape.ndim == Unknown) + { + return fix_image_flip_shape(image, gen_array_ops.reverse(image, new { flip_index })); + } + else if (shape.ndim == 4) + { + return gen_array_ops.reverse(image, new[] { flip_index + 1 }); + } + else + { + throw new ValueError("\'image\' must have either 3 or 4 dimensions."); + } + }); } public static Tensor rot90(Tensor image, int k = 1, string name = null) { - return tf_with(ops.name_scope(name, "rot90", new [] {image, tf.constant(k)}), scope => - { - image = ops.convert_to_tensor(image, name: "image"); - image = _AssertAtLeast3DImage(image); - + return tf_with(ops.name_scope(name, "rot90", new[] { image, tf.constant(k) }), scope => + { + image = ops.convert_to_tensor(image, name: "image"); + image = _AssertAtLeast3DImage(image); + // can't get k to convert to tensor without throwing error about it being an int--- // might rework later. for now, k2 == k as Tensor Tensor k2 = ops.convert_to_tensor(k, dtype: dtypes.int32, name: "k"); - k2.TensorShape.assert_has_rank(0); - k2 = gen_ops.mod(k2, tf.constant(4)); - - TensorShape shape = image.shape; - if (shape.ndim == 3 || shape.ndim == Unknown) - { - return _rot90_3D(image, k, scope); - } else if (shape.ndim == 4) - { - return _rot90_3D(image, k, scope); - } else - { - throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", shape)); - } - }); + k2.TensorShape.assert_has_rank(0); + k2 = gen_ops.mod(k2, tf.constant(4)); + + TensorShape shape = image.shape; + if (shape.ndim == 3 || shape.ndim == Unknown) + { + return _rot90_3D(image, k, scope); + } + else if (shape.ndim == 4) + { + return _rot90_3D(image, k, scope); + } + else + { + throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", shape)); + } + }); } internal static Tensor _rot90_3D(Tensor image, int k, string name_scope) { - Tensor _rot90() { - return array_ops.transpose(gen_array_ops.reverse(image, new [] {1, 0, 2}), new int[] {1}); + Tensor _rot90() + { + return array_ops.transpose(gen_array_ops.reverse(image, new[] { 1, 0, 2 }), new int[] { 1 }); }; - Tensor _rot180() { - return gen_array_ops.reverse(image, new [] {0, 1}); + Tensor _rot180() + { + return gen_array_ops.reverse(image, new[] { 0, 1 }); }; - Tensor _rot270() { - return gen_array_ops.reverse(array_ops.transpose(image, new [] {1, 0, 2}), new [] {1}); + Tensor _rot270() + { + return gen_array_ops.reverse(array_ops.transpose(image, new[] { 1, 0, 2 }), new[] { 1 }); }; - var cases = new [] {math_ops.equal(k, 1), _rot90(), + var cases = new[] {math_ops.equal(k, 1), _rot90(), math_ops.equal(k, 2), _rot180(), math_ops.equal(k, 3), _rot270()}; - - var result = control_flow_ops.case_v2(cases, callable_default: () => new Tensor[] {image}, exclusive: true, name: name_scope); - result.set_shape(new [] {-1, -1, image.TensorShape.dims[2]}); + + var result = control_flow_ops.case_v2(cases, callable_default: () => new Tensor[] { image }, exclusive: true, name: name_scope); + result.set_shape(new[] { -1, -1, image.TensorShape.dims[2] }); return result; } public static Tensor transpose(Tensor image, string name = null) { - using (ops.name_scope(name, "transpose", new [] {image})) - return tf_with(ops.name_scope(name, "transpose", new [] {image}), delegate - { - image = ops.convert_to_tensor(image, name: "image"); - image = _AssertAtLeast3DImage(image); - TensorShape shape = image.shape; - if (shape.ndim == 3 || shape.ndim == Unknown) - { - return array_ops.transpose(image, new [] {1, 0, 2}, name: name); - } else if (shape.ndim == 4) - { - return array_ops.transpose(image, new [] {0, 2, 1, 3}, name: name); - } else { - throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.")); - } - }); + using (ops.name_scope(name, "transpose", new[] { image })) + return tf_with(ops.name_scope(name, "transpose", new[] { image }), delegate + { + image = ops.convert_to_tensor(image, name: "image"); + image = _AssertAtLeast3DImage(image); + TensorShape shape = image.shape; + if (shape.ndim == 3 || shape.ndim == Unknown) + { + return array_ops.transpose(image, new[] { 1, 0, 2 }, name: name); + } + else if (shape.ndim == 4) + { + return array_ops.transpose(image, new[] { 0, 2, 1, 3 }, name: name); + } + else + { + throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.")); + } + }); } public static Tensor central_crop(Tensor image, float central_fraction) { - using (ops.name_scope(null, "central_crop", new [] {image})) + using (ops.name_scope(null, "central_crop", new[] { image })) { image = ops.convert_to_tensor(image, name: "image"); if (central_fraction <= 0.0 || central_fraction > 1.0) throw new ValueError("central_fraction must be within (0, 1]"); if (central_fraction == 1.0) return image; - + _AssertAtLeast3DImage(image); var rank = image.TensorShape.ndim; if (rank != 3 && rank != 4) throw new ValueError(String.Format(@"`image` should either be a Tensor with rank = 3 or rank = 4. Had rank = {0}", rank)); - object[] _get_dim(Tensor tensor, int idx) { + object[] _get_dim(Tensor tensor, int idx) + { var static_shape = tensor.TensorShape.dims[idx]; if (static_shape != (int)None) - return new object[2] {static_shape, false}; - return new object[2] {array_ops.shape(tensor)[idx], true}; + return new object[2] { static_shape, false }; + return new object[2] { array_ops.shape(tensor)[idx], true }; }; object[] h, w; @@ -324,12 +342,13 @@ or rank = 4. Had rank = {0}", rank)); h = _get_dim(image, 0); // img_h == h[0], dynamic_h == h[1] w = _get_dim(image, 1); d = image.shape[3]; - } else + } + else { bs = image.shape[0]; h = _get_dim(image, 1); w = _get_dim(image, 2); - d = image.shape[3]; + d = image.shape[3]; } object hd, bbox_h_start; @@ -337,7 +356,8 @@ or rank = 4. Had rank = {0}", rank)); { hd = math_ops.cast((IVariableV1)h[0], dtypes.float64); bbox_h_start = math_ops.cast(((int)hd - (int)hd * central_fraction) / 2, dtypes.int32); - } else + } + else { hd = (float)w[0]; bbox_h_start = (int)(((int)hd - (int)hd * central_fraction) / 2); @@ -348,7 +368,8 @@ or rank = 4. Had rank = {0}", rank)); { wd = math_ops.cast((IVariableV1)w[0], dtypes.float64); bbox_w_start = math_ops.cast(((int)wd - (int)wd * central_fraction) / 2, dtypes.int32); - } else + } + else { wd = (float)w[0]; bbox_w_start = (int)(((int)wd - (int)wd * central_fraction) / 2); @@ -360,31 +381,36 @@ or rank = 4. Had rank = {0}", rank)); Tensor bbox_begin, bbox_size; if (rank == 3) { - bbox_begin = array_ops.stack(ops.convert_to_tensor(new [] {bbox_h_start, bbox_w_start, 0})); - bbox_size = array_ops.stack(ops.convert_to_tensor(new [] {bbox_h_size, bbox_w_size, -1})); - } else + bbox_begin = array_ops.stack(ops.convert_to_tensor(new[] { bbox_h_start, bbox_w_start, 0 })); + bbox_size = array_ops.stack(ops.convert_to_tensor(new[] { bbox_h_size, bbox_w_size, -1 })); + } + else { - bbox_begin = array_ops.stack(ops.convert_to_tensor(new [] {0, bbox_h_start, bbox_w_start, 0})); - bbox_size = array_ops.stack(ops.convert_to_tensor(new [] {-1, bbox_h_size, bbox_w_size, -1})); + bbox_begin = array_ops.stack(ops.convert_to_tensor(new[] { 0, bbox_h_start, bbox_w_start, 0 })); + bbox_size = array_ops.stack(ops.convert_to_tensor(new[] { -1, bbox_h_size, bbox_w_size, -1 })); } image = array_ops.slice(image, bbox_begin, bbox_size); - int arg1() { + int arg1() + { if ((bool)h[1]) { // 0 == null for nullable ints anyways return 0; - } else + } + else { return bbox_h_size; } }; - int arg2() { + int arg2() + { if ((bool)w[1]) { return 0; - } else + } + else { return bbox_w_size; } @@ -397,7 +423,9 @@ or rank = 4. Had rank = {0}", rank)); image.set_shape(ops.convert_to_tensor(new object[ _arg1, _arg2, d ])); - } else { + } + else + { var _arg1 = arg1(); var _arg2 = arg2(); image.set_shape(ops.convert_to_tensor(new object[] { @@ -412,354 +440,368 @@ or rank = 4. Had rank = {0}", rank)); public static Tensor pad_to_bounding_box(Tensor image, int offset_height, int offset_width, int target_height, int target_width) { - return tf_with(ops.name_scope(null, "pad_to_bounding_box", new [] {image}), delegate - { - image = ops.convert_to_tensor(image, name: "image"); - - bool is_batch = true; - TensorShape image_shape = image.shape; - if (image_shape.ndim == 3) - { - is_batch = false; - image = array_ops.expand_dims(image, 0); - } else if (image_shape.ndim == Unknown) - { - is_batch = false; - image = array_ops.expand_dims(image, 0); - image.set_shape(new TensorShape(0, 0, 0, 0)); - } else if (image_shape.ndim != 4) - { - throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", - image_shape)); - } - - var assert_ops = _CheckAtLeast3DImage(image, require_static: false); + return tf_with(ops.name_scope(null, "pad_to_bounding_box", new[] { image }), delegate + { + image = ops.convert_to_tensor(image, name: "image"); + + bool is_batch = true; + TensorShape image_shape = image.shape; + if (image_shape.ndim == 3) + { + is_batch = false; + image = array_ops.expand_dims(image, 0); + } + else if (image_shape.ndim == Unknown) + { + is_batch = false; + image = array_ops.expand_dims(image, 0); + image.set_shape(new TensorShape(0, 0, 0, 0)); + } + else if (image_shape.ndim != 4) + { + throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", + image_shape)); + } + + var assert_ops = _CheckAtLeast3DImage(image, require_static: false); // batch: [0], height: [1], width: [2], depth: [3] int[] bhwd = _ImageDimensions(image, rank: 4); - var after_padding_width = target_width - offset_width - bhwd[2]; - - var after_padding_height = target_height - offset_height - bhwd[1]; - - assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(offset_height), - tf.constant(0)), typeof(ValueError), - "offset_height must be >= 0"); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(offset_width), - tf.constant(0)), typeof(ValueError), - "offset_width must be >= 0"); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(after_padding_width), - tf.constant(0)), typeof(ValueError), - "width must be <= target - offset"); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(after_padding_height), - tf.constant(0)), typeof(ValueError), - "height must be <= target - offset"); - image = control_flow_ops.with_dependencies(assert_ops, image); - - var paddings = array_ops.reshape( - array_ops.stack(new [] { + var after_padding_width = target_width - offset_width - bhwd[2]; + + var after_padding_height = target_height - offset_height - bhwd[1]; + + assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(offset_height), + tf.constant(0)), typeof(ValueError), + "offset_height must be >= 0"); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(offset_width), + tf.constant(0)), typeof(ValueError), + "offset_width must be >= 0"); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(after_padding_width), + tf.constant(0)), typeof(ValueError), + "width must be <= target - offset"); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(after_padding_height), + tf.constant(0)), typeof(ValueError), + "height must be <= target - offset"); + image = control_flow_ops.with_dependencies(assert_ops, image); + + var paddings = array_ops.reshape( + array_ops.stack(new[] { 0, 0, offset_height, after_padding_height, offset_width, after_padding_width, 0, 0 - }), new [] {4, 2} - ); - var padded = array_ops.pad(image, paddings); - - TensorShape padded_shape_result() { - int[] i_remnants = {}; - foreach (var i in new [] {bhwd[0], target_height, target_width, bhwd[3]}) - if (_is_tensor(i)) - return null; - else - i_remnants[i_remnants.Length] = i; - return new TensorShape(i_remnants); - }; - TensorShape padded_shape = padded_shape_result(); - padded.set_shape(padded_shape); - - if (!is_batch) - { - padded = array_ops.squeeze(padded, axis: new int[] {0}); - } - - return padded; - }); + }), new[] { 4, 2 } + ); + var padded = array_ops.pad(image, paddings); + + TensorShape padded_shape_result() + { + int[] i_remnants = { }; + foreach (var i in new[] { bhwd[0], target_height, target_width, bhwd[3] }) + if (_is_tensor(i)) + return null; + else + i_remnants[i_remnants.Length] = i; + return new TensorShape(i_remnants); + }; + TensorShape padded_shape = padded_shape_result(); + padded.set_shape(padded_shape); + + if (!is_batch) + { + padded = array_ops.squeeze(padded, axis: new int[] { 0 }); + } + + return padded; + }); } public static Tensor crop_to_bounding_box(Tensor image, int offset_height, int offset_width, int target_height, int target_width) { - return tf_with(ops.name_scope(null, "crop_to_bounding_box", new [] {image}), delegate - { - image = ops.convert_to_tensor(image, name: "image"); - - bool is_batch = true; - TensorShape image_shape = image.shape; - if (image_shape.ndim == 3) - { - is_batch = false; - image = array_ops.expand_dims(image, 0); - } else if (image_shape.ndim == Unknown) - { - is_batch = false; - image = array_ops.expand_dims(image, 0); - image.set_shape(new TensorShape(new int[] {0, 0, 0, 0})); - } else if (image_shape.ndim != 4) - { - throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", - image_shape)); - } - - var assert_ops = _CheckAtLeast3DImage(image, require_static: false); + return tf_with(ops.name_scope(null, "crop_to_bounding_box", new[] { image }), delegate + { + image = ops.convert_to_tensor(image, name: "image"); + + bool is_batch = true; + TensorShape image_shape = image.shape; + if (image_shape.ndim == 3) + { + is_batch = false; + image = array_ops.expand_dims(image, 0); + } + else if (image_shape.ndim == Unknown) + { + is_batch = false; + image = array_ops.expand_dims(image, 0); + image.set_shape(new TensorShape(new int[] { 0, 0, 0, 0 })); + } + else if (image_shape.ndim != 4) + { + throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", + image_shape)); + } + + var assert_ops = _CheckAtLeast3DImage(image, require_static: false); // batch: [0], height: [1], width: [2], depth: [3] int[] bhwd = _ImageDimensions(image, rank: 4); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(offset_height), - tf.constant(0)), typeof(ValueError), - "offset_height must be >= 0."); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(offset_width), - tf.constant(0)), typeof(ValueError), - "offset_width must be >= 0."); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), - tf.constant(target_width)), typeof(ValueError), - "target_width must be > 0."); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), - tf.constant(target_height)), typeof(ValueError), - "target_height must be > 0."); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(bhwd[2]), - tf.constant(target_width + offset_width)), - typeof(ValueError), - "width must be >= target + offset."); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(bhwd[1]), - tf.constant(target_height + offset_height)), - typeof(ValueError), - "height must be >= target + offset."); - image = control_flow_ops.with_dependencies(assert_ops, image); - - var cropped = array_ops.slice( - image, array_ops.stack(new [] {0, offset_height, offset_width, 0}), - array_ops.stack(new [] {-1, target_height, target_width, -1})); - - TensorShape cropped_shape_result() { - int[] i_remnants = {}; - foreach (var i in new [] {bhwd[0], target_height, target_width, bhwd[3]}) - if (_is_tensor(i)) - return null; - else - i_remnants[i_remnants.Length] = i; - return new TensorShape(i_remnants); - }; - var cropped_shape = cropped_shape_result(); - cropped.set_shape(cropped_shape); - - if (!is_batch) - { - cropped = array_ops.squeeze(cropped, axis: new int[] {0}); - } - - return cropped; - }); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(offset_height), + tf.constant(0)), typeof(ValueError), + "offset_height must be >= 0."); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(offset_width), + tf.constant(0)), typeof(ValueError), + "offset_width must be >= 0."); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), + tf.constant(target_width)), typeof(ValueError), + "target_width must be > 0."); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), + tf.constant(target_height)), typeof(ValueError), + "target_height must be > 0."); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(bhwd[2]), + tf.constant(target_width + offset_width)), + typeof(ValueError), + "width must be >= target + offset."); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_greater_equal(tf.constant(bhwd[1]), + tf.constant(target_height + offset_height)), + typeof(ValueError), + "height must be >= target + offset."); + image = control_flow_ops.with_dependencies(assert_ops, image); + + var cropped = array_ops.slice( + image, array_ops.stack(new[] { 0, offset_height, offset_width, 0 }), + array_ops.stack(new[] { -1, target_height, target_width, -1 })); + + TensorShape cropped_shape_result() + { + int[] i_remnants = { }; + foreach (var i in new[] { bhwd[0], target_height, target_width, bhwd[3] }) + if (_is_tensor(i)) + return null; + else + i_remnants[i_remnants.Length] = i; + return new TensorShape(i_remnants); + }; + var cropped_shape = cropped_shape_result(); + cropped.set_shape(cropped_shape); + + if (!is_batch) + { + cropped = array_ops.squeeze(cropped, axis: new int[] { 0 }); + } + + return cropped; + }); } public static Tensor resize_image_with_crop_or_pad(Tensor image, object target_height, object target_width) { - using (ops.name_scope(null, "resize_image_with_crop_or_pad", new [] {image})) - return tf_with(ops.name_scope(null, "resize_image_with_crop_or_pad", new [] {image}), delegate - { - image = ops.convert_to_tensor(image, name: "image"); - TensorShape image_shape = image.shape; - bool is_batch = true; - if (image_shape.ndim == 3) - { - is_batch = false; - image = array_ops.expand_dims(image, 0); - } else if (image_shape.ndim == Unknown) - { - is_batch = false; - image = array_ops.expand_dims(image, 0); - image.set_shape(new TensorShape(new int[] {0, 0, 0, 0})); - } else if (image_shape.ndim != 4) - { - throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", - image_shape)); - } - - var assert_ops = _CheckAtLeast3DImage(image, require_static: false); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), - tf.constant(target_width)), - typeof(ValueError), - "target_width must be > 0."); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), - tf.constant(target_height)), - typeof(ValueError), - "target_height must be > 0."); - - image = control_flow_ops.with_dependencies(assert_ops, image); - - if (_is_tensor(target_height)) - { - target_height = control_flow_ops.with_dependencies( - assert_ops, tf.constant(target_height)); - } - if (_is_tensor(target_width)) - { - target_width = control_flow_ops.with_dependencies( - assert_ops, tf.constant(target_width)); - } - - - object max_(object x, object y) { - if (_is_tensor(x) || _is_tensor(y)) - return math_ops.maximum(x, y); - else - return Math.Max((int)x, (int)y); - } - - object min_(object x, object y) { - if (_is_tensor(x) || _is_tensor(y)) - return math_ops.minimum(x, y); - else - return Math.Min((int)x, (int)y); - } - - object equal_(object x, object y) { - if (_is_tensor(x) || _is_tensor(y)) - return math_ops.equal(x, y); - else - return x == y; - } - - int[] _hw_ = _ImageDimensions(image, rank: 4); - int width_diff = (int)target_width - _hw_[2]; - int offset_crop_width = (int)max_(Math.Floor(Math.Abs((decimal)width_diff) / 2), 0); - int offset_pad_width = (int)max_(Math.Floor((decimal)width_diff / 2), 0); - - int height_diff = (int)target_height - _hw_[1]; - int offset_crop_height = (int)max_(Math.Floor(Math.Abs((decimal)height_diff) / 2), 0); - int offset_pad_height = (int)max_(Math.Floor((decimal)height_diff / 2), 0); - - Tensor cropped = crop_to_bounding_box(image, offset_crop_height, offset_crop_width, - (int)min_(target_height, _hw_[1]), - (int)min_(target_width, _hw_[2])); - - Tensor resized = pad_to_bounding_box(cropped, offset_pad_height, offset_pad_width, - (int)target_height, (int)target_width); - - if (resized.TensorShape.ndim == Unknown) - throw new ValueError("resized contains no shape."); - - int[] _rhrw_ = _ImageDimensions(resized, rank: 4); - - assert_ops = new Operation[2]; - assert_ops[0] = _assert( - (Tensor)equal_(_rhrw_[1], target_height), typeof(ValueError), - "resized height is not correct."); - assert_ops[1] = _assert( - (Tensor)equal_(_rhrw_[2], target_width), typeof(ValueError), - "resized width is not correct."); - - resized = control_flow_ops.with_dependencies(assert_ops, resized); - - if (!is_batch) - { - resized = array_ops.squeeze(resized, axis: new int[] {0}); - } - - return resized; - }); + using (ops.name_scope(null, "resize_image_with_crop_or_pad", new[] { image })) + return tf_with(ops.name_scope(null, "resize_image_with_crop_or_pad", new[] { image }), delegate + { + image = ops.convert_to_tensor(image, name: "image"); + TensorShape image_shape = image.shape; + bool is_batch = true; + if (image_shape.ndim == 3) + { + is_batch = false; + image = array_ops.expand_dims(image, 0); + } + else if (image_shape.ndim == Unknown) + { + is_batch = false; + image = array_ops.expand_dims(image, 0); + image.set_shape(new TensorShape(new int[] { 0, 0, 0, 0 })); + } + else if (image_shape.ndim != 4) + { + throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", + image_shape)); + } + + var assert_ops = _CheckAtLeast3DImage(image, require_static: false); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), + tf.constant(target_width)), + typeof(ValueError), + "target_width must be > 0."); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), + tf.constant(target_height)), + typeof(ValueError), + "target_height must be > 0."); + + image = control_flow_ops.with_dependencies(assert_ops, image); + + if (_is_tensor(target_height)) + { + target_height = control_flow_ops.with_dependencies( + assert_ops, tf.constant(target_height)); + } + if (_is_tensor(target_width)) + { + target_width = control_flow_ops.with_dependencies( + assert_ops, tf.constant(target_width)); + } + + + object max_(object x, object y) + { + if (_is_tensor(x) || _is_tensor(y)) + return math_ops.maximum(x, y); + else + return Math.Max((int)x, (int)y); + } + + object min_(object x, object y) + { + if (_is_tensor(x) || _is_tensor(y)) + return math_ops.minimum(x, y); + else + return Math.Min((int)x, (int)y); + } + + object equal_(object x, object y) + { + if (_is_tensor(x) || _is_tensor(y)) + return math_ops.equal(x, y); + else + return x == y; + } + + int[] _hw_ = _ImageDimensions(image, rank: 4); + int width_diff = (int)target_width - _hw_[2]; + int offset_crop_width = (int)max_(Math.Floor(Math.Abs((decimal)width_diff) / 2), 0); + int offset_pad_width = (int)max_(Math.Floor((decimal)width_diff / 2), 0); + + int height_diff = (int)target_height - _hw_[1]; + int offset_crop_height = (int)max_(Math.Floor(Math.Abs((decimal)height_diff) / 2), 0); + int offset_pad_height = (int)max_(Math.Floor((decimal)height_diff / 2), 0); + + Tensor cropped = crop_to_bounding_box(image, offset_crop_height, offset_crop_width, + (int)min_(target_height, _hw_[1]), + (int)min_(target_width, _hw_[2])); + + Tensor resized = pad_to_bounding_box(cropped, offset_pad_height, offset_pad_width, + (int)target_height, (int)target_width); + + if (resized.TensorShape.ndim == Unknown) + throw new ValueError("resized contains no shape."); + + int[] _rhrw_ = _ImageDimensions(resized, rank: 4); + + assert_ops = new Operation[2]; + assert_ops[0] = _assert( + (Tensor)equal_(_rhrw_[1], target_height), typeof(ValueError), + "resized height is not correct."); + assert_ops[1] = _assert( + (Tensor)equal_(_rhrw_[2], target_width), typeof(ValueError), + "resized width is not correct."); + + resized = control_flow_ops.with_dependencies(assert_ops, resized); + + if (!is_batch) + { + resized = array_ops.squeeze(resized, axis: new int[] { 0 }); + } + + return resized; + }); } internal static Tensor _resize_images_common(Tensor images, Func resizer_fn, Tensor size, bool preserve_aspect_ratio, string name, bool skip_resize_if_same) { - return tf_with(ops.name_scope(name, "resize", new[] {images, size}), delegate - { - if (images.TensorShape.ndim == Unknown) - throw new ValueError("\'images\' contains no shape."); - bool is_batch = true; - if (images.TensorShape.ndim == 3) - { - is_batch = false; - images = array_ops.expand_dims(images, 0); - } else if (images.TensorShape.ndim != 4) - throw new ValueError("\'images\' must have either 3 or 4 dimensions."); - - var (height, width) = (images.dims[1], images.dims[2]); - - if (!size.TensorShape.is_compatible_with(new [] {2})) - throw new ValueError(@"\'size\' must be a 1-D Tensor of 2 elements: + return tf_with(ops.name_scope(name, "resize", new[] { images, size }), delegate + { + if (images.TensorShape.ndim == Unknown) + throw new ValueError("\'images\' contains no shape."); + bool is_batch = true; + if (images.TensorShape.ndim == 3) + { + is_batch = false; + images = array_ops.expand_dims(images, 0); + } + else if (images.TensorShape.ndim != 4) + throw new ValueError("\'images\' must have either 3 or 4 dimensions."); + + var (height, width) = (images.dims[1], images.dims[2]); + + if (!size.TensorShape.is_compatible_with(new[] { 2 })) + throw new ValueError(@"\'size\' must be a 1-D Tensor of 2 elements: new_height, new_width"); - if (preserve_aspect_ratio) - { - var _chcw_ = _ImageDimensions(images, rank: 4); - - var scale_factor_height = ( - math_ops.cast(size[0], dtypes.float32) / - math_ops.cast(_chcw_[1], dtypes.float32)); - var scale_factor_width = ( - math_ops.cast(size[1], dtypes.float32) / - math_ops.cast(_chcw_[2], dtypes.float32)); - var scale_factor = math_ops.minimum(scale_factor_height, scale_factor_width); - var scaled_height_const = math_ops.cast( - math_ops.round(scale_factor * - math_ops.cast(_chcw_[1], dtypes.float32)), - dtypes.int32); - var scaled_width_const = math_ops.cast( - math_ops.round(scale_factor * - math_ops.cast(_chcw_[2], dtypes.float32)), - dtypes.int32); - - size = ops.convert_to_tensor(new [] {scaled_height_const, scaled_width_const}, - dtypes.int32, - name: "size"); - } - - var size_const_as_shape = tensor_util.constant_value_as_shape(size); - var new_height_const = tensor_shape.dimension_at_index(size_const_as_shape, - 0).value; - var new_width_const = tensor_shape.dimension_at_index(size_const_as_shape, - 1).value; - - bool x_null = true; - if (skip_resize_if_same) - { - foreach (int x in new [] {new_width_const, width, new_height_const, height}) - { - if (width != new_width_const && height == new_height_const) - { - break; - } - if (x != 0) - { - x_null = false; - } - } - if (!x_null) - images = array_ops.squeeze(images, axis: new int[] {0}); - return images; - } - - images = resizer_fn(images, size); - - images.set_shape(new TensorShape(new int[] { Unknown, new_height_const, new_width_const, Unknown })); - - if (!is_batch) - images = array_ops.squeeze(images, axis: new int[] {0}); - return images; - }); + if (preserve_aspect_ratio) + { + var _chcw_ = _ImageDimensions(images, rank: 4); + + var scale_factor_height = ( + math_ops.cast(size[0], dtypes.float32) / + math_ops.cast(_chcw_[1], dtypes.float32)); + var scale_factor_width = ( + math_ops.cast(size[1], dtypes.float32) / + math_ops.cast(_chcw_[2], dtypes.float32)); + var scale_factor = math_ops.minimum(scale_factor_height, scale_factor_width); + var scaled_height_const = math_ops.cast( + math_ops.round(scale_factor * + math_ops.cast(_chcw_[1], dtypes.float32)), + dtypes.int32); + var scaled_width_const = math_ops.cast( + math_ops.round(scale_factor * + math_ops.cast(_chcw_[2], dtypes.float32)), + dtypes.int32); + + size = ops.convert_to_tensor(new[] { scaled_height_const, scaled_width_const }, + dtypes.int32, + name: "size"); + } + + var size_const_as_shape = tensor_util.constant_value_as_shape(size); + var new_height_const = tensor_shape.dimension_at_index(size_const_as_shape, + 0).value; + var new_width_const = tensor_shape.dimension_at_index(size_const_as_shape, + 1).value; + + bool x_null = true; + if (skip_resize_if_same) + { + foreach (int x in new[] { new_width_const, width, new_height_const, height }) + { + if (width != new_width_const && height == new_height_const) + { + break; + } + if (x != 0) + { + x_null = false; + } + } + if (!x_null) + images = array_ops.squeeze(images, axis: new int[] { 0 }); + return images; + } + + images = resizer_fn(images, size); + + images.set_shape(new TensorShape(new int[] { Unknown, new_height_const, new_width_const, Unknown })); + + if (!is_batch) + images = array_ops.squeeze(images, axis: new int[] { 0 }); + return images; + }); } public static Tensor resize_images(Tensor images, Tensor size, string method = ResizeMethod.BILINEAR, bool preserve_aspect_ratio = false, bool antialias = false, string name = null) { - Tensor resize_fn(Tensor images_t, Tensor new_size) { + Tensor resize_fn(Tensor images_t, Tensor new_size) + { var scale_and_translate_methods = new string[] { ResizeMethod.LANCZOS3, ResizeMethod.LANCZOS5, ResizeMethod.GAUSSIAN, ResizeMethod.MITCHELLCUBIC }; - Tensor resize_with_scale_and_translate(string method) { + Tensor resize_with_scale_and_translate(string method) + { var scale = new Tensor[] { math_ops.cast(new_size, dtype: dtypes.float32), // does this need to be reworked into only elements 1-3 being @@ -770,7 +812,7 @@ new_height, new_width"); images_t, new_size, scale, - array_ops.zeros(new [] {2}), + array_ops.zeros(new[] { 2 }), kernel_type: method, antialias: antialias ); @@ -780,19 +822,19 @@ new_height, new_width"); if (antialias) return resize_with_scale_and_translate("triangle"); else - return gen_image_ops.resize_bilinear(images_t, - new_size, + return gen_image_ops.resize_bilinear(images_t, + new_size, half_pixel_centers: true); else if (method == ResizeMethod.NEAREST_NEIGHBOR) - return gen_image_ops.resize_nearest_neighbor(images_t, - new_size, + return gen_image_ops.resize_nearest_neighbor(images_t, + new_size, half_pixel_centers: true); else if (method == ResizeMethod.BICUBIC) if (antialias) return resize_with_scale_and_translate("keyscubic"); else - return gen_image_ops.resize_bicubic(images_t, - new_size, + return gen_image_ops.resize_bicubic(images_t, + new_size, half_pixel_centers: true); else if (method == ResizeMethod.AREA) return gen_ops.resize_area(images_t, new_size); @@ -816,85 +858,88 @@ new_height, new_width"); internal static Tensor _resize_image_with_pad_common(Tensor image, int target_height, int target_width, Func resize_fn) { - using (ops.name_scope(null, "resize_image_with_pad", new [] {image})) - return tf_with(ops.name_scope(null, "resize_image_with_pad", new [] {image}), delegate - { - image = ops.convert_to_tensor(image, name: "tensor"); - var image_shape = image.TensorShape; - bool is_batch = true; - if (image_shape.ndim == 3) - { - is_batch = false; - image = array_ops.expand_dims(image, 0); - } else if (image_shape.ndim == Unknown) - { - is_batch = false; - image = array_ops.expand_dims(image, 0); - image.set_shape(new TensorShape(new [] {Unknown, Unknown, Unknown, Unknown})); - } else if (image_shape.ndim != 4) - { - throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", - image_shape)); - } - - var assert_ops = _CheckAtLeast3DImage(image, require_static: false); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), - tf.constant(target_width)), - typeof(ValueError), - "target_width must be > 0."); - assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), - tf.constant(target_height)), - typeof(ValueError), - "target_height must be > 0."); - - image = control_flow_ops.with_dependencies(assert_ops, image); - - object max_(object x, object y) { - if (_is_tensor(x) || _is_tensor(y)) - return math_ops.maximum(x, y); - else - return Math.Max((int)x, (int)y); - } - - var _hw_ = _ImageDimensions(image, rank: 4); - - var f_height = math_ops.cast(_hw_[1], dtype: dtypes.float32); - var f_width = math_ops.cast(_hw_[2], dtype: dtypes.float32); - var f_target_height = math_ops.cast(target_height, dtype: dtypes.float32); - var f_target_width = math_ops.cast(target_width, dtype: dtypes.float32); - - var ratio = (Tensor)max_(f_width / f_target_width, f_height / f_target_height); - var resized_height_float = f_height / ratio; - var resized_width_float = f_width / ratio; - var resized_height = math_ops.cast( - gen_math_ops.floor(resized_height_float), dtype: dtypes.int32); - var resized_width = math_ops.cast( - gen_math_ops.floor(resized_width_float), dtype: dtypes.int32); - - var padding_height = (f_target_height - resized_height_float) / 2; - var padding_width = (f_target_width - resized_width_float) / 2; - var f_padding_height = gen_math_ops.floor(padding_height); - var f_padding_width = gen_math_ops.floor(padding_width); - int p_height = (int)max_(0, math_ops.cast(f_padding_height, dtype: dtypes.int32)); - int p_width = (int)max_(0, math_ops.cast(f_padding_width, dtype: dtypes.int32)); - - var resized = resize_fn(image, new Tensor(new [] {resized_height, resized_width})); - - var padded = pad_to_bounding_box(resized, p_height, p_width, target_height, - target_width); - - if (padded.TensorShape.ndim == Unknown) - throw new ValueError("padded contains no shape."); - - _ImageDimensions(padded, rank: 4); - - if (!is_batch) - { - padded = array_ops.squeeze(padded, axis: new int[] {0}); - } - - return padded; - }); + using (ops.name_scope(null, "resize_image_with_pad", new[] { image })) + return tf_with(ops.name_scope(null, "resize_image_with_pad", new[] { image }), delegate + { + image = ops.convert_to_tensor(image, name: "tensor"); + var image_shape = image.TensorShape; + bool is_batch = true; + if (image_shape.ndim == 3) + { + is_batch = false; + image = array_ops.expand_dims(image, 0); + } + else if (image_shape.ndim == Unknown) + { + is_batch = false; + image = array_ops.expand_dims(image, 0); + image.set_shape(new TensorShape(new[] { Unknown, Unknown, Unknown, Unknown })); + } + else if (image_shape.ndim != 4) + { + throw new ValueError(String.Format("\'image\' {0} must have either 3 or 4 dimensions.", + image_shape)); + } + + var assert_ops = _CheckAtLeast3DImage(image, require_static: false); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), + tf.constant(target_width)), + typeof(ValueError), + "target_width must be > 0."); + assert_ops[assert_ops.Length] = _assert(check_ops.assert_less(tf.constant(0), + tf.constant(target_height)), + typeof(ValueError), + "target_height must be > 0."); + + image = control_flow_ops.with_dependencies(assert_ops, image); + + object max_(object x, object y) + { + if (_is_tensor(x) || _is_tensor(y)) + return math_ops.maximum(x, y); + else + return Math.Max((int)x, (int)y); + } + + var _hw_ = _ImageDimensions(image, rank: 4); + + var f_height = math_ops.cast(_hw_[1], dtype: dtypes.float32); + var f_width = math_ops.cast(_hw_[2], dtype: dtypes.float32); + var f_target_height = math_ops.cast(target_height, dtype: dtypes.float32); + var f_target_width = math_ops.cast(target_width, dtype: dtypes.float32); + + var ratio = (Tensor)max_(f_width / f_target_width, f_height / f_target_height); + var resized_height_float = f_height / ratio; + var resized_width_float = f_width / ratio; + var resized_height = math_ops.cast( + gen_math_ops.floor(resized_height_float), dtype: dtypes.int32); + var resized_width = math_ops.cast( + gen_math_ops.floor(resized_width_float), dtype: dtypes.int32); + + var padding_height = (f_target_height - resized_height_float) / 2; + var padding_width = (f_target_width - resized_width_float) / 2; + var f_padding_height = gen_math_ops.floor(padding_height); + var f_padding_width = gen_math_ops.floor(padding_width); + int p_height = (int)max_(0, math_ops.cast(f_padding_height, dtype: dtypes.int32)); + int p_width = (int)max_(0, math_ops.cast(f_padding_width, dtype: dtypes.int32)); + + var resized = resize_fn(image, new Tensor(new[] { resized_height, resized_width })); + + var padded = pad_to_bounding_box(resized, p_height, p_width, target_height, + target_width); + + if (padded.TensorShape.ndim == Unknown) + throw new ValueError("padded contains no shape."); + + _ImageDimensions(padded, rank: 4); + + if (!is_batch) + { + padded = array_ops.squeeze(padded, axis: new int[] { 0 }); + } + + return padded; + }); } public static Tensor resize_images_with_pad(Tensor image, int target_height, int target_width, @@ -911,28 +956,28 @@ new_height, new_width"); public static Tensor per_image_standardization(Tensor image) { - return tf_with(ops.name_scope(null, "per_image_standardization", new [] {image}), scope => - { - image = ops.convert_to_tensor(image, name: "image"); - image = _AssertAtLeast3DImage(image); + return tf_with(ops.name_scope(null, "per_image_standardization", new[] { image }), scope => + { + image = ops.convert_to_tensor(image, name: "image"); + image = _AssertAtLeast3DImage(image); - var orig_dtype = image.dtype; - if (Array.Exists(new [] {dtypes.float16, dtypes.float32}, orig_dtype => orig_dtype == orig_dtype)) - image = convert_image_dtype(image, dtypes.float32); + var orig_dtype = image.dtype; + if (Array.Exists(new[] { dtypes.float16, dtypes.float32 }, orig_dtype => orig_dtype == orig_dtype)) + image = convert_image_dtype(image, dtypes.float32); - var num_pixels_ = array_ops.shape(image).dims; - num_pixels_ = num_pixels_.Skip(num_pixels_.Length - 3).Take(num_pixels_.Length - (num_pixels_.Length - 3)).ToArray(); - Tensor num_pixels = math_ops.reduce_prod(new Tensor(num_pixels_)); - Tensor image_mean = math_ops.reduce_mean(image, axis: new int[] {-1, -2, -3}, keepdims: true); + var num_pixels_ = array_ops.shape(image).dims; + num_pixels_ = num_pixels_.Skip(num_pixels_.Length - 3).Take(num_pixels_.Length - (num_pixels_.Length - 3)).ToArray(); + Tensor num_pixels = math_ops.reduce_prod(new Tensor(num_pixels_)); + Tensor image_mean = math_ops.reduce_mean(image, axis: new int[] { -1, -2, -3 }, keepdims: true); - var stddev = math_ops.reduce_std(image, axis: new int[] {-1, -2, -3}, keepdims: true); - var min_stddev = math_ops.rsqrt(math_ops.cast(num_pixels, image.dtype)); - var adjusted_stddev = math_ops.maximum(stddev, min_stddev); + var stddev = math_ops.reduce_std(image, axis: new int[] { -1, -2, -3 }, keepdims: true); + var min_stddev = math_ops.rsqrt(math_ops.cast(num_pixels, image.dtype)); + var adjusted_stddev = math_ops.maximum(stddev, min_stddev); - image = image - image_mean; - image = tf.div(image, adjusted_stddev, name: scope); // name: scope in python version + image = image - image_mean; + image = tf.div(image, adjusted_stddev, name: scope); // name: scope in python version return convert_image_dtype(image, orig_dtype, saturate: true); - }); + }); } public static Tensor random_brightness(Tensor image, float max_delta, int seed = 0) @@ -940,7 +985,7 @@ new_height, new_width"); if (max_delta < 0) throw new ValueError("max_delta must be non-negative."); - var delta = random_ops.random_uniform(new int[] {}, max_delta * -1, max_delta, seed: seed); + var delta = random_ops.random_uniform(new int[] { }, max_delta * -1, max_delta, seed: seed); return adjust_brightness(image, delta); } @@ -952,69 +997,72 @@ new_height, new_width"); if (lower < 0) throw new ValueError("lower must be non-negative."); - var contrast_factor = random_ops.random_uniform(new int[] {}, lower, upper, seed: seed); + var contrast_factor = random_ops.random_uniform(new int[] { }, lower, upper, seed: seed); return adjust_contrast(image, contrast_factor); } public static Tensor adjust_brightness(Tensor image, Tensor delta) { - return tf_with(ops.name_scope(null, "adjust_brightness", new [] {image, delta}), name => - { - image = ops.convert_to_tensor(image, name: "image"); - var orig_dtype = image.dtype; + return tf_with(ops.name_scope(null, "adjust_brightness", new[] { image, delta }), name => + { + image = ops.convert_to_tensor(image, name: "image"); + var orig_dtype = image.dtype; - Tensor flt_image; - if (Array.Exists(new [] {dtypes.float16, dtypes.float32}, orig_dtype => orig_dtype == orig_dtype)) - { - flt_image = image; - } else - { - flt_image = convert_image_dtype(image, dtypes.float32); - } + Tensor flt_image; + if (Array.Exists(new[] { dtypes.float16, dtypes.float32 }, orig_dtype => orig_dtype == orig_dtype)) + { + flt_image = image; + } + else + { + flt_image = convert_image_dtype(image, dtypes.float32); + } - var adjusted = math_ops.add( - flt_image, math_ops.cast(delta, flt_image.dtype), name: name); - - return convert_image_dtype(adjusted, orig_dtype, saturate: true); - }); + var adjusted = math_ops.add( + flt_image, math_ops.cast(delta, flt_image.dtype), name: name); + + return convert_image_dtype(adjusted, orig_dtype, saturate: true); + }); } public static Tensor adjust_contrast(Tensor images, Tensor contrast_factor) { - return tf_with(ops.name_scope(null, "adjust_brightness", new [] {images, contrast_factor}), name => - { - images = ops.convert_to_tensor(images, name: "images"); - var orig_dtype = images.dtype; + return tf_with(ops.name_scope(null, "adjust_brightness", new[] { images, contrast_factor }), name => + { + images = ops.convert_to_tensor(images, name: "images"); + var orig_dtype = images.dtype; - Tensor flt_images; - if (Array.Exists(new [] {dtypes.float16, dtypes.float32}, orig_dtype => orig_dtype == orig_dtype)) - { - flt_images = images; - } else - { - flt_images = convert_image_dtype(images, dtypes.float32); - } + Tensor flt_images; + if (Array.Exists(new[] { dtypes.float16, dtypes.float32 }, orig_dtype => orig_dtype == orig_dtype)) + { + flt_images = images; + } + else + { + flt_images = convert_image_dtype(images, dtypes.float32); + } - var adjusted = gen_ops.adjust_contrastv2( - flt_images, contrast_factor: contrast_factor, name: name); + var adjusted = gen_ops.adjust_contrastv2( + flt_images, contrast_factor: contrast_factor, name: name); - return convert_image_dtype(adjusted, orig_dtype, saturate: true); - }); + return convert_image_dtype(adjusted, orig_dtype, saturate: true); + }); } public static Tensor adjust_gamma(Tensor image, int gamma = 1, int gain = 1) { - return tf_with(ops.name_scope(null, "adjust_gamma", new [] {image, + return tf_with(ops.name_scope(null, "adjust_gamma", new[] {image, tf.constant(gamma), tf.constant(gain)}), name => { image = ops.convert_to_tensor(image, name: "image"); var orig_dtype = image.dtype; Tensor flt_image; - if (Array.Exists(new [] {dtypes.float16, dtypes.float32}, orig_dtype => orig_dtype == orig_dtype)) + if (Array.Exists(new[] { dtypes.float16, dtypes.float32 }, orig_dtype => orig_dtype == orig_dtype)) { flt_image = image; - } else + } + else { flt_image = convert_image_dtype(image, dtypes.float32); } @@ -1030,7 +1078,7 @@ new_height, new_width"); // if it fails to continue down the line of the assert Tensor gamma_as_tensor; if (assert_op != null) - gamma_as_tensor = control_flow_ops.with_dependencies(new [] {assert_op}, tf.constant(gamma)); + gamma_as_tensor = control_flow_ops.with_dependencies(new[] { assert_op }, tf.constant(gamma)); else gamma_as_tensor = tf.constant(gamma); @@ -1042,35 +1090,35 @@ new_height, new_width"); public static Tensor rgb_to_grayscale(Tensor images, string name = null) { - return tf_with(ops.name_scope(name, "rgb_to_grayscale", new [] {images}), name => - { - images = ops.convert_to_tensor(images, name: "images"); - var orig_dtype = images.dtype; - var flt_image = convert_image_dtype(images, dtypes.float32); - - var rgb_weights = new Tensor(new double[] {0.2989, 0.5870, 0.1140}); - var gray_float = math_ops.tensordot(flt_image, rgb_weights, new [] {-1, -1}); - gray_float = array_ops.expand_dims(gray_float, -1); - return convert_image_dtype(gray_float, orig_dtype, name: name); - }); + return tf_with(ops.name_scope(name, "rgb_to_grayscale", new[] { images }), name => + { + images = ops.convert_to_tensor(images, name: "images"); + var orig_dtype = images.dtype; + var flt_image = convert_image_dtype(images, dtypes.float32); + + var rgb_weights = new Tensor(new double[] { 0.2989, 0.5870, 0.1140 }); + var gray_float = math_ops.tensordot(flt_image, rgb_weights, new[] { -1, -1 }); + gray_float = array_ops.expand_dims(gray_float, -1); + return convert_image_dtype(gray_float, orig_dtype, name: name); + }); } public static Tensor grayscale_to_rgb(Tensor images, string name = null) { - return tf_with(ops.name_scope(name, "grayscale_to_rgb", new [] {images}), name => - { - images = _AssertAtLeast3DImage(images); - - images = ops.convert_to_tensor(images, name: "images"); - var rank_1 = array_ops.expand_dims(array_ops.rank(images) - 1, 0); - var shape_list = (array_ops.ones(rank_1, dtype: dtypes.int32) + - array_ops.expand_dims(tf.constant(3), 0)); - var multiples = array_ops.concat(new Tensor[] {shape_list}, 0); - var rgb = array_ops.tile(images, multiples, name: name); - int[] rgb_temp = images.shape.Take(images.shape.Length - 1).ToArray(); - rgb.set_shape(array_ops.concat(new Tensor[] {ops.convert_to_tensor(rgb_temp)}, 3)); - return rgb; - }); + return tf_with(ops.name_scope(name, "grayscale_to_rgb", new[] { images }), name => + { + images = _AssertAtLeast3DImage(images); + + images = ops.convert_to_tensor(images, name: "images"); + var rank_1 = array_ops.expand_dims(array_ops.rank(images) - 1, 0); + var shape_list = (array_ops.ones(rank_1, dtype: dtypes.int32) + + array_ops.expand_dims(tf.constant(3), 0)); + var multiples = array_ops.concat(new Tensor[] { shape_list }, 0); + var rgb = array_ops.tile(images, multiples, name: name); + int[] rgb_temp = images.shape.Take(images.shape.Length - 1).ToArray(); + rgb.set_shape(array_ops.concat(new Tensor[] { ops.convert_to_tensor(rgb_temp) }, 3)); + return rgb; + }); } public static Tensor random_hue(Tensor image, float max_delta, int seed = 0) @@ -1081,27 +1129,27 @@ new_height, new_width"); if (max_delta < 0) throw new ValueError("max_delta must be non-negative."); - var delta = random_ops.random_uniform(new int[] {}, max_delta * -1, max_delta, seed: seed); + var delta = random_ops.random_uniform(new int[] { }, max_delta * -1, max_delta, seed: seed); return adjust_hue(image, delta); } public static Tensor adjust_hue(Tensor image, Tensor delta, string name = null) { - return tf_with(ops.name_scope(name, "adjust_hue", new [] {image}), name => - { - image = ops.convert_to_tensor(image, name: "image"); - var orig_dtype = image.dtype; - - Tensor flt_image; - if (Array.Exists(new [] {dtypes.float16, dtypes.float32}, orig_dtype => orig_dtype == orig_dtype)) - flt_image = image; - else - flt_image = convert_image_dtype(image, dtypes.float32); + return tf_with(ops.name_scope(name, "adjust_hue", new[] { image }), name => + { + image = ops.convert_to_tensor(image, name: "image"); + var orig_dtype = image.dtype; - var rgb_altered = gen_ops.adjust_hue(flt_image, delta); + Tensor flt_image; + if (Array.Exists(new[] { dtypes.float16, dtypes.float32 }, orig_dtype => orig_dtype == orig_dtype)) + flt_image = image; + else + flt_image = convert_image_dtype(image, dtypes.float32); - return convert_image_dtype(rgb_altered, orig_dtype); - }); + var rgb_altered = gen_ops.adjust_hue(flt_image, delta); + + return convert_image_dtype(rgb_altered, orig_dtype); + }); } public static Tensor random_jpeg_quality(Tensor image, float min_jpeg_quality, float max_jpeg_quality, @@ -1114,7 +1162,7 @@ new_height, new_width"); if (min_jpeg_quality >= max_jpeg_quality) throw new ValueError("`min_jpeg_quality` must be less than `max_jpeg_quality`."); - var jpeg_quality = random_ops.random_uniform(new int[] {}, + var jpeg_quality = random_ops.random_uniform(new int[] { }, min_jpeg_quality, max_jpeg_quality, seed: seed, @@ -1124,18 +1172,18 @@ new_height, new_width"); public static Tensor adjust_jpeg_quality(Tensor image, Tensor jpeg_quality, string name = null) { - return tf_with(ops.name_scope(name, "adjust_jpeg_quality", new [] {image}), delegate - { - image = ops.convert_to_tensor(image, name: "image"); - var channels = image.TensorShape.as_list()[image.TensorShape.dims.Length - 1]; - var orig_dtype = image.dtype; + return tf_with(ops.name_scope(name, "adjust_jpeg_quality", new[] { image }), delegate + { + image = ops.convert_to_tensor(image, name: "image"); + var channels = image.TensorShape.as_list()[image.TensorShape.dims.Length - 1]; + var orig_dtype = image.dtype; // python code checks to ensure jpeq_quality is a tensor; unnecessary here since // it is passed as a tensor image = gen_ops.encode_jpeg_variable_quality(image, quality: jpeg_quality); - - image = gen_ops.decode_jpeg(image, channels: channels); - return convert_image_dtype(image, orig_dtype, saturate: true); - }); + + image = gen_ops.decode_jpeg(image, channels: channels); + return convert_image_dtype(image, orig_dtype, saturate: true); + }); } public static Tensor random_saturation(Tensor image, float lower, float upper, int seed = 0) @@ -1146,27 +1194,27 @@ new_height, new_width"); if (lower < 0) throw new ValueError("lower must be non-negative"); - var saturation_factor = random_ops.random_uniform(new int[] {}, lower, upper, seed: seed); + var saturation_factor = random_ops.random_uniform(new int[] { }, lower, upper, seed: seed); return adjust_saturation(image, saturation_factor); } public static Tensor adjust_saturation(Tensor image, Tensor saturation_factor, string name = null) { - return tf_with(ops.name_scope(name, "adjust_saturation", new [] {image}), name => - { - image = ops.convert_to_tensor(image, name: "image"); - var orig_dtype = image.dtype; - - Tensor flt_image; - if (Array.Exists(new [] {dtypes.float16, dtypes.float32}, orig_dtype => orig_dtype == orig_dtype)) - flt_image = image; - else - flt_image = convert_image_dtype(image, dtypes.float32); + return tf_with(ops.name_scope(name, "adjust_saturation", new[] { image }), name => + { + image = ops.convert_to_tensor(image, name: "image"); + var orig_dtype = image.dtype; - var adjusted = gen_ops.adjust_saturation(flt_image, saturation_factor); + Tensor flt_image; + if (Array.Exists(new[] { dtypes.float16, dtypes.float32 }, orig_dtype => orig_dtype == orig_dtype)) + flt_image = image; + else + flt_image = convert_image_dtype(image, dtypes.float32); - return convert_image_dtype(adjusted, orig_dtype); - }); + var adjusted = gen_ops.adjust_saturation(flt_image, saturation_factor); + + return convert_image_dtype(adjusted, orig_dtype); + }); } public static Tensor total_variation(Tensor images, string name = null) @@ -1188,10 +1236,10 @@ new_height, new_width"); if (min_object_covered == null) min_object_covered = ops.convert_to_tensor(0.1); if (aspect_ratio_range == null) - aspect_ratio_range = new float[] {0.75f, 1.33f}; + aspect_ratio_range = new float[] { 0.75f, 1.33f }; if (area_range == null) - area_range = new float[] {0.05f, 1f}; - + area_range = new float[] { 0.05f, 1f }; + int? seed1, seed2; if (seed != 0) (seed1, seed2) = random_seed.get_seed(seed); @@ -1243,7 +1291,7 @@ new_height, new_width"); { Tensor iou_threshold_tensor = ops.convert_to_tensor(iou_threshold, name: "iou_threshold"); Tensor score_threshold_tensor = ops.convert_to_tensor(score_threshold, name: "score_threshold"); - + // non_max_suppression_v5 apparently doesn't exist yet, so use v4 // and adapt the arguments to fit @@ -1260,7 +1308,7 @@ new_height, new_width"); return (selected_indices, selected_scores); }); } - + public static Tensor non_max_suppression_with_overlaps(Tensor overlaps, Tensor scores, Tensor max_output_size, float overlap_threshold = 0.5f, float score_threshold = -1f / 0f, string name = null) { @@ -1280,7 +1328,7 @@ new_height, new_width"); {0.114f, -0.32134392f, 0.31119955f}}; Tensor kernel = ops.convert_to_tensor(_rgb_to_yiq_kernel, dtype: images.dtype, name: "kernel"); var ndims = images.TensorShape.ndim; - return math_ops.tensordot(images, kernel, axes: new int[] {ndims - 1, 0}); + return math_ops.tensordot(images, kernel, axes: new int[] { ndims - 1, 0 }); } public static Tensor yiq_to_rgb(Tensor images) @@ -1291,7 +1339,7 @@ new_height, new_width"); {0.6208248f, -0.64720424f, 1.70423049f}}; Tensor kernel = ops.convert_to_tensor(_yiq_to_rgb_kernel, dtype: images.dtype, name: "kernel"); var ndims = images.TensorShape.ndim; - return math_ops.tensordot(images, kernel, axes: new int[] {ndims - 1, 0}); + return math_ops.tensordot(images, kernel, axes: new int[] { ndims - 1, 0 }); } public static Tensor rgb_to_yuv(Tensor images) @@ -1302,7 +1350,7 @@ new_height, new_width"); {0.114f, 0.43601035f, -0.10001026f}}; Tensor kernel = ops.convert_to_tensor(_rgb_to_yuv_kernel, dtype: images.dtype, name: "kernel"); var ndims = images.TensorShape.ndim; - return math_ops.tensordot(images, kernel, axes: new int[] {ndims - 1, 0}); + return math_ops.tensordot(images, kernel, axes: new int[] { ndims - 1, 0 }); } public static Tensor yuv_to_rgb(Tensor images) @@ -1313,20 +1361,20 @@ new_height, new_width"); {1.13988303f, -0.58062185f, 0f}}; Tensor kernel = ops.convert_to_tensor(_yuv_to_rgb_kernel, dtype: images.dtype, name: "kernel"); var ndims = images.TensorShape.ndim; - return math_ops.tensordot(images, kernel, axes: new int[] {ndims - 1, 0}); + return math_ops.tensordot(images, kernel, axes: new int[] { ndims - 1, 0 }); } internal static (Tensor, Tensor, Operation[]) _verify_compatible_image_shapes(Tensor img1, Tensor img2) { TensorShape shape1 = img1.TensorShape.with_rank_at_least(3); TensorShape shape2 = img2.TensorShape.with_rank_at_least(3); - shape1 = new TensorShape(shape1.dims.Skip(shape1.dims.Length - 3).Take(shape1.dims.Length - (shape1.dims.Length -3)).ToArray()); + shape1 = new TensorShape(shape1.dims.Skip(shape1.dims.Length - 3).Take(shape1.dims.Length - (shape1.dims.Length - 3)).ToArray()); tensor_shape.assert_is_compatible_with(self: new Tensor(shape1), other: new Tensor(shape2.dims.Skip(shape2.dims.Length - 3).Take(shape2.dims.Length - (shape2.dims.Length - 3)).ToArray())); - + if (shape1.ndim != -1 && shape2.ndim != -1) { - var shape1_temp = shape1.dims.Skip(shape1.dims.Length - 3).Take(shape1.dims.Length - (shape1.dims.Length -3)).ToArray(); - var shape2_temp = shape2.dims.Skip(shape2.dims.Length - 3).Take(shape2.dims.Length - (shape1.dims.Length -3)).ToArray(); + var shape1_temp = shape1.dims.Skip(shape1.dims.Length - 3).Take(shape1.dims.Length - (shape1.dims.Length - 3)).ToArray(); + var shape2_temp = shape2.dims.Skip(shape2.dims.Length - 3).Take(shape2.dims.Length - (shape1.dims.Length - 3)).ToArray(); Array.Reverse(shape1_temp); Array.Reverse(shape2_temp); foreach ((int dim1, int dim2) in shape1_temp.Zip(shape2_temp, Tuple.Create)) @@ -1336,42 +1384,42 @@ new_height, new_width"); } } - Tensor shape1_tensor = gen_array_ops.shape_n(new Tensor[] {img1, img2})[0]; - Tensor shape2_tensor = gen_array_ops.shape_n(new Tensor[] {img1, img2})[1]; - Operation[] checks = new Operation[] {}; + Tensor shape1_tensor = gen_array_ops.shape_n(new Tensor[] { img1, img2 })[0]; + Tensor shape2_tensor = gen_array_ops.shape_n(new Tensor[] { img1, img2 })[1]; + Operation[] checks = new Operation[] { }; checks.append( control_flow_ops.Assert( - gen_math_ops.greater_equal(array_ops.size(shape1_tensor), 3), new [] {shape1, shape2}, + gen_math_ops.greater_equal(array_ops.size(shape1_tensor), 3), new[] { shape1, shape2 }, summarize: 10)); checks.append( control_flow_ops.Assert( math_ops.reduce_all(math_ops.equal(shape1_tensor.dims.Skip(shape1_tensor.dims.Length - 3).Take(shape1_tensor.dims.Length - (shape1_tensor.dims.Length - 3)).ToArray(), shape2_tensor.dims.Skip(shape1_tensor.dims.Length - 3).Take(shape1_tensor.dims.Length - (shape1_tensor.dims.Length - 3)))), - new [] {shape1, shape2}, + new[] { shape1, shape2 }, summarize: 10)); return (shape1_tensor, shape2_tensor, checks); - } - + } + public static Tensor psnr(Tensor a, Tensor b, Tensor max_val, string name = null) { - return tf_with(ops.name_scope(name, "PSNR", new [] {a, b}), delegate - { - max_val = math_ops.cast(max_val, a.dtype); - max_val = convert_image_dtype(max_val, dtypes.float32); - a = convert_image_dtype(a, dtypes.float32); - b = convert_image_dtype(b, dtypes.float32); - Tensor mse = math_ops.reduce_mean(gen_math_ops.squared_difference(a, b), new int[] {-3, -2, -1}); - var psnr_val = math_ops.subtract( - (20 * math_ops.log(max_val)) / math_ops.log(ops.convert_to_tensor(10.0)), - math_ops.cast(10 / math_ops.log(ops.convert_to_tensor(10)), dtypes.float32) * math_ops.log(mse), - name: "psnr" ); - - (object _a, object _b, Operation[] checks) = _verify_compatible_image_shapes(a, b); - return tf_with(ops.control_dependencies(checks), delegate - { - return array_ops.identity(psnr_val); - }); - }); + return tf_with(ops.name_scope(name, "PSNR", new[] { a, b }), delegate + { + max_val = math_ops.cast(max_val, a.dtype); + max_val = convert_image_dtype(max_val, dtypes.float32); + a = convert_image_dtype(a, dtypes.float32); + b = convert_image_dtype(b, dtypes.float32); + Tensor mse = math_ops.reduce_mean(gen_math_ops.squared_difference(a, b), new int[] { -3, -2, -1 }); + var psnr_val = math_ops.subtract( + (20 * math_ops.log(max_val)) / math_ops.log(ops.convert_to_tensor(10.0)), + math_ops.cast(10 / math_ops.log(ops.convert_to_tensor(10)), dtypes.float32) * math_ops.log(mse), + name: "psnr"); + + (object _a, object _b, Operation[] checks) = _verify_compatible_image_shapes(a, b); + return tf_with(ops.control_dependencies(checks), delegate + { + return array_ops.identity(psnr_val); + }); + }); } internal static (Tensor, Tensor) _ssim_helper(Tensor x, Tensor y, Func reducer, float max_val, @@ -1405,13 +1453,13 @@ new_height, new_width"); var g = math_ops.square(coords); g = g * -0.5 / math_ops.square(sigma); - g = array_ops.reshape(g, shape: new int[] {1, -1}) + array_ops.reshape(g, shape: new int[] {-1, 1}); - g = array_ops.reshape(g, shape: new int[] {1, -1}); + g = array_ops.reshape(g, shape: new int[] { 1, -1 }) + array_ops.reshape(g, shape: new int[] { -1, 1 }); + g = array_ops.reshape(g, shape: new int[] { 1, -1 }); g = nn_ops.softmax(g); // shape takes an int, python code passes size, a Tensor. NDims is the only int type // i could think of a Tensor having. it might be incorrect tho, so keep that in mind. - return array_ops.reshape(g, shape: new int[] {size.NDims, size.NDims, 1, 1}); + return array_ops.reshape(g, shape: new int[] { size.NDims, size.NDims, 1, 1 }); } internal static (Tensor, Tensor) _ssim_per_channel(Tensor img1, Tensor img2, float max_val = 1f, @@ -1420,8 +1468,8 @@ new_height, new_width"); Tensor filter_size_tensor = constant_op.constant(filter_size, dtype: dtypes.int32); Tensor filter_sigma_tensor = constant_op.constant(filter_sigma, dtype: img1.dtype); - Tensor shape1_tensor = gen_array_ops.shape_n(new Tensor[] {img1, img2})[0]; - Tensor shape2_tensor = gen_array_ops.shape_n(new Tensor[] {img1, img2})[1]; + Tensor shape1_tensor = gen_array_ops.shape_n(new Tensor[] { img1, img2 })[0]; + Tensor shape2_tensor = gen_array_ops.shape_n(new Tensor[] { img1, img2 })[1]; Operation[] checks = new Operation[] { control_flow_ops.Assert( math_ops.reduce_all( @@ -1439,22 +1487,22 @@ new_height, new_width"); img1 = array_ops.identity(img1); var kernel = _fspecial_gauss(filter_size_tensor, filter_sigma_tensor); - kernel = array_ops.tile(kernel, multiples: new Tensor(new int[] {1, 1, shape1_tensor.dims[shape1_tensor.dims.Length - 2], 1})); + kernel = array_ops.tile(kernel, multiples: new Tensor(new int[] { 1, 1, shape1_tensor.dims[shape1_tensor.dims.Length - 2], 1 })); float compensation = 1.0f; Tensor reducer(Tensor x) { var shape = array_ops.shape(x); - x = array_ops.reshape(x, shape: array_ops.concat(new Tensor[] {new Tensor(-1), new Tensor(shape1_tensor.dims.Skip(shape1_tensor.dims.Length - 3).Take(shape1_tensor.dims.Length - (shape1_tensor.dims.Length - 3 - 1)).ToArray())}, 0)); - var y = gen_ops.depthwise_conv2d_native(x, kernel, strides: new int[] {1, 1, 1, 1}, padding: "VALID"); + x = array_ops.reshape(x, shape: array_ops.concat(new Tensor[] { new Tensor(-1), new Tensor(shape1_tensor.dims.Skip(shape1_tensor.dims.Length - 3).Take(shape1_tensor.dims.Length - (shape1_tensor.dims.Length - 3 - 1)).ToArray()) }, 0)); + var y = gen_ops.depthwise_conv2d_native(x, kernel, strides: new int[] { 1, 1, 1, 1 }, padding: "VALID"); return array_ops.reshape( - y, array_ops.concat(new Tensor[] {new Tensor(shape.dims.Take(shape.dims.Length - 3).ToArray()), new Tensor(array_ops.shape(y).dims.Skip(1).Take(array_ops.shape(y).dims.Length - 2).ToArray())}, 0)); + y, array_ops.concat(new Tensor[] { new Tensor(shape.dims.Take(shape.dims.Length - 3).ToArray()), new Tensor(array_ops.shape(y).dims.Skip(1).Take(array_ops.shape(y).dims.Length - 2).ToArray()) }, 0)); } (Tensor luminance, Tensor cs) = _ssim_helper(img1, img2, reducer, max_val, compensation, k1, k2); - var axes = constant_op.constant(new [] {-3, -2}, dtype: dtypes.int32); + var axes = constant_op.constant(new[] { -3, -2 }, dtype: dtypes.int32); var ssim_val = math_ops.reduce_mean(luminance * cs, axes.dims); cs = math_ops.reduce_mean(cs, axes.dims); return (ssim_val, cs); @@ -1463,162 +1511,162 @@ new_height, new_width"); public static Tensor ssim(Tensor img1, Tensor img2, float max_val = 1f, float filter_size = 11f, float filter_sigma = 1.5f, float k1 = 0.01f, float k2 = 0.03f) { - return tf_with(ops.name_scope(null, "SSIM", new [] {img1, img2}), delegate - { - img1 = ops.convert_to_tensor(img1, name: "img1"); - img2 = ops.convert_to_tensor(img2, name: "img2"); + return tf_with(ops.name_scope(null, "SSIM", new[] { img1, img2 }), delegate + { + img1 = ops.convert_to_tensor(img1, name: "img1"); + img2 = ops.convert_to_tensor(img2, name: "img2"); - (Tensor _, Tensor __, Operation[] checks) = _verify_compatible_image_shapes(img1, img2); - using (ops.control_dependencies(checks)) - img1 = array_ops.identity(img1); + (Tensor _, Tensor __, Operation[] checks) = _verify_compatible_image_shapes(img1, img2); + using (ops.control_dependencies(checks)) + img1 = array_ops.identity(img1); - Tensor max_val_tensor = math_ops.cast(max_val, img1.dtype); - max_val_tensor = convert_image_dtype(max_val_tensor, dtypes.float32); - img1 = convert_image_dtype(img1, dtypes.float32); - img2 = convert_image_dtype(img2, dtypes.float32); - (Tensor ssim_per_channel, Tensor ___) = _ssim_per_channel(img1, img2, max_val, filter_size, - filter_sigma, k1, k2); + Tensor max_val_tensor = math_ops.cast(max_val, img1.dtype); + max_val_tensor = convert_image_dtype(max_val_tensor, dtypes.float32); + img1 = convert_image_dtype(img1, dtypes.float32); + img2 = convert_image_dtype(img2, dtypes.float32); + (Tensor ssim_per_channel, Tensor ___) = _ssim_per_channel(img1, img2, max_val, filter_size, + filter_sigma, k1, k2); - return math_ops.reduce_mean(ssim_per_channel, new int[] {-1}); - }); + return math_ops.reduce_mean(ssim_per_channel, new int[] { -1 }); + }); } public static Tensor ssim_multiscale(Tensor img1, Tensor img2, float max_val, float[] power_factors = null, float filter_size = 11f, float filter_sigma = 1.5f, float k1 = 0.01f, float k2 = 0.03f) { if (power_factors == null) - power_factors = new float[] {0.0448f, 0.2856f, 0.3001f, 0.2363f, 0.1333f}; - - return tf_with(ops.name_scope(null, "MS-SSIM", new [] {img1, img2}), delegate - { - img1 = ops.convert_to_tensor(img1, name: "img1"); - img2 = ops.convert_to_tensor(img2, name: "img2"); - - (Tensor shape1, Tensor shape2, Operation[] checks) = _verify_compatible_image_shapes(img1, img2); - using (ops.control_dependencies(checks)) - img1 = array_ops.identity(img1); - - Tensor max_val_tensor = math_ops.cast(max_val, img1.dtype); - max_val_tensor = convert_image_dtype(max_val_tensor, dtypes.float32); - img1 = convert_image_dtype(img1, dtypes.float32); - img2 = convert_image_dtype(img2, dtypes.float32); - - var imgs = new [] {img1, img2}; - var shapes = new [] {shape1, shape2}; - - Tensor[] heads = new Tensor[] {}; - Tensor[] tails = new Tensor[] {}; - foreach (Tensor s in shapes) - { - heads[heads.Length] = new Tensor(s.dims.Take(s.dims.Length - 3).ToArray()); - tails[tails.Length] = new Tensor(s.dims.Skip(s.dims.Length - 3).Take(s.dims.Length - (s.dims.Length - 3)).ToArray()); - } + power_factors = new float[] { 0.0448f, 0.2856f, 0.3001f, 0.2363f, 0.1333f }; + + return tf_with(ops.name_scope(null, "MS-SSIM", new[] { img1, img2 }), delegate + { + img1 = ops.convert_to_tensor(img1, name: "img1"); + img2 = ops.convert_to_tensor(img2, name: "img2"); + + (Tensor shape1, Tensor shape2, Operation[] checks) = _verify_compatible_image_shapes(img1, img2); + using (ops.control_dependencies(checks)) + img1 = array_ops.identity(img1); + + Tensor max_val_tensor = math_ops.cast(max_val, img1.dtype); + max_val_tensor = convert_image_dtype(max_val_tensor, dtypes.float32); + img1 = convert_image_dtype(img1, dtypes.float32); + img2 = convert_image_dtype(img2, dtypes.float32); + + var imgs = new[] { img1, img2 }; + var shapes = new[] { shape1, shape2 }; + + Tensor[] heads = new Tensor[] { }; + Tensor[] tails = new Tensor[] { }; + foreach (Tensor s in shapes) + { + heads[heads.Length] = new Tensor(s.dims.Take(s.dims.Length - 3).ToArray()); + tails[tails.Length] = new Tensor(s.dims.Skip(s.dims.Length - 3).Take(s.dims.Length - (s.dims.Length - 3)).ToArray()); + } + + var divisor = new[] { 1, 2, 2, 1 }; + var divisor_tensor = constant_op.constant(divisor.Skip(1).Take(divisor.Length - 1).ToArray(), dtype: dtypes.int32); + + Tensor[] do_pad(Tensor[] images, Tensor remainder) + { + var padding = array_ops.expand_dims(remainder, -1); + padding = array_ops.pad(padding, new Tensor(new int[,] { { 1, 0 }, { 1, 0 } })); + + Tensor[] x_arr = new Tensor[] { }; + foreach (Tensor x in images) + { + x_arr[x_arr.Length] = array_ops.pad(x, padding, mode: "SYMMETRIC"); + } + return x_arr; + } + + var mcs = new Tensor[] { }; + var ssim_per_channel = new Tensor(new int[] { }); + var cs = ssim_per_channel; + foreach (var k in range(0, len(power_factors))) + { + using (ops.name_scope(null, String.Format("Scale{0}", k), imgs)) + { + if (k > 0) + { + // handle flat_imgs + Tensor[] flat_imgs = new Tensor[] { }; + foreach ((Tensor x, Tensor t) in imgs.Zip(tails, Tuple.Create)) + { + flat_imgs[flat_imgs.Length] = array_ops.reshape(x, array_ops.concat(new Tensor[] { constant_op.constant(-1), t }, 0)); + } - var divisor = new [] {1, 2, 2, 1}; - var divisor_tensor = constant_op.constant(divisor.Skip(1).Take(divisor.Length - 1).ToArray(), dtype: dtypes.int32); + var remainder = tails[0] % divisor_tensor; + var need_padding = math_ops.reduce_any(math_ops.not_equal(remainder, 0)); - Tensor[] do_pad(Tensor[] images, Tensor remainder) - { - var padding = array_ops.expand_dims(remainder, -1); - padding = array_ops.pad(padding, new Tensor(new int[,] { {1, 0}, {1, 0}})); - - Tensor[] x_arr = new Tensor[] {}; - foreach (Tensor x in images) - { - x_arr[x_arr.Length] = array_ops.pad(x, padding, mode: "SYMMETRIC"); - } - return x_arr; - } + Tensor[] padded_func_pass() { return do_pad(flat_imgs, remainder); } + var padded = control_flow_ops.cond(need_padding, + true_fn: () => padded_func_pass(), + false_fn: () => flat_imgs); - var mcs = new Tensor[] {}; - var ssim_per_channel = new Tensor(new int[] {}); - var cs = ssim_per_channel; - foreach (var k in range(0, len(power_factors))) - { - using(ops.name_scope(null, String.Format("Scale{0}", k), imgs)) - { - if (k > 0) - { - // handle flat_imgs - Tensor[] flat_imgs = new Tensor[] {}; - foreach ((Tensor x, Tensor t) in imgs.Zip(tails, Tuple.Create)) - { - flat_imgs[flat_imgs.Length] = array_ops.reshape(x, array_ops.concat(new Tensor[] {constant_op.constant(-1), t}, 0)); - } - - var remainder = tails[0] % divisor_tensor; - var need_padding = math_ops.reduce_any(math_ops.not_equal(remainder, 0)); - - Tensor[] padded_func_pass() {return do_pad(flat_imgs, remainder);} - var padded = control_flow_ops.cond(need_padding, - true_fn: () => padded_func_pass(), - false_fn: () => flat_imgs); - // handle downscaled - Tensor[] downscaled = new Tensor[] {}; - foreach (Tensor x in padded) - { - downscaled[downscaled.Length] = gen_ops.avg_pool(x, ksize: divisor, strides: divisor, padding: "VALID"); - } + Tensor[] downscaled = new Tensor[] { }; + foreach (Tensor x in padded) + { + downscaled[downscaled.Length] = gen_ops.avg_pool(x, ksize: divisor, strides: divisor, padding: "VALID"); + } // handle tails - tails = new Tensor[] {}; - foreach (Tensor x in gen_array_ops.shape_n(downscaled)) - { - tails[tails.Length] = new Tensor(x.dims.Skip(1).Take(tails.Length - 1).ToArray()); - } + tails = new Tensor[] { }; + foreach (Tensor x in gen_array_ops.shape_n(downscaled)) + { + tails[tails.Length] = new Tensor(x.dims.Skip(1).Take(tails.Length - 1).ToArray()); + } - imgs = new Tensor[] {}; + imgs = new Tensor[] { }; // tuples weren't working; this is hacky, but should work similarly. // zip loads the values into a tuple (Tensor, Tensor, Tensor) for each // zip entry; this just gets the length of the longest array, and loops // that many times, getting values (like zip) and using them similarly. for (int x = 0; x < Math.Max(Math.Max(downscaled.Length, heads.Length), tails.Length); x++) - { - imgs[imgs.Length] = array_ops.reshape(downscaled[x], array_ops.concat(new Tensor[] {heads[x], tails[x]}, 0)); - } - } - } + { + imgs[imgs.Length] = array_ops.reshape(downscaled[x], array_ops.concat(new Tensor[] { heads[x], tails[x] }, 0)); + } + } + } // python code uses * to unpack imgs; how to replicate that here? // don't think that this is doing the same thing as the python code. (ssim_per_channel, cs) = _ssim_per_channel( - img1: imgs[0], - img2: imgs[1], - max_val: max_val, - filter_size: filter_size, - filter_sigma: filter_sigma, - k1: k1, - k2: k2); - mcs.append(gen_nn_ops.relu(cs)); - } - - mcs = mcs.Skip(1).ToArray(); - var mcs_and_ssim = array_ops.stack( - math_ops.add(mcs, new [] {gen_nn_ops.relu(ssim_per_channel)}), axis: -1); - var ms_ssim = math_ops.reduce_prod( - math_ops.pow(mcs_and_ssim, power_factors), new int[] {-1}); - - return math_ops.reduce_mean(ms_ssim, new int[] {-1}); - }); + img1: imgs[0], + img2: imgs[1], + max_val: max_val, + filter_size: filter_size, + filter_sigma: filter_sigma, + k1: k1, + k2: k2); + mcs.append(gen_nn_ops.relu(cs)); + } + + mcs = mcs.Skip(1).ToArray(); + var mcs_and_ssim = array_ops.stack( + math_ops.add(mcs, new[] { gen_nn_ops.relu(ssim_per_channel) }), axis: -1); + var ms_ssim = math_ops.reduce_prod( + math_ops.pow(mcs_and_ssim, power_factors), new int[] { -1 }); + + return math_ops.reduce_mean(ms_ssim, new int[] { -1 }); + }); } public static (Tensor, Tensor) image_gradients(Tensor image) { if (image.TensorShape.ndim != 4) throw new ValueError(String.Format(@"image_gradients expects a 4D tensor [batch_size, h, w, d], not {0}.", image.shape)); - + var image_shape = array_ops.shape(image); var bs_h_w_d = array_ops.unstack(image_shape); Tensor dy; //= image[:, 1:, :, :] - image[:, :-1, :, :]; - Tensor dx = new Tensor(new int[] {}); //= image[:, :, 1:, :] - image[:, :, :-1, :]; + Tensor dx = new Tensor(new int[] { }); //= image[:, :, 1:, :] - image[:, :, :-1, :]; - var shape = array_ops.stack(new Tensor[] {bs_h_w_d[0], constant_op.constant(1), bs_h_w_d[2], bs_h_w_d[3]}); - dy = array_ops.concat(new Tensor[] {dx, array_ops.zeros(shape, image.dtype)}, 2); + var shape = array_ops.stack(new Tensor[] { bs_h_w_d[0], constant_op.constant(1), bs_h_w_d[2], bs_h_w_d[3] }); + dy = array_ops.concat(new Tensor[] { dx, array_ops.zeros(shape, image.dtype) }, 2); dy = array_ops.reshape(dy, image_shape); - shape = array_ops.stack(new Tensor[] {bs_h_w_d[0], bs_h_w_d[1], constant_op.constant(1), bs_h_w_d[3]}); - dx = array_ops.concat(new Tensor[] {dx, array_ops.zeros(shape, image.dtype)}, 2); + shape = array_ops.stack(new Tensor[] { bs_h_w_d[0], bs_h_w_d[1], constant_op.constant(1), bs_h_w_d[3] }); + dx = array_ops.concat(new Tensor[] { dx, array_ops.zeros(shape, image.dtype) }, 2); dx = array_ops.reshape(dx, image_shape); return (dx, dy); @@ -1637,17 +1685,17 @@ new_height, new_width"); var kernels_tf = constant_op.constant(kernels, dtype: image.dtype); kernels_tf = array_ops.tile( - kernels_tf, new Tensor(new int[] {1, 1, image_shape.dims[image_shape.dims.Length - 2], 1}), name: "sobel_filters"); + kernels_tf, new Tensor(new int[] { 1, 1, image_shape.dims[image_shape.dims.Length - 2], 1 }), name: "sobel_filters"); - var pad_sizes = new int[,] { {0, 0}, {1, 1}, {1, 1}, {0, 0}}; + var pad_sizes = new int[,] { { 0, 0 }, { 1, 1 }, { 1, 1 }, { 0, 0 } }; var padded = array_ops.pad(image, new Tensor(pad_sizes), mode: "reflect"); - var strides = new int[] {1, 1, 1, 1}; + var strides = new int[] { 1, 1, 1, 1 }; var output = gen_ops.depthwise_conv2d_native(padded, kernels_tf, strides, "VALID"); - var shape = array_ops.concat(new Tensor[] {image_shape, ops.convert_to_tensor(num_kernels)}, 0); + var shape = array_ops.concat(new Tensor[] { image_shape, ops.convert_to_tensor(num_kernels) }, 0); output = array_ops.reshape(output, shape: shape); - output.set_shape(static_image_shape.concatenate(new int[] {num_kernels})); + output.set_shape(static_image_shape.concatenate(new int[] { num_kernels })); return output; } @@ -1724,7 +1772,7 @@ new_height, new_width"); return control_flow_ops.cond(is_jpeg(contents), _jpeg, check_png, name: "cond_jpeg"); }); } - + public static Tensor crop_and_resize(Tensor image, Tensor boxes, Tensor box_ind, Tensor crop_size, string method, float extrapolation_value, string name) { var _op = tf.OpDefLib._apply_op_helper("CropAndResize", name: name, args: new @@ -1764,7 +1812,7 @@ new_height, new_width"); Tensor score_threshold_tensor = ops.convert_to_tensor( score_threshold, dtype: dtypes.float32, name: "score_threshold"); return gen_image_ops.combined_non_max_suppression( - boxes, scores, max_output_size_per_class, max_total_size, iou_threshold_tensor, + boxes, scores, max_output_size_per_class, max_total_size, iou_threshold_tensor, score_threshold_tensor, pad_per_class, clip_boxes); }); } @@ -1773,11 +1821,11 @@ new_height, new_width"); { var batch_size = array_ops.shape(boxes)[0]; var new_slice = array_ops.slice( - boxes, new object[] {0, inner_idx * tile_size, 0}, - new object[] {batch_size, tile_size, 4}); + boxes, new object[] { 0, inner_idx * tile_size, 0 }, + new object[] { batch_size, tile_size, 4 }); var iou = _bbox_overlap(new_slice, box_slice); var box_slice_after_suppression = array_ops.expand_dims( - math_ops.cast(math_ops.reduce_all(iou < iou_threshold, new int[] {1}), + math_ops.cast(math_ops.reduce_all(iou < iou_threshold, new int[] { 1 }), box_slice.dtype), 2) * box_slice; return (boxes, box_slice_after_suppression, iou_threshold, inner_idx + 1); @@ -1795,13 +1843,13 @@ new_height, new_width"); value: boxes_b, num_split: 4, axis: 2); var i_xmin = math_ops.maximum( - a_xy_minmax[1], array_ops.transpose(b_xy_minmax[1], new [] {0, 2, 1})); + a_xy_minmax[1], array_ops.transpose(b_xy_minmax[1], new[] { 0, 2, 1 })); var i_xmax = math_ops.minimum( - a_xy_minmax[3], array_ops.transpose(b_xy_minmax[3], new [] {0, 2, 1})); + a_xy_minmax[3], array_ops.transpose(b_xy_minmax[3], new[] { 0, 2, 1 })); var i_ymin = math_ops.maximum( - a_xy_minmax[0], array_ops.transpose(b_xy_minmax[0], new [] {0, 2, 1})); + a_xy_minmax[0], array_ops.transpose(b_xy_minmax[0], new[] { 0, 2, 1 })); var i_ymax = math_ops.minimum( - a_xy_minmax[3], array_ops.transpose(b_xy_minmax[3], new [] {0, 2, 1})); + a_xy_minmax[3], array_ops.transpose(b_xy_minmax[3], new[] { 0, 2, 1 })); var i_area = math_ops.maximum( (i_xmax - i_xmin), 0) * math_ops.maximum((i_ymax - i_ymin), 0); @@ -1809,10 +1857,10 @@ new_height, new_width"); var b_area = (b_xy_minmax[2] - b_xy_minmax[0]) * (b_xy_minmax[3] - b_xy_minmax[1]); double EPSILON = 1e-8; - var u_area = a_area + array_ops.transpose(b_area, new [] {0, 2, 1}) - i_area + EPSILON; + var u_area = a_area + array_ops.transpose(b_area, new[] { 0, 2, 1 }) - i_area + EPSILON; var intersection_over_union = i_area / u_area; - + return intersection_over_union; }); } @@ -1826,41 +1874,41 @@ new_height, new_width"); (Tensor, Tensor, Tensor, Tensor) cross_suppression_func(Tensor boxes, Tensor box_slice, Tensor iou_threshold, Tensor inner_idx, int tile_size) => _cross_suppression(boxes, box_slice, iou_threshold, inner_idx, tile_size); - - var box_slice = array_ops.slice(boxes, new [] {0, idx * tile_size, 0}, - new [] {batch_size, tile_size, 4}); + + var box_slice = array_ops.slice(boxes, new[] { 0, idx * tile_size, 0 }, + new[] { batch_size, tile_size, 4 }); var iou = _bbox_overlap(box_slice, box_slice); var mask = array_ops.expand_dims( array_ops.reshape( - math_ops.range(tile_size), new [] {1, -1}) > array_ops.reshape( - math_ops.range(tile_size), new [] {-1, 1}), 0); + math_ops.range(tile_size), new[] { 1, -1 }) > array_ops.reshape( + math_ops.range(tile_size), new[] { -1, 1 }), 0); iou = iou * math_ops.cast( math_ops.logical_and(mask, iou >= iou_threshold), iou.dtype); - + /* I have no idea what's going on here. Not even going to try to port it yet. var suppressed_iou = control_flow_ops.while_loop( todo ) */ - var suppressed_iou = new Tensor(new int[] {}); + var suppressed_iou = new Tensor(new int[] { }); var suppressed_box = math_ops.reduce_sum(suppressed_iou, 1) > 0; box_slice = box_slice * array_ops.expand_dims( 1.0f - math_ops.cast(suppressed_box, box_slice.dtype), 2); - + mask = array_ops.reshape( math_ops.cast( math_ops.equal(math_ops.range(num_tiles), idx), boxes.dtype), - new [] {1, -1, 1, 1}); + new[] { 1, -1, 1, 1 }); boxes = array_ops.tile(array_ops.expand_dims( - box_slice, 1), ops.convert_to_tensor(new [] {1, num_tiles, 1, 1}) * mask + array_ops.reshape( - boxes, new [] {batch_size, num_tiles, tile_size, 4}) * (1 - mask)); - boxes = array_ops.reshape(boxes, new [] {batch_size, -1, 4}); + box_slice, 1), ops.convert_to_tensor(new[] { 1, num_tiles, 1, 1 }) * mask + array_ops.reshape( + boxes, new[] { batch_size, num_tiles, tile_size, 4 }) * (1 - mask)); + boxes = array_ops.reshape(boxes, new[] { batch_size, -1, 4 }); output_size = output_size + math_ops.reduce_sum( math_ops.cast( - math_ops.reduce_any(box_slice > 0, new int[] {2}), dtypes.int32), new int[] {1}); + math_ops.reduce_any(box_slice > 0, new int[] { 2 }), dtypes.int32), new int[] { 1 }); } return (boxes, iou_threshold, output_size, idx + 1); } @@ -1890,7 +1938,7 @@ new_height, new_width"); // 0, slice(None, num_valid, None) // which is what I tried to replicate below, but i don't think that Unknown is the exact // equivalent to None, and don't know about the slice function bit. - idx = idx[0, slice(Unknown, num_valid.TensorShape.ndim, Unknown).ToArray()[0]]; + idx = idx[0, slice(Unknown, num_valid.TensorShape.ndim, Unknown).ToArray()[0]]; else { var batch_dims = array_ops.concat(new Tensor[] { @@ -1899,8 +1947,8 @@ new_height, new_width"); }, 0); idx = array_ops.reshape(idx, batch_dims); } - return (idx, num_valid); - }); + return (idx, num_valid); + }); } } @@ -1919,13 +1967,13 @@ new_height, new_width"); scores, axis: 1, direction: "DESCENDING); */ index_offsets = math_ops.range(batch_size) * num_boxes; indices = array_ops.reshape( - sorted_scores_indices + array_ops.expand_dims(index_offsets, 1), new [] {-1}); + sorted_scores_indices + array_ops.expand_dims(index_offsets, 1), new[] { -1 }); sorted_scores = array_ops.reshape( - array_ops.gather(array_ops.reshape(boxes, new [] {-1, 4}), indices), - new [] {batch_size, -1}); + array_ops.gather(array_ops.reshape(boxes, new[] { -1, 4 }), indices), + new[] { batch_size, -1 }); sorted_boxes = array_ops.reshape( - array_ops.gather(array_ops.reshape(boxes, new [] {-1, 4}), indices), - new [] {batch_size, -1, 4}); + array_ops.gather(array_ops.reshape(boxes, new[] { -1, 4 }), indices), + new[] { batch_size, -1, 4 }); }; return (sorted_scores, sorted_boxes, sorted_scores_indices); @@ -1933,12 +1981,12 @@ new_height, new_width"); var batch_dims = array_ops.shape(boxes).dims.Take(boxes.TensorShape.dims.Length - 2).ToArray(); var num_boxes = array_ops.shape(boxes).dims[boxes.TensorShape.dims.Length - 2]; - boxes = array_ops.reshape(boxes, new [] {-1, num_boxes, 4}); - scores = array_ops.reshape(scores, new [] {-1, num_boxes}); + boxes = array_ops.reshape(boxes, new[] { -1, num_boxes, 4 }); + scores = array_ops.reshape(scores, new[] { -1, num_boxes }); var batch_size = array_ops.shape(boxes).dims[0]; - + // initialization for later - Tensor sorted_indices; + Tensor sorted_indices; if (score_threshold != -1f / 0f) using (ops.name_scope("filter_by_score")) @@ -1963,7 +2011,7 @@ new_height, new_width"); gen_math_ops.less_equal(yx[1][0, 0, 0], yx[3][0, 0, 0])); var x_minmax = control_flow_ops.cond( x_1_is_min, true_fn: () => yx[1] /*yx[3]*/, false_fn: () => yx[3] /*yx[1]*/); - boxes = array_ops.concat(new Tensor[] {y_minmax, x_minmax}, axis: 2); + boxes = array_ops.concat(new Tensor[] { y_minmax, x_minmax }, axis: 2); } if (!sorted_input) @@ -1978,12 +2026,12 @@ new_height, new_width"); math_ops.cast(tile_size, dtypes.float32)), dtypes.int32) * tile_size - num_boxes; boxes = array_ops.pad( - math_ops.cast(scores, dtypes.float32), ops.convert_to_tensor(new object[,] { {0, 0}, {0, pad}, {0, 0}})); + math_ops.cast(scores, dtypes.float32), ops.convert_to_tensor(new object[,] { { 0, 0 }, { 0, pad }, { 0, 0 } })); scores = array_ops.pad( - math_ops.cast(scores, dtypes.float32), ops.convert_to_tensor(new object[,] { {0, 0}, {0, pad}})); + math_ops.cast(scores, dtypes.float32), ops.convert_to_tensor(new object[,] { { 0, 0 }, { 0, pad } })); var num_boxes_after_padding = num_boxes + pad; var num_iterations = math_ops.floordiv(num_boxes_after_padding, ops.convert_to_tensor(tile_size)); - + // Tensor unused_boxes, Tensor unused_threshold, Tensor output_size, Tensor idx go into args Tensor _loop_cond(object[] args) => /*new object[] {*/math_ops.logical_and( @@ -1994,7 +2042,7 @@ new_height, new_width"); object[] suppression_loop_body(object[] args) { (Tensor a, float b, Tensor c, int d) = _suppression_loop_body((Tensor)args[0], (float)args[1], (Tensor)args[2], (int)args[3], tile_size); - return new object[] {a, b, c, d}; + return new object[] { a, b, c, d }; } object[] selboxes__output_size_ = null; @@ -2018,10 +2066,10 @@ new_height, new_width"); ); */ var num_valid = math_ops.minimum(selboxes__output_size_[2], max_output_size); - + (Tensor values, Tensor indices) = gen_ops.top_k_v2( math_ops.cast(math_ops.reduce_any( - (Tensor)selboxes__output_size_[0] > 0, new int[] {2}), dtypes.int32) * + (Tensor)selboxes__output_size_[0] > 0, new int[] { 2 }), dtypes.int32) * array_ops.expand_dims( math_ops.range(num_boxes_after_padding, 0, -1), 0), max_output_size); @@ -2032,13 +2080,13 @@ new_height, new_width"); { var index_offsets = math_ops.range(batch_size) * num_boxes; var gather_idx = array_ops.reshape( - idx + array_ops.expand_dims(index_offsets, 1), new [] {-1}); + idx + array_ops.expand_dims(index_offsets, 1), new[] { -1 }); idx = array_ops.reshape( - array_ops.gather(array_ops.reshape(sorted_indices, new [] {-1}), + array_ops.gather(array_ops.reshape(sorted_indices, new[] { -1 }), gather_idx), - new [] {batch_size, -1}); + new[] { batch_size, -1 }); } - var invalid_index = array_ops.fill(ops.convert_to_tensor(new object[] {batch_size, max_output_size}), + var invalid_index = array_ops.fill(ops.convert_to_tensor(new object[] { batch_size, max_output_size }), tf.constant(0)); var idx_index = array_ops.expand_dims(math_ops.range(max_output_size), 0); var num_valid_expanded = array_ops.expand_dims(num_valid, 1); @@ -2090,7 +2138,7 @@ new_height, new_width"); }); } - public static Tensor convert_image_dtype(Tensor image, TF_DataType dtype, bool saturate = false, + public static Tensor convert_image_dtype(Tensor image, TF_DataType dtype, bool saturate = false, string name = null) { image = ops.convert_to_tensor(image, name: "image"); @@ -2103,50 +2151,53 @@ new_height, new_width"); // declarations for later Tensor cast; - return tf_with(ops.name_scope(name, "convert_image", new [] {image}), name => - { - if (image.dtype.is_integer() && dtype.is_integer()) - { - var scale_in = image.dtype.max(); - var scale_out = dtype.max(); - if (scale_in > scale_out) - { - var scale = Math.Floor((decimal)(scale_in + 1) / (scale_out + 1)); - var scaled = math_ops.floordiv(image, ops.convert_to_tensor(scale)); - - if (saturate) - return math_ops.saturate_cast(scaled, dtype, name: name); - else - return math_ops.cast(scaled, dtype, name: name); - } else - { - if (saturate) - cast = math_ops.saturate_cast(image, dtype); - else - cast = math_ops.cast(image, dtype); - var scale = Math.Floor((decimal)(scale_in + 1) / (scale_out + 1)); - return math_ops.multiply(cast, scale, name: name); - } - } else if (image.dtype.is_floating() && dtype.is_floating()) - return math_ops.cast(image, dtype, name: name); - else - { - if (image.dtype.is_integer()) - { - cast = math_ops.cast(image, dtype); - var scale = 1 / image.dtype.max(); - return math_ops.multiply(cast, scale, name: name); - } else - { - var scale = dtype.max() + 0.5; - var scaled = math_ops.multiply(image, scale); - if (saturate) - return math_ops.saturate_cast(scaled, dtype, name: name); - else - return math_ops.cast(scaled, dtype, name: name); - } - } - }); + return tf_with(ops.name_scope(name, "convert_image", new[] { image }), name => + { + if (image.dtype.is_integer() && dtype.is_integer()) + { + var scale_in = image.dtype.max(); + var scale_out = dtype.max(); + if (scale_in > scale_out) + { + var scale = Math.Floor((decimal)(scale_in + 1) / (scale_out + 1)); + var scaled = math_ops.floordiv(image, ops.convert_to_tensor(scale)); + + if (saturate) + return math_ops.saturate_cast(scaled, dtype, name: name); + else + return math_ops.cast(scaled, dtype, name: name); + } + else + { + if (saturate) + cast = math_ops.saturate_cast(image, dtype); + else + cast = math_ops.cast(image, dtype); + var scale = Math.Floor((decimal)(scale_in + 1) / (scale_out + 1)); + return math_ops.multiply(cast, scale, name: name); + } + } + else if (image.dtype.is_floating() && dtype.is_floating()) + return math_ops.cast(image, dtype, name: name); + else + { + if (image.dtype.is_integer()) + { + cast = math_ops.cast(image, dtype); + var scale = 1 / image.dtype.max(); + return math_ops.multiply(cast, scale, name: name); + } + else + { + var scale = dtype.max() + 0.5; + var scaled = math_ops.multiply(image, scale); + if (saturate) + return math_ops.saturate_cast(scaled, dtype, name: name); + else + return math_ops.cast(scaled, dtype, name: name); + } + } + }); } /// @@ -2188,7 +2239,7 @@ new_height, new_width"); /// /// /// - public static Tensor resize_nearest_neighbor(Tensor images, Tsize size, bool align_corners = false, + public static Tensor resize_nearest_neighbor(Tensor images, Tsize size, bool align_corners = false, string name = null, bool half_pixel_centers = false) => gen_image_ops.resize_nearest_neighbor(images: images, size: size, diff --git a/src/TensorFlowNET.Core/Operations/io_ops.cs b/src/TensorFlowNET.Core/Operations/io_ops.cs index de6f9234..4f276e36 100644 --- a/src/TensorFlowNET.Core/Operations/io_ops.cs +++ b/src/TensorFlowNET.Core/Operations/io_ops.cs @@ -15,7 +15,6 @@ ******************************************************************************/ using Tensorflow.Contexts; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Operations/linalg_ops.cs b/src/TensorFlowNET.Core/Operations/linalg_ops.cs index cbbe262a..bebea29c 100644 --- a/src/TensorFlowNET.Core/Operations/linalg_ops.cs +++ b/src/TensorFlowNET.Core/Operations/linalg_ops.cs @@ -1,15 +1,12 @@ -using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; +using System; using static Tensorflow.Binding; namespace Tensorflow { public class linalg_ops { - public Tensor eye(int num_rows, - int num_columns = -1, + public Tensor eye(int num_rows, + int num_columns = -1, TensorShape batch_shape = null, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) diff --git a/src/TensorFlowNET.Core/Operations/map_fn.cs b/src/TensorFlowNET.Core/Operations/map_fn.cs index 10e65602..3cf671fb 100644 --- a/src/TensorFlowNET.Core/Operations/map_fn.cs +++ b/src/TensorFlowNET.Core/Operations/map_fn.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using NumSharp; using Tensorflow.Framework; -using Tensorflow.Operations; using Tensorflow.Util; using static Tensorflow.Binding; @@ -26,7 +23,7 @@ namespace Tensorflow /// /// /// A tensor or (possibly nested) sequence of tensors. - public static Tensor map_fn(Func fn, + public static Tensor map_fn(Func fn, Tensor elems, TF_DataType dtype = TF_DataType.DtInvalid, int parallel_iterations = 10, @@ -36,7 +33,7 @@ namespace Tensorflow string name = null) { bool input_is_sequence = nest.is_sequence(elems); - Tensor[] input_flatten(Tensor x) => input_is_sequence ? nest.flatten(x).ToArray() : new [] {x}; + Tensor[] input_flatten(Tensor x) => input_is_sequence ? nest.flatten(x).ToArray() : new[] { x }; Tensor input_pack(Tensor[] x) => input_is_sequence ? (Tensor)nest.pack_sequence_as(elems, x) : x[0]; bool output_is_sequence; @@ -51,7 +48,7 @@ namespace Tensorflow else { output_is_sequence = nest.is_sequence(dtype); - output_flatten = (x) => output_is_sequence ? nest.flatten(x).ToArray() : new [] {x}; + output_flatten = (x) => output_is_sequence ? nest.flatten(x).ToArray() : new[] { x }; output_pack = (x) => output_is_sequence ? (Tensor)nest.pack_sequence_as(dtype, x) : x[0]; } @@ -103,11 +100,11 @@ namespace Tensorflow BodyItem compute(BodyItem item) { - var packed_values = input_pack(elems_ta.Select(elem_ta => elem_ta.read(item.I)).ToArray()); + var packed_values = input_pack(elems_ta.Select(elem_ta => elem_ta.read(item.I)).ToArray()); var packed_fn_values = fn(packed_values); //nest.assert_same_structure(dtype or elems, packed_fn_values) - var flat_fn_values = output_flatten(packed_fn_values); + var flat_fn_values = output_flatten(packed_fn_values); for (int j = 0; j < item.Accs_ta.Length; j++) { item.Accs_ta[j].write(item.I, flat_fn_values[j]); @@ -117,8 +114,8 @@ namespace Tensorflow } var r_a = control_flow_ops.while_loop( - (x) => x.I < n, - compute, + (x) => x.I < n, + compute, new BodyItem(i, accs_ta), parallel_iterations: parallel_iterations, back_prop: back_prop, @@ -127,7 +124,7 @@ namespace Tensorflow var results_flat = r_a.Accs_ta.Select(r => r.stack()).ToArray(); var n_static = new Dimension(tensor_shape.dimension_value(elems_flat[0].TensorShape.with_rank_at_least(1).dims[0])); - + foreach (var elem in elems_flat.Skip(1)) { n_static.merge_with(new Dimension(tensor_shape.dimension_value(elem.TensorShape.with_rank_at_least(1).dims[0]))); @@ -172,15 +169,15 @@ namespace Tensorflow public BodyItem Pack(object[] sequences) { I = sequences[0] as Tensor; - Accs_ta = new [] { sequences[1] as TensorArray }; - + Accs_ta = new[] { sequences[1] as TensorArray }; + return new BodyItem(I, Accs_ta); } public BodyItem FromMergeVars(ITensorOrTensorArray[] merge_vars) { I = (Tensor)merge_vars[1]; - Accs_ta = new [] {(TensorArray) merge_vars[2]}; + Accs_ta = new[] { (TensorArray)merge_vars[2] }; return this; } } diff --git a/src/TensorFlowNET.Core/Operations/math_ops.cs b/src/TensorFlowNET.Core/Operations/math_ops.cs index 826de98a..e5b29ea2 100644 --- a/src/TensorFlowNET.Core/Operations/math_ops.cs +++ b/src/TensorFlowNET.Core/Operations/math_ops.cs @@ -18,7 +18,6 @@ using NumSharp; using System; using System.Collections.Generic; using System.Linq; -using Tensorflow.Eager; using Tensorflow.Framework; using static Tensorflow.Binding; @@ -68,7 +67,7 @@ namespace Tensorflow return gen_math_ops.add_n(inputs, name: name); } - + public static Tensor round(Tensor x, string name = null) { x = ops.convert_to_tensor(x, name: "x"); @@ -128,23 +127,23 @@ namespace Tensorflow return x; }); } - + public static Tensor saturate_cast(Tensor value, TF_DataType dtype, string name = null) { - return tf_with(ops.name_scope(name, "saturate_cast", new [] {value}), name => - { - value = ops.convert_to_tensor(value, name: "value"); + return tf_with(ops.name_scope(name, "saturate_cast", new[] { value }), name => + { + value = ops.convert_to_tensor(value, name: "value"); // dtype = dtypes.as_dtype(dtype).as_base_dtype(); if (value.dtype.min() < dtype.min()) - value = gen_math_ops.maximum( - value, - ops.convert_to_tensor(dtype.min(), dtype: value.dtype, name: "min")); - if (value.dtype.max() > dtype.max()) - value = gen_math_ops.minimum( - value, - ops.convert_to_tensor(dtype.max(), dtype: value.dtype, name: "max")); - return cast(value, dtype, name: name); - }); + value = gen_math_ops.maximum( + value, + ops.convert_to_tensor(dtype.min(), dtype: value.dtype, name: "min")); + if (value.dtype.max() > dtype.max()) + value = gen_math_ops.minimum( + value, + ops.convert_to_tensor(dtype.max(), dtype: value.dtype, name: "max")); + return cast(value, dtype, name: name); + }); } public static Tensor cast(float x, TF_DataType dtype = TF_DataType.DtInvalid, string name = null) @@ -257,22 +256,23 @@ namespace Tensorflow public static Tensor mul_no_nan(Tx x, Ty y, string name = null) => gen_math_ops.mul_no_nan(x, y, name: name); - + public static Tensor real(Tensor input, string name = null) { - return tf_with(ops.name_scope(name, "Real", new [] {input}), scope => - { + return tf_with(ops.name_scope(name, "Real", new[] { input }), scope => + { // name = scope; input = ops.convert_to_tensor(input, name: "input"); - if (input.dtype.is_complex()) - { - var real_dtype = input.dtype.real_dtype(); - return real(input, name: scope); - } else - { - return input; - } - }); + if (input.dtype.is_complex()) + { + var real_dtype = input.dtype.real_dtype(); + return real(input, name: scope); + } + else + { + return input; + } + }); } /// @@ -346,38 +346,39 @@ namespace Tensorflow name = "reduce_std"; // else {name = name;} - return tf_with(ops.name_scope(name, "reduce_std", new [] {input_tensor}), scope => - { - var variance = reduce_variance(input_tensor, axis: axis, keepdims: keepdims); - return gen_math_ops.sqrt(variance); - }); + return tf_with(ops.name_scope(name, "reduce_std", new[] { input_tensor }), scope => + { + var variance = reduce_variance(input_tensor, axis: axis, keepdims: keepdims); + return gen_math_ops.sqrt(variance); + }); } - + public static Tensor reduce_variance(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null) { if (name == null) name = "reduce_variance"; // else {name = name;} - return tf_with(ops.name_scope(name, "reduce_variance", new [] {input_tensor}), scope => - { - var means = reduce_mean(input_tensor, axis: axis, keepdims: true); - if (means.dtype.is_integer()) - throw new TypeError("Input must be either real or complex"); - var diff = input_tensor - means; - - Tensor squared_deviations; - if (diff.dtype.is_complex()) - { - var real_dtype = diff.dtype.real_dtype(); - squared_deviations = real( - gen_math_ops.mul(conj(diff), diff)); - } else - { - squared_deviations = gen_math_ops.square(diff); - } - return reduce_mean(squared_deviations, axis: axis, keepdims: keepdims); - }); + return tf_with(ops.name_scope(name, "reduce_variance", new[] { input_tensor }), scope => + { + var means = reduce_mean(input_tensor, axis: axis, keepdims: true); + if (means.dtype.is_integer()) + throw new TypeError("Input must be either real or complex"); + var diff = input_tensor - means; + + Tensor squared_deviations; + if (diff.dtype.is_complex()) + { + var real_dtype = diff.dtype.real_dtype(); + squared_deviations = real( + gen_math_ops.mul(conj(diff), diff)); + } + else + { + squared_deviations = gen_math_ops.square(diff); + } + return reduce_mean(squared_deviations, axis: axis, keepdims: keepdims); + }); } public static Tensor sigmoid(T x, string name = null) @@ -433,7 +434,7 @@ namespace Tensorflow /// A 1-D Tensor, the output shape as if keepdims were set to True. public static Tensor reduced_shape(Tensor input_shape, Tensor axes) { - if(tf.Context.executing_eagerly()) + if (tf.Context.executing_eagerly()) { var input_shape_val = input_shape.numpy(); foreach (var axes_val in axes.numpy().ToArray()) @@ -564,7 +565,7 @@ namespace Tensorflow /// public static Tensor unsorted_segment_sum(Tensor data, Tensor segment_ids, Tensor num_segments, string name = null) => gen_math_ops.unsorted_segment_sum(data, segment_ids, num_segments, name: name); - + /// /// Casts a tensor to type `int32`. /// @@ -686,7 +687,7 @@ namespace Tensorflow if (rank.HasValue && rank.Value > -1) { - return constant_op.constant(np.arange(rank.Value), TF_DataType.TF_INT32); + return constant_op.constant(np.arange(rank.Value), TF_DataType.TF_INT32); } return range(0, rank, 1); @@ -723,11 +724,11 @@ namespace Tensorflow var _op = tf.OpDefLib._apply_op_helper("Pow", name, args: new { x, y }); return _op.output; - }); + }); public static Tensor range(object start, object limit = null, object delta = null, TF_DataType dtype = TF_DataType.DtInvalid, string name = "range") { - if(limit == null) + if (limit == null) { limit = start; start = 0; @@ -841,7 +842,7 @@ namespace Tensorflow public static Tensor tanh(Tensor x, string name = null) => gen_math_ops.tanh(x, name); - + public static Tensor tensordot(Tensor x, Tensor y, int[] axes, string name = null) { Tensor _tensordot_reshape(Tensor a, int[] axes, bool flipped = false) @@ -849,7 +850,7 @@ namespace Tensorflow if (a.TensorShape.is_fully_defined() && isinstance(axes, (typeof(List), typeof(Tuple)))) { var shape_a = a.TensorShape.as_list(); - + // axes int iter = 0; foreach (int i in axes) @@ -860,27 +861,27 @@ namespace Tensorflow axes[0 + iter] = i + len(shape_a); iter++; } - + // free - int[] free = {}; + int[] free = { }; iter = 0; foreach (int i in Enumerable.Range(0, len(axes))) if (!Array.Exists(axes, i => i == i)) free[free.Length] = i; // free_dims - int[] free_dims = {}; + int[] free_dims = { }; foreach (int i in free) free_dims[free_dims.Length] = shape_a[i]; int prod_free = (int)np.prod(free_dims); - + // prod_axes - int[] prod_axes_pre = {}; + int[] prod_axes_pre = { }; foreach (int i in axes) prod_axes_pre[prod_axes_pre.Length] = shape_a[i]; int prod_axes = (int)np.prod(prod_axes_pre); - + // perm Tensor perm; if (flipped) @@ -892,9 +893,9 @@ namespace Tensorflow // new_shape TensorShape new_shape; if (flipped) - new_shape = new TensorShape(new int[] {prod_axes, prod_free}); + new_shape = new TensorShape(new int[] { prod_axes, prod_free }); else - new_shape = new TensorShape(new int[] {prod_free, prod_axes}); + new_shape = new TensorShape(new int[] { prod_free, prod_axes }); } throw new NotImplementedException("_tensordot_reshape"); diff --git a/src/TensorFlowNET.Core/Operations/nn_impl.py.cs b/src/TensorFlowNET.Core/Operations/nn_impl.py.cs index a28c4746..d2cbdedc 100644 --- a/src/TensorFlowNET.Core/Operations/nn_impl.py.cs +++ b/src/TensorFlowNET.Core/Operations/nn_impl.py.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using Tensorflow.Operations; using static Tensorflow.Binding; @@ -30,7 +29,7 @@ namespace Tensorflow /// /// /// - public static Tensor l2_normalize(Tensor x, + public static Tensor l2_normalize(Tensor x, int axis = 0, float epsilon = 1e-12f, string name = null) @@ -53,7 +52,7 @@ namespace Tensorflow /// Name used to scope the operations that compute the moments. /// Produce moments with the same dimensionality as the input. /// Two `Tensor` objects: `mean` and `variance`. - public static (Tensor, Tensor) moments(Tensor x, + public static (Tensor, Tensor) moments(Tensor x, int[] axes, string name = null, bool keep_dims = false) @@ -112,7 +111,7 @@ namespace Tensorflow var offset_tensor = ops.convert_to_tensor(offset, name: "offset"); if (mean == null) mean = constant_op.constant(new float[0]); - if(variance == null) + if (variance == null) variance = constant_op.constant(new float[0]); var min_epsilon = 1.001e-5f; epsilon = epsilon > min_epsilon ? epsilon : min_epsilon; diff --git a/src/TensorFlowNET.Core/Operations/nn_ops.cs b/src/TensorFlowNET.Core/Operations/nn_ops.cs index 8ded44f1..b70eeab5 100644 --- a/src/TensorFlowNET.Core/Operations/nn_ops.cs +++ b/src/TensorFlowNET.Core/Operations/nn_ops.cs @@ -45,9 +45,9 @@ namespace Tensorflow /// /// /// - public static Tensor bias_add(Tensor value, - Tensor bias, - string data_format = null, + public static Tensor bias_add(Tensor value, + Tensor bias, + string data_format = null, string name = null) { return tf_with(ops.name_scope(name, "BiasAdd", new { value, bias }), scope => @@ -210,7 +210,7 @@ namespace Tensorflow logits.get_shape()[:-1].is_fully_defined());*/ // Check if no reshapes are required. - if(logits.TensorShape.ndim == 2) + if (logits.TensorShape.ndim == 2) { var (cost, _) = gen_nn_ops.sparse_softmax_cross_entropy_with_logits( precise_logits, labels, name: name); @@ -254,7 +254,7 @@ namespace Tensorflow var (cost, unused_backprop) = gen_nn_ops.softmax_cross_entropy_with_logits(precise_logits, labels, name: name); // The output cost shape should be the input minus axis. - var output_shape = array_ops.slice(input_shape, + var output_shape = array_ops.slice(input_shape, new int[] { 0 }, new Tensor[] { math_ops.subtract(input_rank, 1) }); @@ -282,13 +282,13 @@ namespace Tensorflow // Set output shape if known. // if not context.executing_eagerly(): var shape = logits.TensorShape; - if(shape != null && shape.ndim > 0) + if (shape != null && shape.ndim > 0) { var product = 1; var product_valid = true; - foreach(var d in shape.dims.Take(shape.ndim - 1)) + foreach (var d in shape.dims.Take(shape.ndim - 1)) { - if(d == -1) + if (d == -1) { product_valid = false; break; diff --git a/src/TensorFlowNET.Core/Operations/random_ops.cs b/src/TensorFlowNET.Core/Operations/random_ops.cs index 1337db31..e638011a 100644 --- a/src/TensorFlowNET.Core/Operations/random_ops.cs +++ b/src/TensorFlowNET.Core/Operations/random_ops.cs @@ -30,11 +30,11 @@ namespace Tensorflow /// /// /// - public static Tensor random_normal(TensorShape shape, - float mean = 0.0f, - float stddev = 1.0f, - TF_DataType dtype = TF_DataType.TF_FLOAT, - int? seed = null, + public static Tensor random_normal(TensorShape shape, + float mean = 0.0f, + float stddev = 1.0f, + TF_DataType dtype = TF_DataType.TF_FLOAT, + int? seed = null, string name = null) { return tf_with(ops.name_scope(name, "random_normal", new { shape, mean, stddev }), scope => @@ -62,11 +62,11 @@ namespace Tensorflow /// Used to create a random seed for the distribution. /// A name for the operation /// A tensor of the specified shape filled with random uniform values. - public static Tensor random_uniform(int[] shape, + public static Tensor random_uniform(int[] shape, float minval = 0, float maxval = 1, - TF_DataType dtype = TF_DataType.TF_FLOAT, - int? seed = null, + TF_DataType dtype = TF_DataType.TF_FLOAT, + int? seed = null, string name = null) { return tf_with(ops.name_scope(name, "random_uniform", new { shape, minval, maxval }), scope => @@ -167,10 +167,10 @@ namespace Tensorflow { logits = ops.convert_to_tensor(logits, name: "logits"); var (seed1, seed2) = random_seed.get_seed(seed); - return gen_random_ops.multinomial(logits, - num_samples, - seed: seed1, - seed2: seed2, + return gen_random_ops.multinomial(logits, + num_samples, + seed: seed1, + seed2: seed2, output_dtype: dtype); } } diff --git a/src/TensorFlowNET.Core/Operations/resource_variable_ops.cs b/src/TensorFlowNET.Core/Operations/resource_variable_ops.cs index 6d5c9d95..09773a71 100644 --- a/src/TensorFlowNET.Core/Operations/resource_variable_ops.cs +++ b/src/TensorFlowNET.Core/Operations/resource_variable_ops.cs @@ -18,9 +18,6 @@ using System; using System.Linq; using Tensorflow.Framework; using static Tensorflow.CppShapeInferenceResult.Types; -using static Tensorflow.Binding; -using System.Collections.Generic; -using System.Runtime.InteropServices; namespace Tensorflow { @@ -88,7 +85,7 @@ namespace Tensorflow /// /// /// - public static Tensor eager_safe_variable_handle(Tensor initial_value, TensorShape shape, + public static Tensor eager_safe_variable_handle(Tensor initial_value, TensorShape shape, string shared_name, string name, bool graph_mode) { var dtype = initial_value.dtype.as_base_dtype(); @@ -106,7 +103,7 @@ namespace Tensorflow /// /// /// - public static Tensor variable_handle_from_shape_and_dtype(TensorShape shape, TF_DataType dtype, + public static Tensor variable_handle_from_shape_and_dtype(TensorShape shape, TF_DataType dtype, string shared_name, string name, bool graph_mode, Tensor initial_value = null) { var container = ops.get_default_graph().Container; @@ -194,7 +191,7 @@ namespace Tensorflow private static HandleData get_eager_safe_handle_data(Tensor handle) { - if(handle == IntPtr.Zero) + if (handle == IntPtr.Zero) { var data = new HandleData(); data.ShapeAndType.Add(new HandleShapeAndType diff --git a/src/TensorFlowNET.Core/Operations/sparse_ops.cs b/src/TensorFlowNET.Core/Operations/sparse_ops.cs index 6a30771c..37a54f59 100644 --- a/src/TensorFlowNET.Core/Operations/sparse_ops.cs +++ b/src/TensorFlowNET.Core/Operations/sparse_ops.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public class sparse_ops { @@ -17,14 +13,14 @@ namespace Tensorflow /// /// /// Dense `Tensor` of shape `output_shape`. Has the same type as `sparse_values`. - public Tensor sparse_to_dense(Tensor sparse_indices, - int[] output_shape, + public Tensor sparse_to_dense(Tensor sparse_indices, + int[] output_shape, T sparse_values, T default_value = default, bool validate_indices = true, string name = null) - => gen_sparse_ops.sparse_to_dense(sparse_indices, - output_shape, + => gen_sparse_ops.sparse_to_dense(sparse_indices, + output_shape, sparse_values, default_value: default_value, validate_indices: validate_indices, diff --git a/src/TensorFlowNET.Core/Operations/string_ops.cs b/src/TensorFlowNET.Core/Operations/string_ops.cs index 8b4c43a5..49b4c3e9 100644 --- a/src/TensorFlowNET.Core/Operations/string_ops.cs +++ b/src/TensorFlowNET.Core/Operations/string_ops.cs @@ -14,9 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Operations/tensor_array_ops.cs b/src/TensorFlowNET.Core/Operations/tensor_array_ops.cs index 59496943..dc510a41 100644 --- a/src/TensorFlowNET.Core/Operations/tensor_array_ops.cs +++ b/src/TensorFlowNET.Core/Operations/tensor_array_ops.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Operations; +using Tensorflow.Operations; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Sessions/BaseSession.cs b/src/TensorFlowNET.Core/Sessions/BaseSession.cs index 989e89c3..7a1e2b65 100644 --- a/src/TensorFlowNET.Core/Sessions/BaseSession.cs +++ b/src/TensorFlowNET.Core/Sessions/BaseSession.cs @@ -14,6 +14,7 @@ limitations under the License. ******************************************************************************/ +using Google.Protobuf; using NumSharp; using System; using System.Collections; @@ -21,9 +22,8 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; -using Google.Protobuf; -using static Tensorflow.Binding; using Tensorflow.Util; +using static Tensorflow.Binding; namespace Tensorflow { @@ -70,7 +70,7 @@ namespace Tensorflow } public virtual (NDArray, NDArray, NDArray, NDArray, NDArray) run( - (ITensorOrOperation, ITensorOrOperation, ITensorOrOperation, ITensorOrOperation, ITensorOrOperation) fetches, + (ITensorOrOperation, ITensorOrOperation, ITensorOrOperation, ITensorOrOperation, ITensorOrOperation) fetches, params FeedItem[] feed_dict) { var results = _run(new object[] { fetches.Item1, fetches.Item2, fetches.Item3, fetches.Item4, fetches.Item5 }, feed_dict); @@ -79,19 +79,19 @@ namespace Tensorflow public virtual (NDArray, NDArray, NDArray, NDArray) run((ITensorOrOperation, ITensorOrOperation, ITensorOrOperation, ITensorOrOperation) fetches, params FeedItem[] feed_dict) { - var results = _run(new object[] {fetches.Item1, fetches.Item2, fetches.Item3, fetches.Item4}, feed_dict); + var results = _run(new object[] { fetches.Item1, fetches.Item2, fetches.Item3, fetches.Item4 }, feed_dict); return (results[0], results[1], results[2], results[3]); } public virtual (NDArray, NDArray, NDArray) run((ITensorOrOperation, ITensorOrOperation, ITensorOrOperation) fetches, params FeedItem[] feed_dict) { - var results = _run(new object[] {fetches.Item1, fetches.Item2, fetches.Item3}, feed_dict); + var results = _run(new object[] { fetches.Item1, fetches.Item2, fetches.Item3 }, feed_dict); return (results[0], results[1], results[2]); } public virtual (NDArray, NDArray) run((ITensorOrOperation, ITensorOrOperation) fetches, params FeedItem[] feed_dict) { - var results = _run(new object[] {fetches.Item1, fetches.Item2}, feed_dict); + var results = _run(new object[] { fetches.Item1, fetches.Item2 }, feed_dict); return (results[0], results[1]); } @@ -136,7 +136,7 @@ namespace Tensorflow // We only want to really perform the run if fetches or targets are provided, // or if the call is a partial run that specifies feeds. - var results = _do_run(final_targets.Select(x => (Operation) x).ToList(), final_fetches, feed_dict_tensor); + var results = _do_run(final_targets.Select(x => (Operation)x).ToList(), final_fetches, feed_dict_tensor); return fetch_handler.build_results(this, results); } @@ -242,12 +242,12 @@ namespace Tensorflow c_api.TF_SessionRun(_handle, run_options: null, inputs: feed_dict.Select(f => f.Key).ToArray(), - input_values: feed_dict.Select(f => (IntPtr) f.Value).ToArray(), + input_values: feed_dict.Select(f => (IntPtr)f.Value).ToArray(), ninputs: feed_dict.Length, outputs: fetch_list, output_values: output_values, noutputs: fetch_list.Length, - target_opers: target_list.Select(f => (IntPtr) f).ToArray(), + target_opers: target_list.Select(f => (IntPtr)f).ToArray(), ntargets: target_list.Count, run_metadata: IntPtr.Zero, status: status.Handle); @@ -275,51 +275,52 @@ namespace Tensorflow switch (tensor.dtype) { case TF_DataType.TF_BOOL: - ret = NDArray.Scalar(*(bool*) srcAddress); + ret = NDArray.Scalar(*(bool*)srcAddress); break; case TF_DataType.TF_STRING: - using (var reader = new CodedInputStream(new IntPtr(srcAddress).Stream(8, (long) tensor.bytesize))) - ret = new NDArray(reader.ReadBytes().ToByteArray()); + using (var reader = new CodedInputStream(new IntPtr(srcAddress).Stream(8, (long)tensor.bytesize))) + ret = new NDArray(reader.ReadBytes().ToByteArray()); break; case TF_DataType.TF_UINT8: - ret = NDArray.Scalar(*(byte*) srcAddress); + ret = NDArray.Scalar(*(byte*)srcAddress); break; case TF_DataType.TF_INT16: - ret = NDArray.Scalar(*(short*) srcAddress); + ret = NDArray.Scalar(*(short*)srcAddress); break; case TF_DataType.TF_INT32: - ret = NDArray.Scalar(*(int*) srcAddress); + ret = NDArray.Scalar(*(int*)srcAddress); break; case TF_DataType.TF_INT64: - ret = NDArray.Scalar(*(long*) srcAddress); + ret = NDArray.Scalar(*(long*)srcAddress); break; case TF_DataType.TF_UINT16: - ret = NDArray.Scalar(*(ushort*) srcAddress); + ret = NDArray.Scalar(*(ushort*)srcAddress); break; case TF_DataType.TF_UINT32: - ret = NDArray.Scalar(*(uint*) srcAddress); + ret = NDArray.Scalar(*(uint*)srcAddress); break; case TF_DataType.TF_UINT64: - ret = NDArray.Scalar(*(ulong*) srcAddress); + ret = NDArray.Scalar(*(ulong*)srcAddress); break; case TF_DataType.TF_FLOAT: - ret = NDArray.Scalar(*(float*) srcAddress); + ret = NDArray.Scalar(*(float*)srcAddress); break; case TF_DataType.TF_DOUBLE: - ret = NDArray.Scalar(*(double*) srcAddress); + ret = NDArray.Scalar(*(double*)srcAddress); break; default: throw new NotImplementedException("can't fetch output"); } - } else + } + else { //var size = (long) tensor.size; //var itemsize = (long) tensor.itemsize; - var bytesize = (long) tensor.bytesize; - var src = (void*) srcAddress; + var bytesize = (long)tensor.bytesize; + var src = (void*)srcAddress; #if _REGEN - #region Compute + #region Compute switch (tensor.dtype) { %foreach except(supported_dtypes, "Char"),except(supported_dtypes_lowercase, "char"),except(supported_dtypes_TF_DataType,"TF_STRING")% @@ -340,7 +341,7 @@ namespace Tensorflow default: throw new NotSupportedException(); } - #endregion + #endregion #else #region Compute @@ -348,85 +349,85 @@ namespace Tensorflow switch (tensor.dtype) { case TF_DataType.TF_BOOL: - { - ret = new NDArray(NPTypeCode.Boolean, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.Boolean, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_UINT8: - { - ret = new NDArray(NPTypeCode.Byte, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.Byte, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_INT16: - { - ret = new NDArray(NPTypeCode.Int16, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.Int16, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_UINT16: - { - ret = new NDArray(NPTypeCode.UInt16, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.UInt16, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_INT32: - { - ret = new NDArray(NPTypeCode.Int32, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.Int32, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_UINT32: - { - ret = new NDArray(NPTypeCode.UInt32, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.UInt32, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_INT64: - { - ret = new NDArray(NPTypeCode.Int64, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.Int64, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_UINT64: - { - ret = new NDArray(NPTypeCode.UInt64, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.UInt64, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_DOUBLE: - { - ret = new NDArray(NPTypeCode.Double, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.Double, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_FLOAT: - { - ret = new NDArray(NPTypeCode.Single, ndims, false); - System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); - break; - } + { + ret = new NDArray(NPTypeCode.Single, ndims, false); + System.Buffer.MemoryCopy(src, ret.Unsafe.Address, bytesize, bytesize); + break; + } case TF_DataType.TF_STRING: - { - throw new NotImplementedException(); - //TODO:! This is not the way to handle string[], it should be done with TF_DecodeString + { + throw new NotImplementedException(); + //TODO:! This is not the way to handle string[], it should be done with TF_DecodeString #pragma warning disable CS0162 // Unreachable code detected - using (var reader = new CodedInputStream(new IntPtr(srcAddress).Stream(8, (long) tensor.bytesize))) + using (var reader = new CodedInputStream(new IntPtr(srcAddress).Stream(8, (long)tensor.bytesize))) #pragma warning restore CS0162 // Unreachable code detected - ret = NDArray.FromString(reader.ReadString()); - break; - } + ret = NDArray.FromString(reader.ReadString()); + break; + } default: throw new NotSupportedException(); diff --git a/src/TensorFlowNET.Core/Sessions/Session.cs b/src/TensorFlowNET.Core/Sessions/Session.cs index 6de2c606..c48715a2 100644 --- a/src/TensorFlowNET.Core/Sessions/Session.cs +++ b/src/TensorFlowNET.Core/Sessions/Session.cs @@ -18,7 +18,6 @@ using System; using System.IO; using System.Runtime.CompilerServices; using Tensorflow.Util; -using static Tensorflow.Binding; namespace Tensorflow { @@ -49,7 +48,7 @@ namespace Tensorflow using var status = new Status(); var opt = new SessionOptions(); - var tags = new string[] {"serve"}; + var tags = new string[] { "serve" }; var buffer = new TF_Buffer(); IntPtr sess; @@ -64,7 +63,8 @@ namespace Tensorflow ref buffer, status.Handle); status.Check(true); - } catch (TensorflowException ex) when (ex.Message.Contains("Could not find SavedModel")) + } + catch (TensorflowException ex) when (ex.Message.Contains("Could not find SavedModel")) { sess = c_api.TF_LoadSessionFromSavedModel(opt.Handle, IntPtr.Zero, @@ -101,12 +101,12 @@ namespace Tensorflow public void __init__() { - + } public void __del__() { - + } } } diff --git a/src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs b/src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs index 12422289..a5dc46c8 100644 --- a/src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs +++ b/src/TensorFlowNET.Core/Sessions/_ElementFetchMapper.cs @@ -17,7 +17,6 @@ using NumSharp; using System; using System.Collections.Generic; -using System.Numerics; namespace Tensorflow { @@ -32,12 +31,12 @@ namespace Tensorflow { var g = graph ?? ops.get_default_graph(); - foreach(var fetch in fetches) + foreach (var fetch in fetches) { var el = g.as_graph_element(fetch, allow_tensor: true, allow_operation: true); _unique_fetches.Add(el); } - + _contraction_fn = contraction_fn; } diff --git a/src/TensorFlowNET.Core/Sessions/_FetchHandler.cs b/src/TensorFlowNET.Core/Sessions/_FetchHandler.cs index c8f0becf..8a55947d 100644 --- a/src/TensorFlowNET.Core/Sessions/_FetchHandler.cs +++ b/src/TensorFlowNET.Core/Sessions/_FetchHandler.cs @@ -17,7 +17,6 @@ using NumSharp; using System; using System.Collections.Generic; -using NumSharp.Backends; namespace Tensorflow { @@ -35,7 +34,7 @@ namespace Tensorflow public _FetchHandler(Graph graph, object fetches, Dictionary feeds = null, Action feed_handles = null) { _fetch_mapper = _FetchMapper.for_fetch(fetches, graph: graph); - foreach(var fetch in _fetch_mapper.unique_fetches()) + foreach (var fetch in _fetch_mapper.unique_fetches()) { switch (fetch) { @@ -66,11 +65,11 @@ namespace Tensorflow int i = 0; int j = 0; - foreach(var is_op in _ops) + foreach (var is_op in _ops) { if (is_op) { - if(tensor_values.Length > 0) + if (tensor_values.Length > 0) { switch (tensor_values[0].typecode) { diff --git a/src/TensorFlowNET.Core/Sessions/_FetchMapper.cs b/src/TensorFlowNET.Core/Sessions/_FetchMapper.cs index e28b76a1..1d5bf1b2 100644 --- a/src/TensorFlowNET.Core/Sessions/_FetchMapper.cs +++ b/src/TensorFlowNET.Core/Sessions/_FetchMapper.cs @@ -15,9 +15,7 @@ ******************************************************************************/ using NumSharp; -using System; using System.Collections.Generic; -using System.Linq; namespace Tensorflow { @@ -29,7 +27,7 @@ namespace Tensorflow { var fetches = fetch.GetType().IsArray ? (object[])fetch : new object[] { fetch }; - if(fetch is List fetches1) + if (fetch is List fetches1) return new _ListFetchMapper(fetches1.ToArray()); if (fetch.GetType().IsArray) return new _ListFetchMapper(fetches); diff --git a/src/TensorFlowNET.Core/Sessions/c_api.tf_session_helper.cs b/src/TensorFlowNET.Core/Sessions/c_api.tf_session_helper.cs index 6cbf4eec..f004bc54 100644 --- a/src/TensorFlowNET.Core/Sessions/c_api.tf_session_helper.cs +++ b/src/TensorFlowNET.Core/Sessions/c_api.tf_session_helper.cs @@ -29,7 +29,7 @@ namespace Tensorflow var consumers = new string[num_consumers]; unsafe { - var inputptr = (TF_Input*) handle; + var inputptr = (TF_Input*)handle; for (int i = 0; i < num; i++) { var oper = (inputptr + i)->oper; diff --git a/src/TensorFlowNET.Core/Summaries/EventFileWriter.cs b/src/TensorFlowNET.Core/Summaries/EventFileWriter.cs index 3e553078..8a6d9bb0 100644 --- a/src/TensorFlowNET.Core/Summaries/EventFileWriter.cs +++ b/src/TensorFlowNET.Core/Summaries/EventFileWriter.cs @@ -36,7 +36,7 @@ namespace Tensorflow.Summaries #pragma warning restore CS0414 // The field 'EventFileWriter._closed' is assigned but its value is never used EventLoggerThread _worker; - public EventFileWriter(string logdir, int max_queue = 10, int flush_secs= 120, + public EventFileWriter(string logdir, int max_queue = 10, int flush_secs = 120, string filename_suffix = null) { _logdir = logdir; diff --git a/src/TensorFlowNET.Core/Summaries/EventLoggerThread.cs b/src/TensorFlowNET.Core/Summaries/EventLoggerThread.cs index 0a63ca9c..cbe9665d 100644 --- a/src/TensorFlowNET.Core/Summaries/EventLoggerThread.cs +++ b/src/TensorFlowNET.Core/Summaries/EventLoggerThread.cs @@ -51,7 +51,7 @@ namespace Tensorflow.Summaries { while (true) { - if(_queue.Count == 0) + if (_queue.Count == 0) { Thread.Sleep(_flush_secs * 1000); continue; diff --git a/src/TensorFlowNET.Core/Summaries/FileWriter.cs b/src/TensorFlowNET.Core/Summaries/FileWriter.cs index 1be2747b..68bba4db 100644 --- a/src/TensorFlowNET.Core/Summaries/FileWriter.cs +++ b/src/TensorFlowNET.Core/Summaries/FileWriter.cs @@ -23,11 +23,11 @@ namespace Tensorflow.Summaries { EventFileWriter event_writer; - public FileWriter(string logdir, Graph graph, - int max_queue = 10, int flush_secs = 120, string filename_suffix = null, + public FileWriter(string logdir, Graph graph, + int max_queue = 10, int flush_secs = 120, string filename_suffix = null, Session session = null) { - if(session == null) + if (session == null) { event_writer = new EventFileWriter(logdir, max_queue, flush_secs, filename_suffix); } diff --git a/src/TensorFlowNET.Core/Tensors/Dimension.cs b/src/TensorFlowNET.Core/Tensors/Dimension.cs index 878ba5ae..11054d62 100644 --- a/src/TensorFlowNET.Core/Tensors/Dimension.cs +++ b/src/TensorFlowNET.Core/Tensors/Dimension.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public class Dimension { diff --git a/src/TensorFlowNET.Core/Tensors/ITensor.cs b/src/TensorFlowNET.Core/Tensors/ITensor.cs index 4c2365b3..fe483e74 100644 --- a/src/TensorFlowNET.Core/Tensors/ITensor.cs +++ b/src/TensorFlowNET.Core/Tensors/ITensor.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public interface ITensor { diff --git a/src/TensorFlowNET.Core/Tensors/TF_BindingArray.cs b/src/TensorFlowNET.Core/Tensors/TF_BindingArray.cs index 2999dc86..535541b8 100644 --- a/src/TensorFlowNET.Core/Tensors/TF_BindingArray.cs +++ b/src/TensorFlowNET.Core/Tensors/TF_BindingArray.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Tensors/TF_Tensor.cs b/src/TensorFlowNET.Core/Tensors/TF_Tensor.cs index 3035b2f0..06c0be8d 100644 --- a/src/TensorFlowNET.Core/Tensors/TF_Tensor.cs +++ b/src/TensorFlowNET.Core/Tensors/TF_Tensor.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Conversions.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Conversions.cs index 06170bdf..0968b6c6 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Conversions.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Conversions.cs @@ -15,14 +15,14 @@ ******************************************************************************/ using NumSharp; +using NumSharp.Utilities; using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime.CompilerServices; using System.Text; -using NumSharp.Utilities; -using static Tensorflow.Binding; using Tensorflow.Framework.Models; +using static Tensorflow.Binding; namespace Tensorflow { @@ -46,23 +46,23 @@ namespace Tensorflow #else case TF_DataType.TF_UINT8: - return Converts.ChangeType(*(byte*) this.buffer); + return Converts.ChangeType(*(byte*)this.buffer); case TF_DataType.TF_INT16: - return Converts.ChangeType(*(short*) this.buffer); + return Converts.ChangeType(*(short*)this.buffer); case TF_DataType.TF_UINT16: - return Converts.ChangeType(*(ushort*) this.buffer); + return Converts.ChangeType(*(ushort*)this.buffer); case TF_DataType.TF_INT32: - return Converts.ChangeType(*(int*) this.buffer); + return Converts.ChangeType(*(int*)this.buffer); case TF_DataType.TF_UINT32: - return Converts.ChangeType(*(uint*) this.buffer); + return Converts.ChangeType(*(uint*)this.buffer); case TF_DataType.TF_INT64: - return Converts.ChangeType(*(long*) this.buffer); + return Converts.ChangeType(*(long*)this.buffer); case TF_DataType.TF_UINT64: - return Converts.ChangeType(*(ulong*) this.buffer); + return Converts.ChangeType(*(ulong*)this.buffer); case TF_DataType.TF_DOUBLE: - return Converts.ChangeType(*(double*) this.buffer); + return Converts.ChangeType(*(double*)this.buffer); case TF_DataType.TF_FLOAT: - return Converts.ChangeType(*(float*) this.buffer); + return Converts.ChangeType(*(float*)this.buffer); #endif case TF_DataType.TF_STRING: if (this.NDims != 0) @@ -71,13 +71,13 @@ namespace Tensorflow IntPtr stringStartAddress = IntPtr.Zero; ulong dstLen = 0; - c_api.TF_StringDecode((byte*) this.buffer + 8, this.bytesize, (byte**) &stringStartAddress, ref dstLen, tf.Status.Handle); + c_api.TF_StringDecode((byte*)this.buffer + 8, this.bytesize, (byte**)&stringStartAddress, ref dstLen, tf.Status.Handle); tf.Status.Check(true); - var dstLenInt = checked((int) dstLen); - var value = Encoding.UTF8.GetString((byte*) stringStartAddress, dstLenInt); + var dstLenInt = checked((int)dstLen); + var value = Encoding.UTF8.GetString((byte*)stringStartAddress, dstLenInt); if (typeof(T) == typeof(string)) - return (T) (object) value; + return (T)(object)value; else return Converts.ChangeType(value); @@ -116,60 +116,60 @@ namespace Tensorflow switch (nd.typecode) { case NPTypeCode.Boolean: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.Byte: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.Int16: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.UInt16: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.Int32: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.UInt32: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.Int64: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.UInt64: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.Char: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.Double: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } case NPTypeCode.Single: - { - CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); - break; - } + { + CopyTo(new Span(nd.Unsafe.Address, nd.size * nd.dtypesize)); + break; + } default: throw new NotSupportedException(); } @@ -182,11 +182,11 @@ namespace Tensorflow { unsafe { - var len = checked((int) this.size); + var len = checked((int)this.size); //perform regular CopyTo using Span.CopyTo. if (typeof(T).as_dtype() == this.dtype && this.dtype != TF_DataType.TF_STRING) //T can't be a string but tensor can. { - var src = (T*) this.buffer; + var src = (T*)this.buffer; var srcSpan = new Span(src, len); srcSpan.CopyTo(destination); @@ -214,95 +214,95 @@ namespace Tensorflow % #else case TF_DataType.TF_BOOL: - { - var converter = Converts.FindConverter(); - var src = (bool*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (bool*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_UINT8: - { - var converter = Converts.FindConverter(); - var src = (byte*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (byte*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_INT16: - { - var converter = Converts.FindConverter(); - var src = (short*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (short*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_UINT16: - { - var converter = Converts.FindConverter(); - var src = (ushort*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (ushort*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_INT32: - { - var converter = Converts.FindConverter(); - var src = (int*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (int*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_UINT32: - { - var converter = Converts.FindConverter(); - var src = (uint*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (uint*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_INT64: - { - var converter = Converts.FindConverter(); - var src = (long*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (long*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_UINT64: - { - var converter = Converts.FindConverter(); - var src = (ulong*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (ulong*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_DOUBLE: - { - var converter = Converts.FindConverter(); - var src = (double*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (double*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } case TF_DataType.TF_FLOAT: - { - var converter = Converts.FindConverter(); - var src = (float*) this.buffer; - for (var i = 0; i < len; i++) - *(dst + i) = converter(unchecked(*(src + i))); - return; - } + { + var converter = Converts.FindConverter(); + var src = (float*)this.buffer; + for (var i = 0; i < len; i++) + *(dst + i) = converter(unchecked(*(src + i))); + return; + } #endif case TF_DataType.TF_STRING: - { - var src = this.StringData(); - var culture = CultureInfo.InvariantCulture; + { + var src = this.StringData(); + var culture = CultureInfo.InvariantCulture; - //pin to prevent GC from moving the span around. - fixed (T* _ = destination) - switch (typeof(T).as_dtype()) - { + //pin to prevent GC from moving the span around. + fixed (T* _ = destination) + switch (typeof(T).as_dtype()) + { #if _REGEN %foreach supported_numericals_TF_DataType,supported_numericals,supported_numericals_lowercase% case TF_DataType.#1: { @@ -313,81 +313,81 @@ namespace Tensorflow } % #else - case TF_DataType.TF_BOOL: - { - var sdst = (bool*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToBoolean(culture); - return; - } - case TF_DataType.TF_UINT8: - { - var sdst = (byte*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToByte(culture); - return; - } - case TF_DataType.TF_INT16: - { - var sdst = (short*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToInt16(culture); - return; - } - case TF_DataType.TF_UINT16: - { - var sdst = (ushort*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToUInt16(culture); - return; - } - case TF_DataType.TF_INT32: - { - var sdst = (int*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToInt32(culture); - return; - } - case TF_DataType.TF_UINT32: - { - var sdst = (uint*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToUInt32(culture); - return; - } - case TF_DataType.TF_INT64: - { - var sdst = (long*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToInt64(culture); - return; - } - case TF_DataType.TF_UINT64: - { - var sdst = (ulong*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToUInt64(culture); - return; - } - case TF_DataType.TF_DOUBLE: - { - var sdst = (double*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToDouble(culture); - return; - } - case TF_DataType.TF_FLOAT: - { - var sdst = (float*) Unsafe.AsPointer(ref destination.GetPinnableReference()); - for (var i = 0; i < len; i++) - *(sdst + i) = ((IConvertible) src[i]).ToSingle(culture); - return; - } + case TF_DataType.TF_BOOL: + { + var sdst = (bool*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToBoolean(culture); + return; + } + case TF_DataType.TF_UINT8: + { + var sdst = (byte*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToByte(culture); + return; + } + case TF_DataType.TF_INT16: + { + var sdst = (short*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToInt16(culture); + return; + } + case TF_DataType.TF_UINT16: + { + var sdst = (ushort*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToUInt16(culture); + return; + } + case TF_DataType.TF_INT32: + { + var sdst = (int*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToInt32(culture); + return; + } + case TF_DataType.TF_UINT32: + { + var sdst = (uint*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToUInt32(culture); + return; + } + case TF_DataType.TF_INT64: + { + var sdst = (long*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToInt64(culture); + return; + } + case TF_DataType.TF_UINT64: + { + var sdst = (ulong*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToUInt64(culture); + return; + } + case TF_DataType.TF_DOUBLE: + { + var sdst = (double*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToDouble(culture); + return; + } + case TF_DataType.TF_FLOAT: + { + var sdst = (float*)Unsafe.AsPointer(ref destination.GetPinnableReference()); + for (var i = 0; i < len; i++) + *(sdst + i) = ((IConvertible)src[i]).ToSingle(culture); + return; + } #endif - default: - throw new NotSupportedException(); - } - } + default: + throw new NotSupportedException(); + } + } case TF_DataType.TF_COMPLEX64: case TF_DataType.TF_COMPLEX128: default: diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs index 8810076c..1c45fb56 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Creation.cs @@ -22,8 +22,8 @@ using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; -using static Tensorflow.c_api; using static Tensorflow.Binding; +using static Tensorflow.c_api; namespace Tensorflow { @@ -99,7 +99,7 @@ namespace Tensorflow /// Size of the tensor in memory public unsafe Tensor(void* data_ptr, long[] shape, TF_DataType dType, int num_bytes) { - _handle = TF_NewTensor(dType, dims: shape, num_dims: shape.Length, data: data_ptr, len: (ulong) num_bytes); + _handle = TF_NewTensor(dType, dims: shape, num_dims: shape.Length, data: data_ptr, len: (ulong)num_bytes); AllocationType = TF_TensorData(_handle).ToPointer() == data_ptr ? AllocationType.FromPointer : AllocationType.Tensorflow; } @@ -134,13 +134,13 @@ namespace Tensorflow } % #else - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(sbyte[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(sbyte)), new long[] {data.Length}, data, sizeof(sbyte)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(sbyte)), new long[] { data.Length }, data, sizeof(sbyte)); } /// @@ -157,16 +157,16 @@ namespace Tensorflow public unsafe Tensor(sbyte value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(sbyte)), dims: new long[0], num_dims: 0, len: sizeof(sbyte)); - *(sbyte*) TF_TensorData(_handle) = value; + *(sbyte*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(bool[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(bool)), new long[] {data.Length}, data, sizeof(bool)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(bool)), new long[] { data.Length }, data, sizeof(bool)); } /// @@ -183,16 +183,16 @@ namespace Tensorflow public unsafe Tensor(bool value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(bool)), dims: new long[0], num_dims: 0, len: sizeof(bool)); - *(bool*) TF_TensorData(_handle) = value; + *(bool*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(byte[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(byte)), new long[] {data.Length}, data, sizeof(byte)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(byte)), new long[] { data.Length }, data, sizeof(byte)); } /// @@ -209,16 +209,16 @@ namespace Tensorflow public unsafe Tensor(byte value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(byte)), dims: new long[0], num_dims: 0, len: sizeof(byte)); - *(byte*) TF_TensorData(_handle) = value; + *(byte*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(short[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(short)), new long[] {data.Length}, data, sizeof(short)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(short)), new long[] { data.Length }, data, sizeof(short)); } /// @@ -235,16 +235,16 @@ namespace Tensorflow public unsafe Tensor(short value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(short)), dims: new long[0], num_dims: 0, len: sizeof(short)); - *(short*) TF_TensorData(_handle) = value; + *(short*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(ushort[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(ushort)), new long[] {data.Length}, data, sizeof(ushort)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(ushort)), new long[] { data.Length }, data, sizeof(ushort)); } /// @@ -261,16 +261,16 @@ namespace Tensorflow public unsafe Tensor(ushort value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(ushort)), dims: new long[0], num_dims: 0, len: sizeof(ushort)); - *(ushort*) TF_TensorData(_handle) = value; + *(ushort*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(int[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(int)), new long[] {data.Length}, data, sizeof(int)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(int)), new long[] { data.Length }, data, sizeof(int)); } /// @@ -287,16 +287,16 @@ namespace Tensorflow public unsafe Tensor(int value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(int)), dims: new long[0], num_dims: 0, len: sizeof(int)); - *(int*) TF_TensorData(_handle) = value; + *(int*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(uint[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(uint)), new long[] {data.Length}, data, sizeof(uint)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(uint)), new long[] { data.Length }, data, sizeof(uint)); } /// @@ -313,16 +313,16 @@ namespace Tensorflow public unsafe Tensor(uint value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(uint)), dims: new long[0], num_dims: 0, len: sizeof(uint)); - *(uint*) TF_TensorData(_handle) = value; + *(uint*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(long[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(long)), new long[] {data.Length}, data, sizeof(long)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(long)), new long[] { data.Length }, data, sizeof(long)); } /// @@ -339,16 +339,16 @@ namespace Tensorflow public unsafe Tensor(long value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(long)), dims: new long[0], num_dims: 0, len: sizeof(long)); - *(long*) TF_TensorData(_handle) = value; + *(long*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(ulong[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(ulong)), new long[] {data.Length}, data, sizeof(ulong)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(ulong)), new long[] { data.Length }, data, sizeof(ulong)); } /// @@ -365,10 +365,10 @@ namespace Tensorflow public unsafe Tensor(ulong value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(ulong)), dims: new long[0], num_dims: 0, len: sizeof(ulong)); - *(ulong*) TF_TensorData(_handle) = value; + *(ulong*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// @@ -391,16 +391,16 @@ namespace Tensorflow public unsafe Tensor(float value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(float)), dims: new long[0], num_dims: 0, len: sizeof(float)); - *(float*) TF_TensorData(_handle) = value; + *(float*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(double[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(double)), new long[] {data.Length}, data, sizeof(double)); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(double)), new long[] { data.Length }, data, sizeof(double)); } /// @@ -417,16 +417,16 @@ namespace Tensorflow public unsafe Tensor(double value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(double)), dims: new long[0], num_dims: 0, len: sizeof(double)); - *(double*) TF_TensorData(_handle) = value; + *(double*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } - + /// /// Create a 1d Tensor from the given linear array and shape /// public Tensor(Complex[] data, TF_DataType? dType = null) { - _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(Complex)), new long[] {data.Length}, data, Marshal.SizeOf()); + _handle = CreateTensorFromArray(dType ?? dtypes.as_dtype(typeof(Complex)), new long[] { data.Length }, data, Marshal.SizeOf()); } /// @@ -443,7 +443,7 @@ namespace Tensorflow public unsafe Tensor(Complex value, TF_DataType? dType = null) { _handle = TF_AllocateTensor(dType ?? dtypes.as_dtype(typeof(Complex)), dims: new long[0], num_dims: 0, len: (ulong)sizeof(Complex)); - *(Complex*) TF_TensorData(_handle) = value; + *(Complex*)TF_TensorData(_handle) = value; AllocationType = AllocationType.Tensorflow; } #endif @@ -505,7 +505,7 @@ namespace Tensorflow public unsafe Tensor(NDArray nd, TF_DataType? tensorDType = null) { - if (tensorDType == null) + if (tensorDType == null) tensorDType = nd.dtype.as_dtype(); // todo: handle nd of type "String" here too @@ -521,10 +521,11 @@ namespace Tensorflow IntPtr tensor = c_api.TF_TensorData(handle); Marshal.WriteInt64(tensor, 0); - c_api.TF_StringEncode((byte*) nd.Unsafe.Address, bytesLength, (byte*) (tensor + sizeof(long)), size, tf.Status.Handle); + c_api.TF_StringEncode((byte*)nd.Unsafe.Address, bytesLength, (byte*)(tensor + sizeof(long)), size, tf.Status.Handle); tf.Status.Check(true); _handle = handle; - } else + } + else { var buffer = nd.ToArray(); var size = c_api.TF_StringEncodedSize((ulong)buffer.Length); @@ -535,7 +536,7 @@ namespace Tensorflow Marshal.WriteInt64(tensor, 0); fixed (byte* src = buffer) - c_api.TF_StringEncode(src, (ulong)buffer.Length, (byte*) (tensor + sizeof(Int64)), size, tf.Status.Handle); + c_api.TF_StringEncode(src, (ulong)buffer.Length, (byte*)(tensor + sizeof(Int64)), size, tf.Status.Handle); tf.Status.Check(true); _handle = handle; @@ -556,17 +557,18 @@ namespace Tensorflow var handle = TF_NewTensor( given_dtype ?? nd.dtype.as_dtype(), - dims: nd.shape.Select(i => (long) i).ToArray(), + dims: nd.shape.Select(i => (long)i).ToArray(), num_dims: nd.ndim, data: arraySlice.Address, - len: (ulong) (nd.size * nd.dtypesize)); + len: (ulong)(nd.size * nd.dtypesize)); //if TF decided not to perform copy, hold reference for given NDArray. if (TF_TensorData(handle).ToPointer() == arraySlice.Address) { AllocationType = AllocationType.FromPointer; AllocationReferenceHolder = arraySlice; - } else + } + else AllocationType = AllocationType.Tensorflow; return handle; @@ -645,16 +647,17 @@ namespace Tensorflow //call NewTensor IntPtr handle; if (shape == null || shape.Length == 0) - handle = TF_NewTensor(dt, new long[0], 0, pinnedAddr + start * element_size, (ulong) (count * element_size)); - else - handle = TF_NewTensor(dt, shape, shape.Length, pinnedAddr + start * element_size, (ulong) (count * element_size)); + handle = TF_NewTensor(dt, new long[0], 0, pinnedAddr + start * element_size, (ulong)(count * element_size)); + else + handle = TF_NewTensor(dt, shape, shape.Length, pinnedAddr + start * element_size, (ulong)(count * element_size)); //Figure if TF decided to clone or not. if (c_api.TF_TensorData(handle) == pinnedAddr) { AllocationType = AllocationType.GCHandle; AllocationHandle = gcHandle; - } else + } + else { AllocationType = AllocationType.Tensorflow; gcHandle.Free(); diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Explicit.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Explicit.cs index 2f0043b6..79c4a593 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Explicit.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Explicit.cs @@ -21,7 +21,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_INT8); - return *(sbyte*) tensor.buffer; + return *(sbyte*)tensor.buffer; } } @@ -31,7 +31,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_UINT8); - return *(byte*) tensor.buffer; + return *(byte*)tensor.buffer; } } @@ -41,7 +41,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_UINT16); - return *(ushort*) tensor.buffer; + return *(ushort*)tensor.buffer; } } @@ -51,7 +51,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_INT16); - return *(short*) tensor.buffer; + return *(short*)tensor.buffer; } } @@ -61,7 +61,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_INT32); - return *(int*) tensor.buffer; + return *(int*)tensor.buffer; } } @@ -71,7 +71,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_UINT32); - return *(uint*) tensor.buffer; + return *(uint*)tensor.buffer; } } @@ -81,7 +81,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_INT64); - return *(long*) tensor.buffer; + return *(long*)tensor.buffer; } } @@ -91,7 +91,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_UINT64); - return *(ulong*) tensor.buffer; + return *(ulong*)tensor.buffer; } } @@ -101,7 +101,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_FLOAT); - return *(float*) tensor.buffer; + return *(float*)tensor.buffer; } } @@ -111,7 +111,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_DOUBLE); - return *(double*) tensor.buffer; + return *(double*)tensor.buffer; } } @@ -121,7 +121,7 @@ namespace Tensorflow { EnsureScalar(tensor); EnsureDType(tensor, TF_DataType.TF_STRING); - return new string((char*) tensor.buffer, 0, (int) tensor.size); + return new string((char*)tensor.buffer, 0, (int)tensor.size); } } diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Flatten.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Flatten.cs index 5e729a14..80d8b5f2 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Flatten.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Flatten.cs @@ -1,9 +1,4 @@ -using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public partial class Tensor { diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs index 5203d43e..de216bd7 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Implicit.cs @@ -1,8 +1,5 @@ using NumSharp; using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Index.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Index.cs index 26c251b0..239780ea 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Index.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Index.cs @@ -18,7 +18,6 @@ using NumSharp; using System; using System.Collections.Generic; using System.Linq; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow @@ -114,7 +113,7 @@ namespace Tensorflow } } - public Tensor this[params string[] slices] + public Tensor this[params string[] slices] => this[slices.Select(x => new Slice(x)).ToArray()]; diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs index ca022783..1c394238 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Operators.cs @@ -17,7 +17,6 @@ using NumSharp; using System; using System.Collections.Generic; -using System.Linq; using System.Numerics; using static Tensorflow.Binding; @@ -295,7 +294,7 @@ namespace Tensorflow { bool is_floating = false; var types = new List(); - + if (x is Tensor t1) types.add(t1.dtype.is_floating()); @@ -317,7 +316,7 @@ namespace Tensorflow dtype = tl.dtype.as_base_dtype(); switchToGraphModeTemp = switchToGraphModeTemp || !tl.IsEagerTensor; } - + if (y is Tensor tr) { dtype = tr.dtype.as_base_dtype(); diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs index b37612c8..15c2a882 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Pack.cs @@ -1,9 +1,4 @@ -using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow +namespace Tensorflow { public partial class Tensor { diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.Value.cs b/src/TensorFlowNET.Core/Tensors/Tensor.Value.cs index f8d6c1a3..ed60a71d 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.Value.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.Value.cs @@ -3,9 +3,9 @@ using NumSharp.Backends; using NumSharp.Backends.Unmanaged; using NumSharp.Utilities; using System; -using static Tensorflow.Binding; using System.Runtime.InteropServices; using System.Text; +using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Tensors/Tensor.cs b/src/TensorFlowNET.Core/Tensors/Tensor.cs index e6586f26..ce0d5cde 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensor.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensor.cs @@ -16,16 +16,14 @@ using NumSharp; using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using static Tensorflow.Binding; using Tensorflow.Eager; using Tensorflow.Framework; using Tensorflow.Keras.Engine; +using static Tensorflow.Binding; namespace Tensorflow { @@ -36,9 +34,9 @@ namespace Tensorflow [SuppressMessage("ReSharper", "ConvertToAutoProperty")] public partial class Tensor : DisposableObject, ITensor, - ITensorOrOperation, - _TensorLike, - ITensorOrTensorArray, + ITensorOrOperation, + _TensorLike, + ITensorOrTensorArray, IPackable, ICanBeFlattened { @@ -120,7 +118,7 @@ namespace Tensorflow dims[i] = c_api.TF_Dim(_handle, i); } - return dims.Select(x => ((IConvertible) x).ToInt32(CultureInfo.InvariantCulture)).ToArray(); + return dims.Select(x => ((IConvertible)x).ToInt32(CultureInfo.InvariantCulture)).ToArray(); } set @@ -150,7 +148,7 @@ namespace Tensorflow /// /// Updates the shape of this tensor. /// - public virtual void set_shape(TensorShape shape) + public virtual void set_shape(TensorShape shape) { this.shape = shape.rank >= 0 ? shape.dims : null; } @@ -262,20 +260,22 @@ namespace Tensorflow protected override void DisposeUnmanagedResources(IntPtr handle) { c_api.TF_DeleteTensor(handle); - if (AllocationHandle == null) + if (AllocationHandle == null) return; if (AllocationType == AllocationType.GCHandle) { - ((GCHandle) AllocationHandle).Free(); + ((GCHandle)AllocationHandle).Free(); AllocationHandle = null; AllocationType = AllocationType.None; - } else if (AllocationType == AllocationType.Marshal) + } + else if (AllocationType == AllocationType.Marshal) { - Marshal.FreeHGlobal((IntPtr) AllocationHandle); + Marshal.FreeHGlobal((IntPtr)AllocationHandle); AllocationHandle = null; AllocationType = AllocationType.None; - } else + } + else throw new InvalidOperationException($"Tensor.AllocationHandle is not null ({AllocationHandle}) but AllocationType is not matched to a C# allocation type ({AllocationType})."); } diff --git a/src/TensorFlowNET.Core/Tensors/TensorArray.cs b/src/TensorFlowNET.Core/Tensors/TensorArray.cs index 369b9dc0..ccb2a1c7 100644 --- a/src/TensorFlowNET.Core/Tensors/TensorArray.cs +++ b/src/TensorFlowNET.Core/Tensors/TensorArray.cs @@ -14,9 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Operations; namespace Tensorflow @@ -43,7 +40,7 @@ namespace Tensorflow bool infer_shape = true, TensorShape element_shape = null, bool colocate_with_first_write_call = true, string name = null) { - _implementation = new _GraphTensorArray(dtype, + _implementation = new _GraphTensorArray(dtype, size: size, dynamic_size: dynamic_size, clear_after_read: clear_after_read, diff --git a/src/TensorFlowNET.Core/Tensors/TensorConverter.cs b/src/TensorFlowNET.Core/Tensors/TensorConverter.cs index dad051c6..5449db57 100644 --- a/src/TensorFlowNET.Core/Tensors/TensorConverter.cs +++ b/src/TensorFlowNET.Core/Tensors/TensorConverter.cs @@ -1,8 +1,7 @@ -using System; -using System.Threading.Tasks; -using NumSharp; -using NumSharp.Backends; +using NumSharp; using NumSharp.Utilities; +using System; +using System.Threading.Tasks; namespace Tensorflow { @@ -21,7 +20,7 @@ namespace Tensorflow { return new Tensor(astype == null ? nd : nd.astype(astype.Value.as_numpy_typecode(), false)); } - + /// /// Convert given to . /// @@ -32,7 +31,7 @@ namespace Tensorflow { return new Tensor(astype == null ? nd : nd.astype(astype.Value, false)); } - + /// /// Convert given to . /// @@ -58,7 +57,7 @@ namespace Tensorflow if (array.Rank != 1 || array.GetType().GetElementType()?.IsArray == true) //is multidim or jagged array = Arrays.Flatten(array); - return new Tensor((sbyte[]) array); + return new Tensor((sbyte[])array); } //is multidim or jagged, if so - use NDArrays constructor as it records shape. @@ -66,7 +65,7 @@ namespace Tensorflow return new Tensor(new NDArray(array)); #if _REGEN - #region Compute + #region Compute switch (arrtype) { %foreach supported_dtypes,supported_dtypes_lowercase% @@ -75,24 +74,24 @@ namespace Tensorflow default: throw new NotSupportedException(); } - #endregion + #endregion #else #region Compute switch (arrtype.GetTypeCode()) { - case NPTypeCode.Boolean: return new Tensor((bool[]) array); - case NPTypeCode.Byte: return new Tensor((byte[]) array); - case NPTypeCode.Int16: return new Tensor((short[]) array); - case NPTypeCode.UInt16: return new Tensor((ushort[]) array); - case NPTypeCode.Int32: return new Tensor((int[]) array); - case NPTypeCode.UInt32: return new Tensor((uint[]) array); - case NPTypeCode.Int64: return new Tensor((long[]) array); - case NPTypeCode.UInt64: return new Tensor((ulong[]) array); - case NPTypeCode.Char: return new Tensor((char[]) array); - case NPTypeCode.Double: return new Tensor((double[]) array); - case NPTypeCode.Single: return new Tensor((float[]) array); + case NPTypeCode.Boolean: return new Tensor((bool[])array); + case NPTypeCode.Byte: return new Tensor((byte[])array); + case NPTypeCode.Int16: return new Tensor((short[])array); + case NPTypeCode.UInt16: return new Tensor((ushort[])array); + case NPTypeCode.Int32: return new Tensor((int[])array); + case NPTypeCode.UInt32: return new Tensor((uint[])array); + case NPTypeCode.Int64: return new Tensor((long[])array); + case NPTypeCode.UInt64: return new Tensor((ulong[])array); + case NPTypeCode.Char: return new Tensor((char[])array); + case NPTypeCode.Double: return new Tensor((double[])array); + case NPTypeCode.Single: return new Tensor((float[])array); default: throw new NotSupportedException(); } @@ -100,7 +99,8 @@ namespace Tensorflow #endregion #endif - } else + } + else { //conversion is required. //by this point astype is not null. @@ -115,7 +115,8 @@ namespace Tensorflow ArrayConvert.To(array, astype.Value.as_numpy_typecode()), null ); - } catch (NotSupportedException) + } + catch (NotSupportedException) { //handle dtypes not supported by ArrayConvert var ret = Array.CreateInstance(astype_type, array.LongLength); @@ -139,13 +140,13 @@ namespace Tensorflow //No conversion required var constantType = typeof(T).as_dtype(); if (constantType == TF_DataType.TF_INT8) - return new Tensor((sbyte) (object) constant); + return new Tensor((sbyte)(object)constant); if (constantType == TF_DataType.TF_STRING) - return new Tensor((string) (object) constant); + return new Tensor((string)(object)constant); #if _REGEN - #region Compute + #region Compute switch (InfoOf.NPTypeCode) { %foreach supported_dtypes,supported_dtypes_lowercase% @@ -154,24 +155,24 @@ namespace Tensorflow default: throw new NotSupportedException(); } - #endregion + #endregion #else #region Compute switch (InfoOf.NPTypeCode) { - case NPTypeCode.Boolean: return new Tensor((bool) (object) constant); - case NPTypeCode.Byte: return new Tensor((byte) (object) constant); - case NPTypeCode.Int16: return new Tensor((short) (object) constant); - case NPTypeCode.UInt16: return new Tensor((ushort) (object) constant); - case NPTypeCode.Int32: return new Tensor((int) (object) constant); - case NPTypeCode.UInt32: return new Tensor((uint) (object) constant); - case NPTypeCode.Int64: return new Tensor((long) (object) constant); - case NPTypeCode.UInt64: return new Tensor((ulong) (object) constant); + case NPTypeCode.Boolean: return new Tensor((bool)(object)constant); + case NPTypeCode.Byte: return new Tensor((byte)(object)constant); + case NPTypeCode.Int16: return new Tensor((short)(object)constant); + case NPTypeCode.UInt16: return new Tensor((ushort)(object)constant); + case NPTypeCode.Int32: return new Tensor((int)(object)constant); + case NPTypeCode.UInt32: return new Tensor((uint)(object)constant); + case NPTypeCode.Int64: return new Tensor((long)(object)constant); + case NPTypeCode.UInt64: return new Tensor((ulong)(object)constant); case NPTypeCode.Char: return new Tensor(Converts.ToByte(constant)); - case NPTypeCode.Double: return new Tensor((double) (object) constant); - case NPTypeCode.Single: return new Tensor((float) (object) constant); + case NPTypeCode.Double: return new Tensor((double)(object)constant); + case NPTypeCode.Single: return new Tensor((float)(object)constant); default: throw new NotSupportedException(); } @@ -191,7 +192,7 @@ namespace Tensorflow var astype_np = astype?.as_numpy_typecode(); #if _REGEN - #region Compute + #region Compute switch (astype_np) { %foreach supported_dtypes,supported_dtypes_lowercase% @@ -200,31 +201,31 @@ namespace Tensorflow default: throw new NotSupportedException(); } - #endregion + #endregion #else - #region Compute - switch (astype_np) - { - case NPTypeCode.Boolean: return new Tensor(Converts.ToBoolean(constant)); - case NPTypeCode.Byte: return new Tensor(Converts.ToByte(constant)); - case NPTypeCode.Int16: return new Tensor(Converts.ToInt16(constant)); - case NPTypeCode.UInt16: return new Tensor(Converts.ToUInt16(constant)); - case NPTypeCode.Int32: return new Tensor(Converts.ToInt32(constant)); - case NPTypeCode.UInt32: return new Tensor(Converts.ToUInt32(constant)); - case NPTypeCode.Int64: return new Tensor(Converts.ToInt64(constant)); - case NPTypeCode.UInt64: return new Tensor(Converts.ToUInt64(constant)); - case NPTypeCode.Char: return new Tensor(Converts.ToByte(constant)); - case NPTypeCode.Double: return new Tensor(Converts.ToDouble(constant)); - case NPTypeCode.Single: return new Tensor(Converts.ToSingle(constant)); - default: - throw new NotSupportedException(); - } - #endregion + #region Compute + switch (astype_np) + { + case NPTypeCode.Boolean: return new Tensor(Converts.ToBoolean(constant)); + case NPTypeCode.Byte: return new Tensor(Converts.ToByte(constant)); + case NPTypeCode.Int16: return new Tensor(Converts.ToInt16(constant)); + case NPTypeCode.UInt16: return new Tensor(Converts.ToUInt16(constant)); + case NPTypeCode.Int32: return new Tensor(Converts.ToInt32(constant)); + case NPTypeCode.UInt32: return new Tensor(Converts.ToUInt32(constant)); + case NPTypeCode.Int64: return new Tensor(Converts.ToInt64(constant)); + case NPTypeCode.UInt64: return new Tensor(Converts.ToUInt64(constant)); + case NPTypeCode.Char: return new Tensor(Converts.ToByte(constant)); + case NPTypeCode.Double: return new Tensor(Converts.ToDouble(constant)); + case NPTypeCode.Single: return new Tensor(Converts.ToSingle(constant)); + default: + throw new NotSupportedException(); + } + #endregion #endif } - /// + /// /// Convert given to . /// /// The constant scalar to convert @@ -242,11 +243,11 @@ namespace Tensorflow case TF_DataType.TF_INT8: return new Tensor(Converts.ToSByte(constant)); default: - { - var astype_np = astype?.as_numpy_typecode(); + { + var astype_np = astype?.as_numpy_typecode(); #if _REGEN - #region Compute + #region Compute switch (astype_np) { %foreach supported_dtypes,supported_dtypes_lowercase% @@ -255,29 +256,29 @@ namespace Tensorflow default: throw new NotSupportedException(); } - #endregion + #endregion #else - #region Compute - switch (astype_np) - { - case NPTypeCode.Boolean: return new Tensor(Converts.ToBoolean(constant)); - case NPTypeCode.Byte: return new Tensor(Converts.ToByte(constant)); - case NPTypeCode.Int16: return new Tensor(Converts.ToInt16(constant)); - case NPTypeCode.UInt16: return new Tensor(Converts.ToUInt16(constant)); - case NPTypeCode.Int32: return new Tensor(Converts.ToInt32(constant)); - case NPTypeCode.UInt32: return new Tensor(Converts.ToUInt32(constant)); - case NPTypeCode.Int64: return new Tensor(Converts.ToInt64(constant)); - case NPTypeCode.UInt64: return new Tensor(Converts.ToUInt64(constant)); - case NPTypeCode.Char: return new Tensor(Converts.ToByte(constant)); - case NPTypeCode.Double: return new Tensor(Converts.ToDouble(constant)); - case NPTypeCode.Single: return new Tensor(Converts.ToSingle(constant)); - default: - throw new NotSupportedException(); - } - #endregion + #region Compute + switch (astype_np) + { + case NPTypeCode.Boolean: return new Tensor(Converts.ToBoolean(constant)); + case NPTypeCode.Byte: return new Tensor(Converts.ToByte(constant)); + case NPTypeCode.Int16: return new Tensor(Converts.ToInt16(constant)); + case NPTypeCode.UInt16: return new Tensor(Converts.ToUInt16(constant)); + case NPTypeCode.Int32: return new Tensor(Converts.ToInt32(constant)); + case NPTypeCode.UInt32: return new Tensor(Converts.ToUInt32(constant)); + case NPTypeCode.Int64: return new Tensor(Converts.ToInt64(constant)); + case NPTypeCode.UInt64: return new Tensor(Converts.ToUInt64(constant)); + case NPTypeCode.Char: return new Tensor(Converts.ToByte(constant)); + case NPTypeCode.Double: return new Tensor(Converts.ToDouble(constant)); + case NPTypeCode.Single: return new Tensor(Converts.ToSingle(constant)); + default: + throw new NotSupportedException(); + } + #endregion #endif - } + } } } diff --git a/src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs b/src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs index 7f4fb27d..9d6c4af6 100644 --- a/src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs +++ b/src/TensorFlowNET.Core/Tensors/TensorShape.Convert.cs @@ -1,7 +1,4 @@ using NumSharp; -using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Tensors/TensorShape.Equals.cs b/src/TensorFlowNET.Core/Tensors/TensorShape.Equals.cs index a8843e11..7f23cc58 100644 --- a/src/TensorFlowNET.Core/Tensors/TensorShape.Equals.cs +++ b/src/TensorFlowNET.Core/Tensors/TensorShape.Equals.cs @@ -1,8 +1,5 @@ -using NumSharp; -using System; -using System.Collections.Generic; +using System; using System.Linq; -using System.Text; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Tensors/TensorShape.cs b/src/TensorFlowNET.Core/Tensors/TensorShape.cs index 889b800f..116f52df 100644 --- a/src/TensorFlowNET.Core/Tensors/TensorShape.cs +++ b/src/TensorFlowNET.Core/Tensors/TensorShape.cs @@ -1,7 +1,6 @@ using NumSharp; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; @@ -66,14 +65,14 @@ namespace Tensorflow switch (proto.Dim.Count) { case 0: shape = new Shape(new int[0]); break; - case 1: shape = Shape.Vector((int) proto.Dim[0].Size); break; - case 2: shape = Shape.Matrix((int) proto.Dim[0].Size, (int) proto.Dim[1].Size); break; + case 1: shape = Shape.Vector((int)proto.Dim[0].Size); break; + case 2: shape = Shape.Matrix((int)proto.Dim[0].Size, (int)proto.Dim[1].Size); break; default: var protodims = proto.Dim; var len = protodims.Count; var dims = new int[len]; - for (int i = 0; i < len; i++) - dims[i] = (int) protodims[i].Size; + for (int i = 0; i < len; i++) + dims[i] = (int)protodims[i].Size; shape = new Shape(dims); break; @@ -93,7 +92,7 @@ namespace Tensorflow public TensorShape(int[][] dims) { - if(dims.Length == 1) + if (dims.Length == 1) { switch (dims[0].Length) { @@ -145,7 +144,7 @@ namespace Tensorflow public bool is_compatible_with(TensorShape shape2) { - if(dims != null && shape2.dims != null) + if (dims != null && shape2.dims != null) { if (dims.Length != shape2.dims.Length) return false; @@ -153,7 +152,7 @@ namespace Tensorflow return true; } - + public void assert_has_rank(int rank) { if (rank != ndim) @@ -247,10 +246,11 @@ namespace Tensorflow /// /// Returns a cloned array from . /// - public int[] as_list() { + public int[] as_list() + { if (shape.IsEmpty) throw new ValueError("as_list() is not defined on an unknown TensorShape."); - return (int[]) dims.Clone(); + return (int[])dims.Clone(); } public long[] as_list_long() @@ -262,14 +262,14 @@ namespace Tensorflow public int num_elements() { - if(is_fully_defined()) + if (is_fully_defined()) { var size = 1; foreach (var dim in dims) size *= dim; return size; - } - + } + return -1; } diff --git a/src/TensorFlowNET.Core/Tensors/Tensors.cs b/src/TensorFlowNET.Core/Tensors/Tensors.cs index 634b5a1f..bc48da2f 100644 --- a/src/TensorFlowNET.Core/Tensors/Tensors.cs +++ b/src/TensorFlowNET.Core/Tensors/Tensors.cs @@ -3,8 +3,6 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Text; -using Tensorflow.Gradients; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Tensors/constant_op.cs b/src/TensorFlowNET.Core/Tensors/constant_op.cs index 632d8370..212b7ebd 100644 --- a/src/TensorFlowNET.Core/Tensors/constant_op.cs +++ b/src/TensorFlowNET.Core/Tensors/constant_op.cs @@ -17,10 +17,10 @@ using NumSharp; using System; using System.Collections.Generic; -using Tensorflow.Eager; -using static Tensorflow.Binding; using System.Linq; using Tensorflow.Contexts; +using Tensorflow.Eager; +using static Tensorflow.Binding; namespace Tensorflow { @@ -43,11 +43,11 @@ namespace Tensorflow } /// Boolean that enables verification of a shape of values. - public static Tensor _constant_impl(object value, - TF_DataType dtype, - TensorShape shape, - string name, - bool verify_shape, + public static Tensor _constant_impl(object value, + TF_DataType dtype, + TensorShape shape, + string name, + bool verify_shape, bool allow_broadcast) { if (tf.Context.executing_eagerly()) @@ -76,10 +76,10 @@ namespace Tensorflow Graph g = ops.get_default_graph(); var tensor_value = new AttrValue(); - tensor_value.Tensor = tensor_util.make_tensor_proto(value, + tensor_value.Tensor = tensor_util.make_tensor_proto(value, dtype: dtype, shape: shape, - verify_shape: verify_shape, + verify_shape: verify_shape, allow_broadcast: allow_broadcast); var dtype_value = new AttrValue @@ -144,7 +144,7 @@ namespace Tensorflow } } - if(dtype == TF_DataType.TF_STRING && value is byte[] bytes) + if (dtype == TF_DataType.TF_STRING && value is byte[] bytes) { return new EagerTensor(bytes, ctx.DeviceName, TF_DataType.TF_STRING); } @@ -156,7 +156,7 @@ namespace Tensorflow case NDArray val: return new EagerTensor(val, ctx.DeviceName); //case TensorShape val: - //return new EagerTensor(val.dims, ctx.DeviceName); + //return new EagerTensor(val.dims, ctx.DeviceName); case string val: return new EagerTensor(val, ctx.DeviceName); case string[] val: @@ -216,14 +216,14 @@ namespace Tensorflow /// /// /// - public static Tensor _tensor_shape_tensor_conversion_function(TensorShape s, - TF_DataType dtype = TF_DataType.DtInvalid, - string name = null, + public static Tensor _tensor_shape_tensor_conversion_function(TensorShape s, + TF_DataType dtype = TF_DataType.DtInvalid, + string name = null, bool as_ref = false) { var s_list = s.dims; var int64_value = 0; - foreach(var dim in s_list) + foreach (var dim in s_list) { if (dim > Math.Pow(2, 31)) { diff --git a/src/TensorFlowNET.Core/Tensors/dtypes.cs b/src/TensorFlowNET.Core/Tensors/dtypes.cs index 94345b28..98e0066a 100644 --- a/src/TensorFlowNET.Core/Tensors/dtypes.cs +++ b/src/TensorFlowNET.Core/Tensors/dtypes.cs @@ -14,10 +14,9 @@ limitations under the License. ******************************************************************************/ +using NumSharp; using System; using System.Numerics; -using NumSharp; -using NumSharp.Backends; namespace Tensorflow { @@ -72,7 +71,7 @@ namespace Tensorflow return typeof(double); case TF_DataType.TF_STRING: return typeof(string); - case TF_DataType.TF_COMPLEX128: + case TF_DataType.TF_COMPLEX128: case TF_DataType.TF_COMPLEX64: //64 is also TF_COMPLEX return typeof(Complex); default: @@ -112,7 +111,7 @@ namespace Tensorflow return NPTypeCode.Double; case TF_DataType.TF_STRING: return NPTypeCode.String; - case TF_DataType.TF_COMPLEX128: + case TF_DataType.TF_COMPLEX128: case TF_DataType.TF_COMPLEX64: //64 is also TF_COMPLEX return NPTypeCode.Complex; default: @@ -132,7 +131,7 @@ namespace Tensorflow switch (type.Name) { case "Char": - dtype = dtype ?? TF_DataType.TF_UINT8; + dtype = dtype ?? TF_DataType.TF_UINT8; break; case "SByte": dtype = TF_DataType.TF_INT8; @@ -228,7 +227,7 @@ namespace Tensorflow { return (int)type < 100 ? (TF_DataType)((int)type + 100) : type; } - + public static long min(this TF_DataType type) { throw new NotImplementedException($"min {type.name()}"); @@ -283,7 +282,7 @@ namespace Tensorflow { return self.as_datatype_enum() == other.as_datatype_enum(); } - + public static TF_DataType real_dtype(this TF_DataType self) { TF_DataType base_ = self.as_base_dtype(); diff --git a/src/TensorFlowNET.Core/Tensors/shape_utils.cs b/src/TensorFlowNET.Core/Tensors/shape_utils.cs index 0974dc5b..254cdad8 100644 --- a/src/TensorFlowNET.Core/Tensors/shape_utils.cs +++ b/src/TensorFlowNET.Core/Tensors/shape_utils.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/Tensors/tensor_util.cs b/src/TensorFlowNET.Core/Tensors/tensor_util.cs index 13dda9ce..70a880b5 100644 --- a/src/TensorFlowNET.Core/Tensors/tensor_util.cs +++ b/src/TensorFlowNET.Core/Tensors/tensor_util.cs @@ -17,7 +17,6 @@ using NumSharp; using System; using System.Linq; -using NumSharp.Utilities; using System.Text; using Tensorflow.Eager; @@ -64,7 +63,7 @@ namespace Tensorflow { var shape = tensor.TensorShape.Dim.Select(x => (int)x.Size).ToArray(); int num_elements = np.prod(shape); - var tensor_dtype = tensor.Dtype.as_numpy_dtype(); + var tensor_dtype = tensor.Dtype.as_numpy_dtype(); if (tensor.TensorContent.Length > 0) { @@ -148,7 +147,7 @@ namespace Tensorflow // If shape is not given, get the shape from the numpy array. if (shape == null) { - if(numpy_dtype == TF_DataType.TF_STRING) + if (numpy_dtype == TF_DataType.TF_STRING) { // scalar string shape = new int[0]; @@ -189,9 +188,9 @@ namespace Tensorflow } else if (values is string[] str_values) tensor_proto.StringVal.AddRange(str_values.Select(x => Google.Protobuf.ByteString.CopyFromUtf8(x))); - else if(values is byte[] byte_values) + else if (values is byte[] byte_values) tensor_proto.TensorContent = Google.Protobuf.ByteString.CopyFrom(byte_values); - + return tensor_proto; } @@ -225,7 +224,7 @@ namespace Tensorflow return tensor_proto; } - public static TensorShape constant_value_as_shape(Tensor tensor) + public static TensorShape constant_value_as_shape(Tensor tensor) { bool hasattr(Graph property, string attr) { @@ -258,39 +257,42 @@ scalar with value '-1' to describe an unknown shape.", value_)); } var shape = tensor.TensorShape.with_rank(1); - if (shape == new TensorShape(new int[] {1})) + if (shape == new TensorShape(new int[] { 1 })) { - return new TensorShape(new int[] {}); - } else if (tensor.op.type == "Cast") + return new TensorShape(new int[] { }); + } + else if (tensor.op.type == "Cast") { var pre_cast = constant_value_as_shape(tensor.op.inputs[0]); if (pre_cast.dims == null) return pre_cast; var cast_dtype = dtypes.as_dtype((Type)tensor.op.get_attr("DstT")); - if (!Array.Exists(new [] {dtypes.int32, dtypes.int64}, cast_dtype_ => cast_dtype_ == cast_dtype)) + if (!Array.Exists(new[] { dtypes.int32, dtypes.int64 }, cast_dtype_ => cast_dtype_ == cast_dtype)) return tensor.TensorShape.unknown_shape(shape.dims[0]); - - int[] x_ = {}; + + int[] x_ = { }; foreach (var x in pre_cast.as_list()) if (x != -1) x_[x_.Length] = x; else x_[x_.Length] = -1; var dest_dtype_shape_array = np.array(x_).astype(cast_dtype.as_numpy_dtype()); - - int[] y_ = {}; - foreach(int y in dest_dtype_shape_array) + + int[] y_ = { }; + foreach (int y in dest_dtype_shape_array) if (y >= 0) y_[y_.Length] = y; else y_[y_.Length] = -1; return new TensorShape(y_); - } else if (tensor.op.type == "Shape") + } + else if (tensor.op.type == "Shape") { return tensor.op.inputs[0].shape; - } else if (tensor.op.type == "Pack") + } + else if (tensor.op.type == "Pack") { - var ret_ = new TensorShape(new int[] {}); + var ret_ = new TensorShape(new int[] { }); if ((int)tensor.op.get_attr("axis") != 0) throw new ValueError(String.Format( @"Since rank 1 inputs are expected, Pack's axis: {0} must be 0, otherwise it @@ -302,36 +304,40 @@ would not be rank 1.", tensor.op.get_attr("axis"))); if (pack_input_val < 0) { new_dim = new Dimension(-1); - } else if (pack_input_val == null) + } + else if (pack_input_val == null) { new_dim = new Dimension(-1); - } else + } + else { new_dim = new Dimension(pack_input_val); } - ret_ = ret_.concatenate(new int[] {new_dim}); + ret_ = ret_.concatenate(new int[] { new_dim }); } return ret_; - } else if (tensor.op.type == "Concat") + } + else if (tensor.op.type == "Concat") { - var ret_ = new TensorShape(new int[] {}); + var ret_ = new TensorShape(new int[] { }); - var inputlist_ = new ArraySegment(tensor.op.inputs, 1, + var inputlist_ = new ArraySegment(tensor.op.inputs, 1, tensor.op.inputs.Length - 1); foreach (var concat_input in inputlist_) { ret_ = ret_.concatenate(constant_value_as_shape(concat_input)); } return ret_; - } else if (tensor.op.type == "StridedSlice") + } + else if (tensor.op.type == "StridedSlice") { try { var begin = constant_value(tensor.op.inputs[1]); var end = constant_value(tensor.op.inputs[2]); var strides = constant_value(tensor.op.inputs[3]); - if (new [] {begin, end, strides}.All(x => x == null)) - { + if (new[] { begin, end, strides }.All(x => x == null)) + { begin = begin[0]; end = end[0]; strides = strides[0]; @@ -349,14 +355,15 @@ would not be rank 1.", tensor.op.get_attr("axis"))); var ellipsis_mask = tensor.op.get_attr("ellipsis_mask"); var new_axis_mask = tensor.op.get_attr("new_axis_mask"); var shrink_axis_mask = tensor.op.get_attr("shrink_axis_mask"); - + bool valid_attributes; if (!(bool)ellipsis_mask && !(bool)new_axis_mask && !(bool)shrink_axis_mask && !((bool)begin_mask || (int)begin_mask == 1) && !((bool)end_mask || (int)end_mask == 1)) { valid_attributes = true; - } else {valid_attributes = false;} + } + else { valid_attributes = false; } if (valid_attributes) { // sorry for the mess here, but this hacky solution was the best way @@ -374,13 +381,15 @@ would not be rank 1.", tensor.op.get_attr("axis"))); return ret_; } } - } catch (Exception ex) - { - if (ex is ValueError || ex is TypeError) {} } - } else if (tensor.op.type == "Placeholder" && - tensor.op.graph.building_function && - hasattr(tensor.op.graph, "internal_captures")) + catch (Exception ex) + { + if (ex is ValueError || ex is TypeError) { } + } + } + else if (tensor.op.type == "Placeholder" && + tensor.op.graph.building_function && + hasattr(tensor.op.graph, "internal_captures")) { int i = 0; foreach (Tensor capture in tensor.op.graph.internal_captures()) @@ -399,7 +408,7 @@ would not be rank 1.", tensor.op.get_attr("axis"))); var value = constant_value(tensor); if (value != null) { - int[] d_ = {}; + int[] d_ = { }; foreach (int d in value) { if (d >= 0) @@ -412,7 +421,7 @@ would not be rank 1.", tensor.op.get_attr("axis"))); } return ret; } - + public static NDArray convert_to_numpy_ndarray(object values) { NDArray nd; @@ -487,7 +496,7 @@ would not be rank 1.", tensor.op.get_attr("axis"))); for (int i = 0; i < dims.Length; i++) { var dim = new TensorShapeProto.Types.Dim(); - switch(dims[i]) + switch (dims[i]) { case int n: dim.Size = n; @@ -551,7 +560,7 @@ would not be rank 1.", tensor.op.get_attr("axis"))); { var dtype = tensor.dtype; - if(dtype == TF_DataType.TF_STRING && tensor.NDims > 0) + if (dtype == TF_DataType.TF_STRING && tensor.NDims > 0) { return $"['{string.Join("', '", tensor.StringData())}']"; } diff --git a/src/TensorFlowNET.Core/Tensors/tf.constant.cs b/src/TensorFlowNET.Core/Tensors/tf.constant.cs index d2111ca2..baa422a4 100644 --- a/src/TensorFlowNET.Core/Tensors/tf.constant.cs +++ b/src/TensorFlowNET.Core/Tensors/tf.constant.cs @@ -14,9 +14,6 @@ limitations under the License. ******************************************************************************/ -using NumSharp; -using Tensorflow.Eager; - namespace Tensorflow { public partial class tensorflow @@ -40,10 +37,10 @@ namespace Tensorflow verify_shape: false, allow_broadcast: true); - public Tensor zeros(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) + public Tensor zeros(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) => array_ops.zeros(shape, dtype, name); - public Tensor ones(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) + public Tensor ones(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) => array_ops.ones(shape, dtype, name); public Tensor size(Tensor input, diff --git a/src/TensorFlowNET.Core/Training/AdamOptimizer.cs b/src/TensorFlowNET.Core/Training/AdamOptimizer.cs index 4151843b..c64154e5 100644 --- a/src/TensorFlowNET.Core/Training/AdamOptimizer.cs +++ b/src/TensorFlowNET.Core/Training/AdamOptimizer.cs @@ -124,7 +124,7 @@ namespace Tensorflow.Train _create_non_slot_variable(initial_value: _beta2, name: "beta2_power", colocate_with: first_var); // Create slots for the first and second moments. - foreach(var v in var_list) + foreach (var v in var_list) { _zeros_slot(v, "m", Name); _zeros_slot(v, "v", Name); diff --git a/src/TensorFlowNET.Core/Training/Coordinator.cs b/src/TensorFlowNET.Core/Training/Coordinator.cs index 33c787b4..b00ef3de 100644 --- a/src/TensorFlowNET.Core/Training/Coordinator.cs +++ b/src/TensorFlowNET.Core/Training/Coordinator.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tensorflow.Training +namespace Tensorflow.Training { /// /// A coordinator for threads diff --git a/src/TensorFlowNET.Core/Training/ExponentialMovingAverage.cs b/src/TensorFlowNET.Core/Training/ExponentialMovingAverage.cs index bdcc69cc..e3f454bc 100644 --- a/src/TensorFlowNET.Core/Training/ExponentialMovingAverage.cs +++ b/src/TensorFlowNET.Core/Training/ExponentialMovingAverage.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using static Tensorflow.Binding; namespace Tensorflow.Train @@ -35,7 +33,7 @@ namespace Tensorflow.Train if (var_list == null) var_list = variables.trainable_variables() as RefVariable[]; - foreach(var var in var_list) + foreach (var var in var_list) { if (!_averages.ContainsKey(var)) { diff --git a/src/TensorFlowNET.Core/Training/GradientDescentOptimizer.cs b/src/TensorFlowNET.Core/Training/GradientDescentOptimizer.cs index fed8142e..9173d6ba 100644 --- a/src/TensorFlowNET.Core/Training/GradientDescentOptimizer.cs +++ b/src/TensorFlowNET.Core/Training/GradientDescentOptimizer.cs @@ -37,7 +37,7 @@ namespace Tensorflow.Train /// for changing these values across different invocations of optimizer /// functions. /// - public GradientDescentOptimizer(float learning_rate, bool use_locking = false, string name = "GradientDescent") + public GradientDescentOptimizer(float learning_rate, bool use_locking = false, string name = "GradientDescent") : base(learning_rate, use_locking, name) { _lr = learning_rate; @@ -53,12 +53,12 @@ namespace Tensorflow.Train public override void _prepare() { - if(!_useTensor) + if (!_useTensor) { var lr = _call_if_callable(_lr); _lr_t = ops.convert_to_tensor(lr, name: "learning_rate"); } - + } } } diff --git a/src/TensorFlowNET.Core/Training/Optimizer.cs b/src/TensorFlowNET.Core/Training/Optimizer.cs index d22562d5..1979c357 100644 --- a/src/TensorFlowNET.Core/Training/Optimizer.cs +++ b/src/TensorFlowNET.Core/Training/Optimizer.cs @@ -105,17 +105,17 @@ namespace Tensorflow /// An Operation that updates the variables in `var_list`. If `global_step` /// was not `None`, that operation also increments `global_step`. /// - public Operation minimize(Tensor loss, + public Operation minimize(Tensor loss, IVariableV1 global_step = null, - List var_list=null, + List var_list = null, GateGradientType gate_gradients = GateGradientType.GATE_OP, - int? aggregation_method=null, - bool colocate_gradients_with_ops = false, string name=null, Tensor grad_loss=null) + int? aggregation_method = null, + bool colocate_gradients_with_ops = false, string name = null, Tensor grad_loss = null) { // TODO: strongly type aggregation_method - var grads_and_vars = compute_gradients(loss, var_list:var_list, - gate_gradients: gate_gradients, - aggregation_method:aggregation_method, + var grads_and_vars = compute_gradients(loss, var_list: var_list, + gate_gradients: gate_gradients, + aggregation_method: aggregation_method, colocate_gradients_with_ops: colocate_gradients_with_ops, grad_loss: grad_loss); @@ -124,7 +124,7 @@ namespace Tensorflow throw new ValueError($"No gradients provided for any variable, check your graph for ops" + $" that do not support gradients, between variables {string.Join(",", vars_with_grad.Select(x => x.Name))} and loss {loss}."); - return apply_gradients(grads_and_vars, global_step:global_step, name:name); + return apply_gradients(grads_and_vars, global_step: global_step, name: name); } /// @@ -148,7 +148,7 @@ namespace Tensorflow var converted_grads_and_vars = new List<(Tensor, IVariableV1, _OptimizableVariable)>(); foreach (var (g, v) in grads_and_vars) { - if(g != null) + if (g != null) { // Convert the grad to Tensor or IndexedSlices if necessary. var gR = ops.convert_to_tensor_or_indexed_slices(g); @@ -170,7 +170,7 @@ namespace Tensorflow name = scope; _prepare(); - foreach(var (grad, var, processor) in converted_grads_and_vars) + foreach (var (grad, var, processor) in converted_grads_and_vars) { if (grad == null) continue; @@ -190,8 +190,8 @@ namespace Tensorflow } else { - tf_with(ops.control_dependencies(new object[] {_finish(update_ops.ToArray(), "update")}), dep => - { + tf_with(ops.control_dependencies(new object[] { _finish(update_ops.ToArray(), "update") }), dep => + { // ops.colocate_with(global_step); // TODO: port this if branch once ResourceVariable has been ported! //if (global_step is ResourceVariable) @@ -205,11 +205,11 @@ namespace Tensorflow //} //else { - apply_updates = state_ops.assign_add(global_step, - ops.convert_to_tensor(1, dtype: global_step.dtype), - name: name); - } - }); + apply_updates = state_ops.assign_add(global_step, + ops.convert_to_tensor(1, dtype: global_step.dtype), + name: name); + } + }); } if (!tf.Context.executing_eagerly()) @@ -232,7 +232,7 @@ namespace Tensorflow /// protected virtual void _create_slots(IVariableV1[] var_list) { - + } /// @@ -247,12 +247,12 @@ namespace Tensorflow var graph = colocate_with.Graph; var key = $"{name}.{graph.graph_key}"; var v = _non_slot_dict.ContainsKey(key) ? _non_slot_dict[key] : null; - if(v == null) + if (v == null) { _maybe_initialize_trackable(); v = variable_scope.default_variable_creator( - initial_value, - name: name, + initial_value, + name: name, dtype: colocate_with.dtype.as_base_dtype(), trainable: false, use_resource: resource_variable_ops.is_resource_variable( @@ -392,7 +392,7 @@ namespace Tensorflow // Scale loss if using a "mean" loss reduction and multiple replicas. loss = _scale_loss(loss); - if(var_list == null) + if (var_list == null) { var vars = ops.get_collection(tf.GraphKeys.TRAINABLE_RESOURCE_VARIABLES); var tmp = variables.trainable_variables(); @@ -462,7 +462,7 @@ namespace Tensorflow protected Dictionary _slot_dict(string slot_name) { var named_slots = _slots.ContainsKey(slot_name) ? _slots[slot_name] : null; - if(named_slots == null) + if (named_slots == null) { named_slots = new Dictionary(); _slots[slot_name] = named_slots; diff --git a/src/TensorFlowNET.Core/Training/QueueRunner.cs b/src/TensorFlowNET.Core/Training/QueueRunner.cs index 0a0d9c2e..30d3af5f 100644 --- a/src/TensorFlowNET.Core/Training/QueueRunner.cs +++ b/src/TensorFlowNET.Core/Training/QueueRunner.cs @@ -14,9 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; -using System.Collections.Generic; -using System.Text; using Tensorflow.Queues; namespace Tensorflow.Train diff --git a/src/TensorFlowNET.Core/Training/Saving/BaseSaverBuilder.cs b/src/TensorFlowNET.Core/Training/Saving/BaseSaverBuilder.cs index 9bb763e3..21b9df91 100644 --- a/src/TensorFlowNET.Core/Training/Saving/BaseSaverBuilder.cs +++ b/src/TensorFlowNET.Core/Training/Saving/BaseSaverBuilder.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Tensorflow.Operations; using static Tensorflow.Binding; namespace Tensorflow @@ -45,7 +44,7 @@ namespace Tensorflow foreach (var saveable in saveables) { - foreach(var spec in saveable.specs) + foreach (var spec in saveable.specs) { tensor_names.Add(spec.name); tensors.Add(spec.tensor); @@ -166,7 +165,7 @@ namespace Tensorflow default: throw new NotImplementedException("_build_internal.check_collection_list"); }*/ - + } return new SaverDef() @@ -198,7 +197,7 @@ namespace Tensorflow /// /// /// An Operation that restores the variables. - public Operation _AddRestoreOps(Tensor filename_tensor, + public Operation _AddRestoreOps(Tensor filename_tensor, MySaveableObject[] saveables, bool restore_sequentially, bool reshape, diff --git a/src/TensorFlowNET.Core/Training/Saving/ISaverBuilder.cs b/src/TensorFlowNET.Core/Training/Saving/ISaverBuilder.cs index 26f0658c..c3275dd2 100644 --- a/src/TensorFlowNET.Core/Training/Saving/ISaverBuilder.cs +++ b/src/TensorFlowNET.Core/Training/Saving/ISaverBuilder.cs @@ -22,9 +22,9 @@ namespace Tensorflow Tensor[] bulk_restore(Tensor filename_tensor, MySaveableObject[] saveables, int preferred_shard, bool restore_sequentially); - SaverDef _build_internal(IVariableV1[] names_to_saveables, - bool reshape = false, - bool sharded = false, + SaverDef _build_internal(IVariableV1[] names_to_saveables, + bool reshape = false, + bool sharded = false, int max_to_keep = 5, float keep_checkpoint_every_n_hours = 10000, string name = null, diff --git a/src/TensorFlowNET.Core/Training/Saving/ResourceVariableSaveable.cs b/src/TensorFlowNET.Core/Training/Saving/ResourceVariableSaveable.cs index d71ac4b9..415671c2 100644 --- a/src/TensorFlowNET.Core/Training/Saving/ResourceVariableSaveable.cs +++ b/src/TensorFlowNET.Core/Training/Saving/ResourceVariableSaveable.cs @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ******************************************************************************/ -using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Training/Saving/Saver.cs b/src/TensorFlowNET.Core/Training/Saving/Saver.cs index 0deee23f..61de4f59 100644 --- a/src/TensorFlowNET.Core/Training/Saving/Saver.cs +++ b/src/TensorFlowNET.Core/Training/Saving/Saver.cs @@ -86,7 +86,7 @@ namespace Tensorflow if (!defer_build) build(); - if(_saver_def != null) + if (_saver_def != null) { _check_saver_def(); _write_version = _saver_def.Version; @@ -214,7 +214,7 @@ namespace Tensorflow return _is_empty ? string.Empty : UTF8Encoding.UTF8.GetString((byte[])model_checkpoint_path[0]); } - public (Saver, object) import_meta_graph(string meta_graph_or_file, + public (Saver, object) import_meta_graph(string meta_graph_or_file, bool clear_devices = false, string import_scope = "") { @@ -263,7 +263,7 @@ namespace Tensorflow /// /// /// - public MetaGraphDef export_meta_graph(string filename= "", + public MetaGraphDef export_meta_graph(string filename = "", string[] collection_list = null, string export_scope = "", bool as_text = false, @@ -290,9 +290,9 @@ namespace Tensorflow SaverDef saver_def = null, string[] collection_list = null, bool as_text = false, - bool clear_devices= false, - bool clear_extraneous_savers= false, - bool strip_default_attrs= false, + bool clear_devices = false, + bool clear_extraneous_savers = false, + bool strip_default_attrs = false, string export_scope = "") { var meta_graph_def = meta_graph.export_scoped_meta_graph( diff --git a/src/TensorFlowNET.Core/Training/Saving/checkpoint_management.py.cs b/src/TensorFlowNET.Core/Training/Saving/checkpoint_management.py.cs index 242464bd..474336f4 100644 --- a/src/TensorFlowNET.Core/Training/Saving/checkpoint_management.py.cs +++ b/src/TensorFlowNET.Core/Training/Saving/checkpoint_management.py.cs @@ -14,13 +14,13 @@ limitations under the License. ******************************************************************************/ +using Protobuf.Text; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using static Tensorflow.SaverDef.Types; using static Tensorflow.Binding; -using Protobuf.Text; +using static Tensorflow.SaverDef.Types; namespace Tensorflow { @@ -45,7 +45,7 @@ namespace Tensorflow float? last_preserved_timestamp = null ) { - CheckpointState ckpt = null; + CheckpointState ckpt = null; // Writes the "checkpoint" file for the coordinator for later restoration. string coord_checkpoint_filename = _GetCheckpointFilename(save_dir, latest_filename); if (save_relative_paths) @@ -112,7 +112,7 @@ namespace Tensorflow .Select(x => x.Substring(save_dir.Length + 1)) .ToList(); } - + var coord_checkpoint_proto = new CheckpointState() { @@ -135,7 +135,7 @@ namespace Tensorflow /// /// /// - public static string meta_graph_filename(string checkpoint_filename, string meta_graph_suffix= "meta") + public static string meta_graph_filename(string checkpoint_filename, string meta_graph_suffix = "meta") { string basename = checkpoint_filename; string suffixed_filename = basename + "." + meta_graph_suffix; @@ -170,7 +170,7 @@ namespace Tensorflow { // Pick the latest checkpoint based on checkpoint state. var ckpt = get_checkpoint_state(checkpoint_dir, latest_filename); - if(ckpt != null && !string.IsNullOrEmpty(ckpt.ModelCheckpointPath)) + if (ckpt != null && !string.IsNullOrEmpty(ckpt.ModelCheckpointPath)) { // Look for either a V2 path or a V1 path, with priority for V2. var v2_path = _prefix_to_checkpoint_path(ckpt.ModelCheckpointPath, CheckpointFormatVersion.V2); @@ -197,7 +197,7 @@ namespace Tensorflow // prepend checkpoint_dir. if (!Path.IsPathRooted(ckpt.ModelCheckpointPath)) ckpt.ModelCheckpointPath = Path.Combine(checkpoint_dir, ckpt.ModelCheckpointPath); - foreach(var i in range(len(ckpt.AllModelCheckpointPaths))) + foreach (var i in range(len(ckpt.AllModelCheckpointPaths))) { var p = ckpt.AllModelCheckpointPaths[i]; if (!Path.IsPathRooted(p)) diff --git a/src/TensorFlowNET.Core/Training/Saving/saveable_object_util.py.cs b/src/TensorFlowNET.Core/Training/Saving/saveable_object_util.py.cs index 7c2d3330..097ca8b3 100644 --- a/src/TensorFlowNET.Core/Training/Saving/saveable_object_util.py.cs +++ b/src/TensorFlowNET.Core/Training/Saving/saveable_object_util.py.cs @@ -79,7 +79,7 @@ namespace Tensorflow op_list = op_list.OrderBy(x => x.Name).ToArray(); var names_to_saveables = new Dictionary(); - foreach(var var in op_list) + foreach (var var in op_list) { bool resource_or_ref_variable = var is RefVariable || var is ResourceVariable; if (false) diff --git a/src/TensorFlowNET.Core/Training/Saving/saver.py.cs b/src/TensorFlowNET.Core/Training/Saving/saver.py.cs index 2b024c08..9307dc5d 100644 --- a/src/TensorFlowNET.Core/Training/Saving/saver.py.cs +++ b/src/TensorFlowNET.Core/Training/Saving/saver.py.cs @@ -51,16 +51,16 @@ namespace Tensorflow /// /// /// - public static Saver _create_saver_from_imported_meta_graph(MetaGraphDef meta_graph_def, - string import_scope, + public static Saver _create_saver_from_imported_meta_graph(MetaGraphDef meta_graph_def, + string import_scope, Dictionary imported_vars) { - if(meta_graph_def.SaverDef != null) + if (meta_graph_def.SaverDef != null) { // Infer the scope that is prepended by `import_scoped_meta_graph`. string scope = import_scope; var var_names = imported_vars.Keys.ToArray(); - if(var_names.Length > 0) + if (var_names.Length > 0) { var sample_key = var_names[0]; var sample_var = imported_vars[sample_key]; @@ -70,7 +70,7 @@ namespace Tensorflow } else { - if(variables._all_saveable_objects(scope: import_scope).Length > 0) + if (variables._all_saveable_objects(scope: import_scope).Length > 0) { // Return the default saver instance for all graph variables. return new Saver(); @@ -85,7 +85,7 @@ namespace Tensorflow } } - public static string freeze_graph(string checkpoint_dir, + public static string freeze_graph(string checkpoint_dir, string output_pb_name, string[] output_node_names) { @@ -112,7 +112,7 @@ namespace Tensorflow { var bytes = File.ReadAllBytes(freeze_graph_pb); var graph = tf.Graph().as_default(); - importer.import_graph_def(GraphDef.Parser.ParseFrom(bytes), + importer.import_graph_def(GraphDef.Parser.ParseFrom(bytes), name: name); return graph; } diff --git a/src/TensorFlowNET.Core/Training/SecondOrStepTimer.cs b/src/TensorFlowNET.Core/Training/SecondOrStepTimer.cs index a18ba58f..cc5b7488 100644 --- a/src/TensorFlowNET.Core/Training/SecondOrStepTimer.cs +++ b/src/TensorFlowNET.Core/Training/SecondOrStepTimer.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Tensorflow.Training { diff --git a/src/TensorFlowNET.Core/Training/SessionRunArgs.cs b/src/TensorFlowNET.Core/Training/SessionRunArgs.cs index 7c089634..f65b4524 100644 --- a/src/TensorFlowNET.Core/Training/SessionRunArgs.cs +++ b/src/TensorFlowNET.Core/Training/SessionRunArgs.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Training +namespace Tensorflow.Training { public class SessionRunArgs { diff --git a/src/TensorFlowNET.Core/Training/SessionRunContext.cs b/src/TensorFlowNET.Core/Training/SessionRunContext.cs index 6c119593..c30ee7dc 100644 --- a/src/TensorFlowNET.Core/Training/SessionRunContext.cs +++ b/src/TensorFlowNET.Core/Training/SessionRunContext.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Training +namespace Tensorflow.Training { public class SessionRunContext { diff --git a/src/TensorFlowNET.Core/Training/SessionRunHook.cs b/src/TensorFlowNET.Core/Training/SessionRunHook.cs index ce3a2200..28552fa5 100644 --- a/src/TensorFlowNET.Core/Training/SessionRunHook.cs +++ b/src/TensorFlowNET.Core/Training/SessionRunHook.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tensorflow.Training +namespace Tensorflow.Training { /// /// Hook to extend calls to MonitoredSession.run(). diff --git a/src/TensorFlowNET.Core/Training/SessionRunValues.cs b/src/TensorFlowNET.Core/Training/SessionRunValues.cs index d93e8347..c0135d2c 100644 --- a/src/TensorFlowNET.Core/Training/SessionRunValues.cs +++ b/src/TensorFlowNET.Core/Training/SessionRunValues.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Training +namespace Tensorflow.Training { public class SessionRunValues { diff --git a/src/TensorFlowNET.Core/Training/SlotCreator.cs b/src/TensorFlowNET.Core/Training/SlotCreator.cs index 408f639c..d8b597d9 100644 --- a/src/TensorFlowNET.Core/Training/SlotCreator.cs +++ b/src/TensorFlowNET.Core/Training/SlotCreator.cs @@ -70,7 +70,7 @@ namespace Tensorflow.Train /// Creates a slot initialized using an `Initializer`. /// /// - public IVariableV1 create_slot_with_initializer(IVariableV1 primary, IInitializer initializer, TensorShape shape, + public IVariableV1 create_slot_with_initializer(IVariableV1 primary, IInitializer initializer, TensorShape shape, TF_DataType dtype, string name, bool colocate_with_primary = true) { var validate_shape = shape.is_fully_defined(); @@ -91,7 +91,7 @@ namespace Tensorflow.Train /// /// /// - private IVariableV1 _create_slot_var(IVariableV1 primary, object val, string scope, bool validate_shape, + private IVariableV1 _create_slot_var(IVariableV1 primary, object val, string scope, bool validate_shape, TensorShape shape, TF_DataType dtype) { bool use_resource = primary is ResourceVariable; diff --git a/src/TensorFlowNET.Core/Training/Trackable.cs b/src/TensorFlowNET.Core/Training/Trackable.cs index d85b57ff..79d6dca9 100644 --- a/src/TensorFlowNET.Core/Training/Trackable.cs +++ b/src/TensorFlowNET.Core/Training/Trackable.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using static Tensorflow.Binding; namespace Tensorflow.Train diff --git a/src/TensorFlowNET.Core/Training/TrainingUtil.cs b/src/TensorFlowNET.Core/Training/TrainingUtil.cs index dbfe916b..1fd92335 100644 --- a/src/TensorFlowNET.Core/Training/TrainingUtil.cs +++ b/src/TensorFlowNET.Core/Training/TrainingUtil.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using static Tensorflow.Binding; namespace Tensorflow.Train @@ -44,7 +42,7 @@ namespace Tensorflow.Train return null; } } - + return global_step_tensor; } diff --git a/src/TensorFlowNET.Core/Training/_HookTimer.cs b/src/TensorFlowNET.Core/Training/_HookTimer.cs index 295de165..8c7b299f 100644 --- a/src/TensorFlowNET.Core/Training/_HookTimer.cs +++ b/src/TensorFlowNET.Core/Training/_HookTimer.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tensorflow.Training +namespace Tensorflow.Training { /// /// Base timer for determining when Hooks should trigger. diff --git a/src/TensorFlowNET.Core/Training/_MonitoredSession.cs b/src/TensorFlowNET.Core/Training/_MonitoredSession.cs index e89b1b89..26e98639 100644 --- a/src/TensorFlowNET.Core/Training/_MonitoredSession.cs +++ b/src/TensorFlowNET.Core/Training/_MonitoredSession.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Tensorflow.Train +namespace Tensorflow.Train { internal class _MonitoredSession { diff --git a/src/TensorFlowNET.Core/Training/gen_training_ops.cs b/src/TensorFlowNET.Core/Training/gen_training_ops.cs index c141d59e..675f920f 100644 --- a/src/TensorFlowNET.Core/Training/gen_training_ops.cs +++ b/src/TensorFlowNET.Core/Training/gen_training_ops.cs @@ -15,8 +15,6 @@ ******************************************************************************/ using System; -using System.Linq; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow @@ -41,8 +39,8 @@ namespace Tensorflow throw new NotImplementedException(""); } - public static Tensor apply_adam(Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor beta2_power, - Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, + public static Tensor apply_adam(Tensor var, Tensor m, Tensor v, Tensor beta1_power, Tensor beta2_power, + Tensor lr, Tensor beta1, Tensor beta2, Tensor epsilon, Tensor grad, bool use_locking = false, bool use_nesterov = false, string name = null) { var _op = tf.OpDefLib._apply_op_helper("ApplyAdam", name, new diff --git a/src/TensorFlowNET.Core/Training/learning_rate_decay.cs b/src/TensorFlowNET.Core/Training/learning_rate_decay.cs index 0315789c..10259cb6 100644 --- a/src/TensorFlowNET.Core/Training/learning_rate_decay.cs +++ b/src/TensorFlowNET.Core/Training/learning_rate_decay.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Tensorflow.Training { diff --git a/src/TensorFlowNET.Core/Training/moving_averages.cs b/src/TensorFlowNET.Core/Training/moving_averages.cs index be91a4b7..f9937482 100644 --- a/src/TensorFlowNET.Core/Training/moving_averages.cs +++ b/src/TensorFlowNET.Core/Training/moving_averages.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using static Tensorflow.Binding; +using static Tensorflow.Binding; namespace Tensorflow.Train { diff --git a/src/TensorFlowNET.Core/Util/UnmanagedExtensions.cs b/src/TensorFlowNET.Core/Util/UnmanagedExtensions.cs index 02b8bb73..8a03f627 100644 --- a/src/TensorFlowNET.Core/Util/UnmanagedExtensions.cs +++ b/src/TensorFlowNET.Core/Util/UnmanagedExtensions.cs @@ -1,15 +1,15 @@ -using System; +using NumSharp.Backends.Unmanaged; +using System; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using NumSharp.Backends.Unmanaged; namespace Tensorflow.Util { public static class UnmanagedExtensions { //internally UnmanagedMemoryStream can't construct with null address. - private static readonly unsafe byte* _empty = (byte*) Marshal.AllocHGlobal(1); + private static readonly unsafe byte* _empty = (byte*)Marshal.AllocHGlobal(1); /// /// Creates a memory stream based on given . @@ -65,7 +65,7 @@ namespace Tensorflow.Util return new UnmanagedMemoryStream(_empty, 0); // ReSharper disable once AssignNullToNotNullAttribute - return new UnmanagedMemoryStream((byte*) address, length); + return new UnmanagedMemoryStream((byte*)address, length); } } @@ -87,7 +87,7 @@ namespace Tensorflow.Util if (address == IntPtr.Zero) return new UnmanagedMemoryStream(_empty, 0); - return new UnmanagedMemoryStream((byte*) address + offset, length); + return new UnmanagedMemoryStream((byte*)address + offset, length); } } } diff --git a/src/TensorFlowNET.Core/Util/UnorderedMap.cs b/src/TensorFlowNET.Core/Util/UnorderedMap.cs index 51bbecae..fa2b91fe 100644 --- a/src/TensorFlowNET.Core/Util/UnorderedMap.cs +++ b/src/TensorFlowNET.Core/Util/UnorderedMap.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Tensorflow.Util { diff --git a/src/TensorFlowNET.Core/Util/UnorderedSet.cs b/src/TensorFlowNET.Core/Util/UnorderedSet.cs index 183746db..95f936b0 100644 --- a/src/TensorFlowNET.Core/Util/UnorderedSet.cs +++ b/src/TensorFlowNET.Core/Util/UnorderedSet.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Tensorflow.Util { diff --git a/src/TensorFlowNET.Core/Util/nest.py.cs b/src/TensorFlowNET.Core/Util/nest.py.cs index 001ae1aa..019e31c1 100644 --- a/src/TensorFlowNET.Core/Util/nest.py.cs +++ b/src/TensorFlowNET.Core/Util/nest.py.cs @@ -14,12 +14,11 @@ limitations under the License. ******************************************************************************/ +using NumSharp; using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using NumSharp; -using Tensorflow.Operations; namespace Tensorflow.Util { @@ -206,7 +205,7 @@ namespace Tensorflow.Util } //# See the swig file (util.i) for documentation. - public static bool is_sequence(object arg) + public static bool is_sequence(object arg) => arg is IEnumerable && !(arg is string) && !(arg is NDArray) && !(arg.GetType().IsGenericType && arg.GetType().GetGenericTypeDefinition() == typeof(HashSet<>)); @@ -230,7 +229,7 @@ namespace Tensorflow.Util private static void _flatten_recursive(T obj, List list) { - switch(obj) + switch (obj) { case IDictionary dict: foreach (var key in _sorted(dict)) @@ -433,9 +432,9 @@ namespace Tensorflow.Util List flat = null; if (flat_sequence is List) flat = flat_sequence as List; - else - flat=new List(flat_sequence); - if (flat_sequence==null) + else + flat = new List(flat_sequence); + if (flat_sequence == null) throw new ArgumentException("flat_sequence must not be null"); // if not is_sequence(flat_sequence): // raise TypeError("flat_sequence must be a sequence") @@ -500,10 +499,10 @@ namespace Tensorflow.Util // for other in structure[1:]: // assert_same_structure(structure[0], other, check_types=check_types) - if (structure.Length==1) + if (structure.Length == 1) { // we don't need to zip if we have only one structure - return map_structure(a => func(new object[]{a}), structure[0]); + return map_structure(a => func(new object[] { a }), structure[0]); } var flat_structures = structure.Select(flatten).ToArray(); // ToArray is important here! var entries = zip_many(flat_structures); diff --git a/src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs b/src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs index 94790339..b274a6e5 100644 --- a/src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs +++ b/src/TensorFlowNET.Core/Variables/BaseResourceVariable.cs @@ -1,9 +1,5 @@ using NumSharp; using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Eager; -using Tensorflow.Gradients; using static Tensorflow.Binding; namespace Tensorflow @@ -75,7 +71,7 @@ namespace Tensorflow public Tensor assign(T value, bool use_locking = false, string name = null, bool read_value = true) { - if(value.GetType() == typeof(Tensor)) + if (value.GetType() == typeof(Tensor)) { var assign = gen_state_ops.assign(handle, value, use_locking: use_locking, name: name); if (read_value) @@ -88,11 +84,11 @@ namespace Tensorflow handle, value_tensor, name: name); if (read_value) return gen_resource_variable_ops.read_variable_op(handle, dtype); - // return _lazy_read(assign_op, value_tensor); + // return _lazy_read(assign_op, value_tensor); return assign_op; } - public Tensor value() + public Tensor value() => GraphElement ?? _read_variable_op(); protected Tensor _read_variable_op() @@ -151,10 +147,10 @@ namespace Tensorflow { var assign_add_op = gen_resource_variable_ops.assign_add_variable_op(Handle, ops.convert_to_tensor(delta, dtype: dtype), name: name); - + if (read_value) return gen_resource_variable_ops.read_variable_op(handle, dtype); - // return _lazy_read(assign_add_op); + // return _lazy_read(assign_add_op); return assign_add_op; } diff --git a/src/TensorFlowNET.Core/Variables/IVariableV1.cs b/src/TensorFlowNET.Core/Variables/IVariableV1.cs index 7d3fd5e7..cd5afb79 100644 --- a/src/TensorFlowNET.Core/Variables/IVariableV1.cs +++ b/src/TensorFlowNET.Core/Variables/IVariableV1.cs @@ -15,8 +15,6 @@ ******************************************************************************/ using NumSharp; -using System; -using System.Collections.Generic; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Variables/PureVariableScope.cs b/src/TensorFlowNET.Core/Variables/PureVariableScope.cs index dd09d8a7..32c016b4 100644 --- a/src/TensorFlowNET.Core/Variables/PureVariableScope.cs +++ b/src/TensorFlowNET.Core/Variables/PureVariableScope.cs @@ -33,8 +33,8 @@ namespace Tensorflow private VariableScope _cached_variable_scope_object; VariableScope _last_variable_scope_object; Dictionary _old_subscopes; - public PureVariableScope(string name, - string old_name_scope = null, + public PureVariableScope(string name, + string old_name_scope = null, TF_DataType dtype = TF_DataType.DtInvalid) { _name = name; @@ -64,7 +64,7 @@ namespace Tensorflow public void __enter__() { _old = _var_scope_store.current_scope; - if(_scope != null) + if (_scope != null) { _var_scope_store.open_variable_scope(_new_name); _old_subscopes = _var_scope_store.variable_scopes_count.ToDictionary(kv => kv.Key, kv => kv.Value); @@ -88,7 +88,7 @@ namespace Tensorflow public void Dispose() { - + } public void __exit__() @@ -103,12 +103,12 @@ namespace Tensorflow public void __init__() { - + } public void __del__() { - + } public static implicit operator VariableScope(PureVariableScope scope) diff --git a/src/TensorFlowNET.Core/Variables/RefVariable.Operators.cs b/src/TensorFlowNET.Core/Variables/RefVariable.Operators.cs index 79d7dd5f..92fbddb6 100644 --- a/src/TensorFlowNET.Core/Variables/RefVariable.Operators.cs +++ b/src/TensorFlowNET.Core/Variables/RefVariable.Operators.cs @@ -24,7 +24,7 @@ namespace Tensorflow public static Tensor operator +(RefVariable x, int y) => op_helper("add", x, y); public static Tensor operator +(RefVariable x, float y) => op_helper("add", x, y); public static Tensor operator +(RefVariable x, double y) => op_helper("add", x, y); - + public static Tensor operator -(RefVariable x, int y) => op_helper("sub", x, y); public static Tensor operator -(RefVariable x, float y) => op_helper("sub", x, y); public static Tensor operator -(RefVariable x, double y) => op_helper("sub", x, y); @@ -37,7 +37,8 @@ namespace Tensorflow private static Tensor op_helper(string default_name, RefVariable x, T y) { var xVal = x.value(); - return tf_with(ops.name_scope(null, default_name, new { xVal, y }), scope => { + return tf_with(ops.name_scope(null, default_name, new { xVal, y }), scope => + { string name = scope; var yTensor = ops.convert_to_tensor(y, xVal.dtype.as_base_dtype(), "y"); Tensor result = null; diff --git a/src/TensorFlowNET.Core/Variables/RefVariable.cs b/src/TensorFlowNET.Core/Variables/RefVariable.cs index b14d381c..849f3157 100644 --- a/src/TensorFlowNET.Core/Variables/RefVariable.cs +++ b/src/TensorFlowNET.Core/Variables/RefVariable.cs @@ -40,14 +40,14 @@ namespace Tensorflow public bool _in_graph_mode = true; public Tensor _initial_value; public bool _trainable; - + public Tensor _snapshot; public bool _save_slice_info; private Operation _initializer_op; public Operation Initializer => _initializer_op; public Operation Op => _variable.op; - + public TF_DataType dtype => _variable.dtype; public TensorShape shape => tensor_util.to_shape(_variable.shape); public string Device => ""; @@ -68,7 +68,7 @@ namespace Tensorflow { _in_graph_mode = true; - if(initial_value is Operation op) + if (initial_value is Operation op) { _init_from_op(op); } @@ -140,7 +140,7 @@ namespace Tensorflow var init_from_fn = initial_value.GetType().Name == "Func`1"; - if(collections == null) + if (collections == null) { collections = new List { tf.GraphKeys.GLOBAL_VARIABLES }; } @@ -254,7 +254,7 @@ namespace Tensorflow { var op = tensor.op; var new_op = op_cache.ContainsKey(op.name) ? op_cache[op.name] : null; - if(new_op == null) + if (new_op == null) { new_op = _safe_initial_value_from_op(name, op, op_cache); op_cache[op.name] = new_op; @@ -302,7 +302,7 @@ namespace Tensorflow foreach (var attr_def in op.node_def.Attr) attr_protos[attr_def.Key] = attr_def.Value; - return op.graph.create_op(new_op_type, new_op_inputs.ToArray(), op._output_types, + return op.graph.create_op(new_op_type, new_op_inputs.ToArray(), op._output_types, name: new_op_name, attrs: attr_protos); } return op; @@ -311,7 +311,7 @@ namespace Tensorflow private Operation _find_initialized_value_for_variable(Operation variable_op) { var var_names = new[] { variable_op.node_def.Name, variable_op.node_def.Name + ":0" }; - foreach(var collection_name in new[]{tf.GraphKeys.GLOBAL_VARIABLES, + foreach (var collection_name in new[]{tf.GraphKeys.GLOBAL_VARIABLES, tf.GraphKeys.LOCAL_VARIABLES }) { foreach (var var in variable_op.graph.get_collection(collection_name)) @@ -319,7 +319,7 @@ namespace Tensorflow return var.initialized_value(); } - return null; + return null; } /// @@ -351,7 +351,7 @@ namespace Tensorflow public VariableDef to_proto(string export_scope) { - if(string.IsNullOrEmpty(export_scope) || _variable.name.StartsWith(export_scope)) + if (string.IsNullOrEmpty(export_scope) || _variable.name.StartsWith(export_scope)) { var var_def = new VariableDef(); var_def.VariableName = ops.strip_name_scope(_variable.name, export_scope); diff --git a/src/TensorFlowNET.Core/Variables/ResourceVariable.Functions.cs b/src/TensorFlowNET.Core/Variables/ResourceVariable.Functions.cs index 1978d60a..d3e77c76 100644 --- a/src/TensorFlowNET.Core/Variables/ResourceVariable.Functions.cs +++ b/src/TensorFlowNET.Core/Variables/ResourceVariable.Functions.cs @@ -14,10 +14,6 @@ limitations under the License. ******************************************************************************/ -using NumSharp; -using System; -using static Tensorflow.Binding; - namespace Tensorflow { public partial class ResourceVariable diff --git a/src/TensorFlowNET.Core/Variables/ResourceVariable.Implicit.cs b/src/TensorFlowNET.Core/Variables/ResourceVariable.Implicit.cs index 656e1653..aa2815c7 100644 --- a/src/TensorFlowNET.Core/Variables/ResourceVariable.Implicit.cs +++ b/src/TensorFlowNET.Core/Variables/ResourceVariable.Implicit.cs @@ -1,6 +1,5 @@ using System; using Tensorflow.Eager; -using static Tensorflow.Binding; namespace Tensorflow { @@ -25,8 +24,8 @@ namespace Tensorflow public static implicit operator IntPtr(ResourceVariable var) => var._handle; - Tensor _dense_var_to_tensor(TF_DataType dtype = TF_DataType.DtInvalid, - string name = null, + Tensor _dense_var_to_tensor(TF_DataType dtype = TF_DataType.DtInvalid, + string name = null, bool as_ref = false) { return value(); diff --git a/src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs b/src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs index 8ff760b9..505ede6e 100644 --- a/src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs +++ b/src/TensorFlowNET.Core/Variables/ResourceVariable.Operators.cs @@ -15,8 +15,6 @@ ******************************************************************************/ using NumSharp; -using System; -using static Tensorflow.Binding; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Variables/ResourceVariable.cs b/src/TensorFlowNET.Core/Variables/ResourceVariable.cs index 37101246..2cff02c2 100644 --- a/src/TensorFlowNET.Core/Variables/ResourceVariable.cs +++ b/src/TensorFlowNET.Core/Variables/ResourceVariable.cs @@ -15,10 +15,8 @@ ******************************************************************************/ using Google.Protobuf; -using NumSharp; using System; using System.Collections.Generic; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow @@ -60,11 +58,11 @@ namespace Tensorflow } else { - _init_from_args(initial_value: initial_value, - trainable: trainable, - collections: collections, - caching_device: caching_device, - name: name, + _init_from_args(initial_value: initial_value, + trainable: trainable, + collections: collections, + caching_device: caching_device, + name: name, dtype: dtype, aggregation: aggregation, shape: shape); @@ -82,15 +80,15 @@ namespace Tensorflow { var init_from_fn = initial_value.GetType().Name == "Func`1" || initial_value.GetType().GetInterface("IInitializer") != null; - if(collections == null) + if (collections == null) collections = new List() { tf.GraphKeys.GLOBAL_VARIABLES }; _trainable = trainable; if (trainable && !collections.Contains(tf.GraphKeys.TRAINABLE_VARIABLES)) collections.Add(tf.GraphKeys.TRAINABLE_VARIABLES); - + _in_graph_mode = !tf.Context.executing_eagerly(); - tf_with(ops.init_scope(), init_scope => + tf_with(ops.init_scope(), init_scope => { var values = init_from_fn ? new object[0] : new object[] { initial_value }; tf_with(ops.name_scope(name, "Variable", values, skip_on_eager: false), scope => @@ -181,7 +179,7 @@ namespace Tensorflow _handle_name = handle.name; _name = handle.name; _shape = new TensorShape(handle.op.get_attr("shape") as TensorShapeProto); - + prepend_name_scope = ops.prepend_name_scope(variable_def.InitializerName, import_scope: import_scope); initializer_op = g.as_graph_element(prepend_name_scope) as Operation; if (!string.IsNullOrEmpty(variable_def.InitialValueName)) diff --git a/src/TensorFlowNET.Core/Variables/VariableArgs.cs b/src/TensorFlowNET.Core/Variables/VariableArgs.cs index cbb7524a..b4f63779 100644 --- a/src/TensorFlowNET.Core/Variables/VariableArgs.cs +++ b/src/TensorFlowNET.Core/Variables/VariableArgs.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Variables/VariableScope.cs b/src/TensorFlowNET.Core/Variables/VariableScope.cs index acfaac95..cda2919f 100644 --- a/src/TensorFlowNET.Core/Variables/VariableScope.cs +++ b/src/TensorFlowNET.Core/Variables/VariableScope.cs @@ -36,8 +36,8 @@ namespace Tensorflow public string _name_scope { get; set; } public string original_name_scope => _name_scope; - public VariableScope(bool reuse, - string name = "", + public VariableScope(bool reuse, + string name = "", string name_scope = "", TF_DataType dtype = TF_DataType.TF_FLOAT) { @@ -47,9 +47,9 @@ namespace Tensorflow _dtype = dtype; } - public IVariableV1 get_variable(_VariableStore var_store, - string name, - TensorShape shape = null, + public IVariableV1 get_variable(_VariableStore var_store, + string name, + TensorShape shape = null, TF_DataType dtype = TF_DataType.DtInvalid, object initializer = null, // IInitializer or Tensor bool? trainable = null, @@ -57,7 +57,7 @@ namespace Tensorflow bool? use_resource = null, bool validate_shape = true, VariableSynchronization synchronization = VariableSynchronization.Auto, - VariableAggregation aggregation= VariableAggregation.None) + VariableAggregation aggregation = VariableAggregation.None) { string full_name = !string.IsNullOrEmpty(this.name) ? this.name + "/" + name : name; return tf_with(ops.name_scope(null), scope => @@ -65,8 +65,8 @@ namespace Tensorflow if (dtype == TF_DataType.DtInvalid) dtype = _dtype; - return var_store.get_variable(full_name, - shape: shape, + return var_store.get_variable(full_name, + shape: shape, dtype: dtype, initializer: initializer, reuse: resue, diff --git a/src/TensorFlowNET.Core/Variables/_UnreadVariable.cs b/src/TensorFlowNET.Core/Variables/_UnreadVariable.cs index c4300ab7..14993063 100644 --- a/src/TensorFlowNET.Core/Variables/_UnreadVariable.cs +++ b/src/TensorFlowNET.Core/Variables/_UnreadVariable.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Tensorflow.Eager; +using Tensorflow.Eager; namespace Tensorflow { diff --git a/src/TensorFlowNET.Core/Variables/_VariableStore.cs b/src/TensorFlowNET.Core/Variables/_VariableStore.cs index a1fd03c9..e608fe94 100644 --- a/src/TensorFlowNET.Core/Variables/_VariableStore.cs +++ b/src/TensorFlowNET.Core/Variables/_VariableStore.cs @@ -52,9 +52,9 @@ namespace Tensorflow dtype = dtype.as_base_dtype(); trainable = variable_scope._get_trainable_value(synchronization, trainable); - return _true_getter(name, - shape: shape, - dtype: dtype, + return _true_getter(name, + shape: shape, + dtype: dtype, initializer: initializer, trainable: trainable, collections: collections, diff --git a/src/TensorFlowNET.Core/Variables/gen_state_ops.py.cs b/src/TensorFlowNET.Core/Variables/gen_state_ops.py.cs index 86c8a33f..3c662346 100644 --- a/src/TensorFlowNET.Core/Variables/gen_state_ops.py.cs +++ b/src/TensorFlowNET.Core/Variables/gen_state_ops.py.cs @@ -14,7 +14,6 @@ limitations under the License. ******************************************************************************/ -using System; using System.Collections.Generic; using static Tensorflow.Binding; @@ -56,8 +55,8 @@ namespace Tensorflow /// /// /// - public static Tensor assign(T @ref, object value, - bool validate_shape = true, + public static Tensor assign(T @ref, object value, + bool validate_shape = true, bool use_locking = true, string name = null) { diff --git a/src/TensorFlowNET.Core/Variables/state_ops.cs b/src/TensorFlowNET.Core/Variables/state_ops.cs index 014a010b..17d27679 100644 --- a/src/TensorFlowNET.Core/Variables/state_ops.cs +++ b/src/TensorFlowNET.Core/Variables/state_ops.cs @@ -115,7 +115,7 @@ namespace Tensorflow bool use_locking = false, string name = null) { - if(tf.executing_eagerly()) + if (tf.executing_eagerly()) return @ref.assign_add(value, use_locking: use_locking, name: name); else return gen_state_ops.assign_add(@ref, value, use_locking: use_locking, name: name); diff --git a/src/TensorFlowNET.Core/Variables/variables.py.cs b/src/TensorFlowNET.Core/Variables/variables.py.cs index 0496bd6c..0c07e024 100644 --- a/src/TensorFlowNET.Core/Variables/variables.py.cs +++ b/src/TensorFlowNET.Core/Variables/variables.py.cs @@ -86,7 +86,7 @@ namespace Tensorflow { var op = tensor.op; Operation new_op = op_cache.ContainsKey(op.name) ? op_cache[op.name] : null; - if(new_op == null) + if (new_op == null) { new_op = _safe_initial_value_from_op(name, op, op_cache); op_cache[op.name] = new_op; @@ -110,7 +110,7 @@ namespace Tensorflow op_type == "ReadVariableOp") return op; - if(op_type == "Variable" || + if (op_type == "Variable" || op_type == "VariableV2" || op_type == "VarHandleOp") { @@ -120,7 +120,7 @@ namespace Tensorflow // Recursively build initializer expressions for inputs. bool modified = false; var new_op_inputs = new List(); - foreach(Tensor op_input in op.inputs) + foreach (Tensor op_input in op.inputs) { var new_op_input = _safe_initial_value_from_tensor(name, op_input, op_cache); new_op_inputs.Add(new_op_input); @@ -128,7 +128,7 @@ namespace Tensorflow } // If at least one input was modified, replace the op. - if(modified) + if (modified) { var new_op_type = op_type; if (new_op_type == "RefSwitch") @@ -143,10 +143,10 @@ namespace Tensorflow attr_protos[attr_def.Key] = attr_def.Value; return op.graph.create_op( - new_op_type, + new_op_type, new_op_inputs.ToArray(), _output_types, - name: new_op_name, + name: new_op_name, attrs: attr_protos); } diff --git a/src/TensorFlowNET.Core/ops.GraphKeys.cs b/src/TensorFlowNET.Core/ops.GraphKeys.cs index f4b4b77f..adf2bb10 100644 --- a/src/TensorFlowNET.Core/ops.GraphKeys.cs +++ b/src/TensorFlowNET.Core/ops.GraphKeys.cs @@ -74,7 +74,7 @@ namespace Tensorflow /// /// List of all collections that keep track of variables. /// - public string[] _VARIABLE_COLLECTIONS_ = new string[] + public string[] _VARIABLE_COLLECTIONS_ = new string[] { GLOBAL_VARIABLES_, LOCAL_VARIABLES_, @@ -84,7 +84,7 @@ namespace Tensorflow MOVING_AVERAGE_VARIABLES_, CONCATENATED_VARIABLES_, TRAINABLE_RESOURCE_VARIABLES_ - }; + }; /// /// Key to collect BaseSaverBuilder.SaveableObject instances for checkpointing. diff --git a/src/TensorFlowNET.Core/ops._DefaultStack.cs b/src/TensorFlowNET.Core/ops._DefaultStack.cs index a41d4964..394b90d2 100644 --- a/src/TensorFlowNET.Core/ops._DefaultStack.cs +++ b/src/TensorFlowNET.Core/ops._DefaultStack.cs @@ -37,12 +37,12 @@ namespace Tensorflow public void __enter__() { - + } public void __exit__() { - + } public void Dispose() @@ -52,12 +52,12 @@ namespace Tensorflow public void __init__() { - + } public void __del__() { - + } } } diff --git a/src/TensorFlowNET.Core/ops.cs b/src/TensorFlowNET.Core/ops.cs index 2731f831..0744c068 100644 --- a/src/TensorFlowNET.Core/ops.cs +++ b/src/TensorFlowNET.Core/ops.cs @@ -14,18 +14,18 @@ limitations under the License. ******************************************************************************/ +using Google.Protobuf; +using Google.Protobuf.Collections; +using NumSharp; using System; using System.Collections.Generic; -using System.Runtime.InteropServices; -using Google.Protobuf; using System.Linq; +using System.Runtime.InteropServices; using System.Threading; -using NumSharp; +using Tensorflow.Contexts; +using Tensorflow.Eager; using Tensorflow.Util; using static Tensorflow.Binding; -using Tensorflow.Eager; -using Tensorflow.Contexts; -using Google.Protobuf.Collections; namespace Tensorflow { @@ -82,7 +82,7 @@ namespace Tensorflow public static Graph _get_graph_from_inputs(Tensors op_input_list, Graph graph = null) { - foreach(var op_input in op_input_list) + foreach (var op_input in op_input_list) { // Determine if this is a valid graph_element. var graph_element = op_input; @@ -98,9 +98,9 @@ namespace Tensorflow /// /// /// - public static Tensor convert_to_tensor(object value, - TF_DataType dtype = TF_DataType.DtInvalid, - string name = null, + public static Tensor convert_to_tensor(object value, + TF_DataType dtype = TF_DataType.DtInvalid, + string name = null, TF_DataType preferred_dtype = TF_DataType.DtInvalid, Context ctx = null) { @@ -162,7 +162,7 @@ namespace Tensorflow { if (op_def == null) op_def = graph.GetOpDef(node_def.Op); - + var input_tensors = _reconstruct_sequence_inputs(op_def, inputs, node_def.Attr); lock (Locks.ProcessWide) @@ -182,7 +182,7 @@ namespace Tensorflow } var status = tf.Status; - + // Add control inputs foreach (var control_input in control_inputs) c_api.TF_AddControlInput(op_desc, control_input); @@ -438,7 +438,7 @@ namespace Tensorflow { var ret = new List(); - foreach(var (i, value) in enumerate(values)) + foreach (var (i, value) in enumerate(values)) { if (value == null) { @@ -454,13 +454,13 @@ namespace Tensorflow return ret.ToArray(); } - public static Tensor[] internal_convert_n_to_tensor(object values, TF_DataType dtype = TF_DataType.DtInvalid, - string name = null, TF_DataType preferred_dtype = TF_DataType.DtInvalid, + public static Tensor[] internal_convert_n_to_tensor(object values, TF_DataType dtype = TF_DataType.DtInvalid, + string name = null, TF_DataType preferred_dtype = TF_DataType.DtInvalid, bool as_ref = false) { var ret = new List(); - foreach((int i, object value) in enumerate(values as object[])) + foreach ((int i, object value) in enumerate(values as object[])) { string n = string.IsNullOrEmpty(name) ? "" : $"{name}_{i}"; ret.Add(internal_convert_to_tensor(value, dtype: dtype, name: n, as_ref: as_ref, preferred_dtype: preferred_dtype)); @@ -485,8 +485,8 @@ namespace Tensorflow if (tf.executing_eagerly()) return tensor; else - return tensor.dtype == TF_DataType.TF_RESOURCE - ? tensor.AsPlaceholder(name: name) + return tensor.dtype == TF_DataType.TF_RESOURCE + ? tensor.AsPlaceholder(name: name) : tensor.AsContatnt(name: name); case Tensor tensor: return tensor; diff --git a/src/TensorFlowNET.Core/ops.name_scope.cs b/src/TensorFlowNET.Core/ops.name_scope.cs index d2b0e849..984efaec 100644 --- a/src/TensorFlowNET.Core/ops.name_scope.cs +++ b/src/TensorFlowNET.Core/ops.name_scope.cs @@ -17,7 +17,6 @@ using System.Collections.Generic; using System.Diagnostics; using Tensorflow.Contexts; -using Tensorflow.Eager; using static Tensorflow.Binding; namespace Tensorflow @@ -105,7 +104,7 @@ namespace Tensorflow else get_default_graph()._name_stack = old_scope_name; } - + [DebuggerNonUserCode] public void __exit__() { @@ -114,15 +113,15 @@ namespace Tensorflow [DebuggerNonUserCode] public void __init__() { - + } [DebuggerNonUserCode] public void __del__() { - + } - + /// /// __enter__() /// diff --git a/src/TensorFlowNET.Core/ops.threading.cs b/src/TensorFlowNET.Core/ops.threading.cs index f8796596..e436cae0 100644 --- a/src/TensorFlowNET.Core/ops.threading.cs +++ b/src/TensorFlowNET.Core/ops.threading.cs @@ -1,5 +1,4 @@ using System.Threading; -using Tensorflow.Util; using static Tensorflow.Binding; namespace Tensorflow diff --git a/src/TensorFlowNET.Core/tensorflow.cs b/src/TensorFlowNET.Core/tensorflow.cs index 94c9f49f..20d43baf 100644 --- a/src/TensorFlowNET.Core/tensorflow.cs +++ b/src/TensorFlowNET.Core/tensorflow.cs @@ -14,12 +14,7 @@ limitations under the License. ******************************************************************************/ -using NumSharp.Utilities; -using System; using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Threading; using Tensorflow.Contexts; using Tensorflow.Eager; using Tensorflow.Gradients; @@ -46,7 +41,7 @@ namespace Tensorflow public OpDefLibrary OpDefLib; public Context Context; public IEagerRunner Runner; - + public tensorflow() { Status = new Status(); @@ -111,33 +106,33 @@ namespace Tensorflow { tape_set = new List(); } - + return tape_set; } public void __init__() { - + } public void __enter__() { - + } public void __exit__() { - + } public void __del__() { - + } public void Dispose() { - + } } } diff --git a/src/TensorFlowNET.Core/tensorflow.memory.cs b/src/TensorFlowNET.Core/tensorflow.memory.cs index d2aeb9b0..ae8590fe 100644 --- a/src/TensorFlowNET.Core/tensorflow.memory.cs +++ b/src/TensorFlowNET.Core/tensorflow.memory.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Tensorflow {