| @@ -63,8 +63,8 @@ namespace Tensorflow | |||||
| static unsafe DeallocatorArgs() | static unsafe DeallocatorArgs() | ||||
| { | { | ||||
| Empty = new IntPtr(EmptyPtr = (DeallocatorArgs*) Marshal.AllocHGlobal(Marshal.SizeOf<DeallocatorArgs>())); | |||||
| *EmptyPtr = new DeallocatorArgs() {gc_handle = IntPtr.Zero, deallocator_called = false}; | |||||
| Empty = new IntPtr(EmptyPtr = (DeallocatorArgs*)Marshal.AllocHGlobal(Marshal.SizeOf<DeallocatorArgs>())); | |||||
| *EmptyPtr = new DeallocatorArgs() { gc_handle = IntPtr.Zero, deallocator_called = false }; | |||||
| } | } | ||||
| public bool deallocator_called; | public bool deallocator_called; | ||||
| @@ -15,7 +15,6 @@ | |||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using NumSharp; | using NumSharp; | ||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| using System.Linq; | using System.Linq; | ||||
| @@ -15,7 +15,6 @@ | |||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using Tensorflow.Graphs; | using Tensorflow.Graphs; | ||||
| using Tensorflow.Operations; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -14,8 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| public partial class tensorflow | public partial class tensorflow | ||||
| @@ -14,9 +14,7 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using Tensorflow.Contexts; | |||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -15,7 +15,6 @@ | |||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | using System; | ||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -42,19 +41,19 @@ namespace Tensorflow | |||||
| public Operation group<T>(T[] inputs, string name = null) where T : ITensorOrOperation | public Operation group<T>(T[] inputs, string name = null) where T : ITensorOrOperation | ||||
| => control_flow_ops.group(inputs, name: name); | => control_flow_ops.group(inputs, name: name); | ||||
| public Tensor while_loop(Func<Tensor, Tensor> cond, | |||||
| Func<Tensor, Tensor> body, | |||||
| public Tensor while_loop(Func<Tensor, Tensor> cond, | |||||
| Func<Tensor, Tensor> body, | |||||
| Tensor loop_vars, | Tensor loop_vars, | ||||
| int parallel_iterations = 10) | int parallel_iterations = 10) | ||||
| { | { | ||||
| Func<Tensor[], Tensor> cond1 = x | |||||
| Func<Tensor[], Tensor> cond1 = x | |||||
| => cond(x[0]); | => cond(x[0]); | ||||
| Func<Tensor[], Tensor[]> body1 = x | |||||
| Func<Tensor[], Tensor[]> body1 = x | |||||
| => new[] { body(x[0]) }; | => 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 }); | new[] { loop_vars }); | ||||
| return results[0]; | return results[0]; | ||||
| } | } | ||||
| @@ -68,7 +67,7 @@ namespace Tensorflow | |||||
| parallel_iterations: parallel_iterations, | parallel_iterations: parallel_iterations, | ||||
| name: name); | name: name); | ||||
| public _ControlDependenciesController control_dependencies(ITensorOrOperation[] control_inputs) | |||||
| public _ControlDependenciesController control_dependencies(ITensorOrOperation[] control_inputs) | |||||
| => ops.control_dependencies(control_inputs); | => ops.control_dependencies(control_inputs); | ||||
| } | } | ||||
| } | } | ||||
| @@ -14,8 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| public partial class tensorflow | public partial class tensorflow | ||||
| @@ -14,8 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| public partial class tensorflow | public partial class tensorflow | ||||
| @@ -34,10 +34,10 @@ namespace Tensorflow | |||||
| object[] data = null, | object[] data = null, | ||||
| string message = null, | string message = null, | ||||
| string name = 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); | name: name); | ||||
| public Tensor assert_greater_equal<T1, T2>(Tensor x, | public Tensor assert_greater_equal<T1, T2>(Tensor x, | ||||
| @@ -40,11 +40,11 @@ namespace Tensorflow | |||||
| int? aggregation_method = null, | int? aggregation_method = null, | ||||
| Tensor[] stop_gradients = 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, | gate_gradients, | ||||
| stop_gradients: stop_gradients); | stop_gradients: stop_gradients); | ||||
| } | } | ||||
| @@ -24,7 +24,7 @@ namespace Tensorflow | |||||
| public GraphTransformer graph_transforms => new GraphTransformer(); | public GraphTransformer graph_transforms => new GraphTransformer(); | ||||
| public GraphKeys GraphKeys { get; } = new GraphKeys(); | public GraphKeys GraphKeys { get; } = new GraphKeys(); | ||||
| public void reset_default_graph() | |||||
| public void reset_default_graph() | |||||
| => ops.reset_default_graph(); | => ops.reset_default_graph(); | ||||
| public Graph get_default_graph() | public Graph get_default_graph() | ||||
| @@ -14,8 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System.Collections.Generic; | |||||
| using Tensorflow.IO; | |||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -34,7 +32,7 @@ namespace Tensorflow | |||||
| public Tensor flip_left_right(Tensor image) | public Tensor flip_left_right(Tensor image) | ||||
| => image_ops_impl.flip_left_right(image); | => image_ops_impl.flip_left_right(image); | ||||
| public Tensor flip_up_down(Tensor image) | public Tensor flip_up_down(Tensor image) | ||||
| => image_ops_impl.flip_up_down(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) | 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); | => 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) | string name = null) | ||||
| => image_ops_impl.resize_images(images, size, method, preserve_aspect_ratio, antialias, name); | => 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) | public Tensor random_hue(Tensor image, float max_delta, int seed = 0) | ||||
| => image_ops_impl.random_hue(image, max_delta, seed); | => image_ops_impl.random_hue(image, max_delta, seed); | ||||
| public Tensor adjust_hue(Tensor image, Tensor delta, string name = null) | public Tensor adjust_hue(Tensor image, Tensor delta, string name = null) | ||||
| => image_ops_impl.adjust_hue(image, delta, name); | => image_ops_impl.adjust_hue(image, delta, name); | ||||
| @@ -169,7 +167,7 @@ namespace Tensorflow | |||||
| string dct_method = "", | string dct_method = "", | ||||
| string name = null) | string name = null) | ||||
| => gen_image_ops.decode_jpeg(contents, channels: channels, ratio: ratio, | => 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); | acceptable_fraction: acceptable_fraction, dct_method: dct_method); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -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, | => 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); | 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 iou_threshold = 0.5f, | ||||
| float score_threshold = -1f / 0f, | float score_threshold = -1f / 0f, | ||||
| bool pad_to_max_output_size = false, | bool pad_to_max_output_size = false, | ||||
| string name = null, | string name = null, | ||||
| bool sorted_input = false, | |||||
| bool sorted_input = false, | |||||
| bool canonicalized_coordinates = false, | bool canonicalized_coordinates = false, | ||||
| int tile_size = 512) | 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, | => image_ops_impl.non_max_suppression_padded(boxes, scores, max_output_size, iou_threshold, score_threshold, pad_to_max_output_size, | ||||
| @@ -22,7 +22,7 @@ namespace Tensorflow | |||||
| { | { | ||||
| public InitializersImpl initializers { get; } = new InitializersImpl(); | public InitializersImpl initializers { get; } = new InitializersImpl(); | ||||
| public IInitializer constant_initializer<T>(T value, TF_DataType dtype = TF_DataType.TF_FLOAT, bool verify_shape = false) | |||||
| public IInitializer constant_initializer<T>(T value, TF_DataType dtype = TF_DataType.TF_FLOAT, bool verify_shape = false) | |||||
| => new Constant<T>(value, dtype: dtype, verify_shape: verify_shape); | => new Constant<T>(value, dtype: dtype, verify_shape: verify_shape); | ||||
| public IInitializer zeros_initializer => new Zeros(); | public IInitializer zeros_initializer => new Zeros(); | ||||
| public IInitializer ones_initializer => new Ones(); | public IInitializer ones_initializer => new Ones(); | ||||
| @@ -97,7 +97,7 @@ namespace Tensorflow | |||||
| dtype: dtype); | dtype: dtype); | ||||
| public IInitializer zeros_initializer(TensorShape shape = null, | 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); | dtype: dtype); | ||||
| } | } | ||||
| } | } | ||||
| @@ -14,8 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| public partial class tensorflow | public partial class tensorflow | ||||
| @@ -14,14 +14,11 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Linq; | using System.Linq; | ||||
| using NumSharp; | |||||
| using Tensorflow.Keras; | using Tensorflow.Keras; | ||||
| using Tensorflow.Keras.ArgsDefinition; | using Tensorflow.Keras.ArgsDefinition; | ||||
| using Tensorflow.Keras.Layers; | using Tensorflow.Keras.Layers; | ||||
| using Tensorflow.Operations.Activation; | |||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -37,7 +34,7 @@ namespace Tensorflow | |||||
| int[] kernel_size, | int[] kernel_size, | ||||
| int[] strides = null, | int[] strides = null, | ||||
| string padding = "valid", | string padding = "valid", | ||||
| string data_format= "channels_last", | |||||
| string data_format = "channels_last", | |||||
| int[] dilation_rate = null, | int[] dilation_rate = null, | ||||
| bool use_bias = true, | bool use_bias = true, | ||||
| Activation activation = null, | Activation activation = null, | ||||
| @@ -219,7 +216,7 @@ namespace Tensorflow | |||||
| if (inputs.shape.Length == 0) | 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: ()"); | 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<int>() {0}; | |||||
| var premutation = new List<int>() { 0 }; | |||||
| if (data_format == "channels_first" && inputs.NDims > 1) | if (data_format == "channels_first" && inputs.NDims > 1) | ||||
| { | { | ||||
| premutation.AddRange(Binding.range(2, inputs.NDims)); | premutation.AddRange(Binding.range(2, inputs.NDims)); | ||||
| @@ -234,16 +231,17 @@ namespace Tensorflow | |||||
| int[] compute_output_shape(int[] inputshape) | int[] compute_output_shape(int[] inputshape) | ||||
| { | { | ||||
| if (inputshape == null || inputshape.Length == 0) | if (inputshape == null || inputshape.Length == 0) | ||||
| inputshape = new int[] {1}; | |||||
| inputshape = new int[] { 1 }; | |||||
| if (inputshape.Skip(1).All(d => d > 0)) | if (inputshape.Skip(1).All(d => d > 0)) | ||||
| { | { | ||||
| int[] output_shape = new int[2]; | int[] output_shape = new int[2]; | ||||
| output_shape[0] = inputshape[0]; | 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; | return output_shape; | ||||
| } else | |||||
| return new int[] {inputshape[0], -1}; //-1 == Binding.None | |||||
| } | |||||
| else | |||||
| return new int[] { inputshape[0], -1 }; //-1 == Binding.None | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -14,9 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using Tensorflow.Eager; | |||||
| using Tensorflow.Operations; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| public partial class tensorflow | public partial class tensorflow | ||||
| @@ -52,7 +49,7 @@ namespace Tensorflow | |||||
| public Tensor add(Tensor a, Tensor b, string name = null) | public Tensor add(Tensor a, Tensor b, string name = null) | ||||
| => gen_math_ops.add(a, b, name: name); | => gen_math_ops.add(a, b, name: name); | ||||
| public Tensor add<Tx, Ty>(Tx a, Ty b, string name = null) | |||||
| public Tensor add<Tx, Ty>(Tx a, Ty b, string name = null) | |||||
| => gen_math_ops.add(a, b, name: name); | => gen_math_ops.add(a, b, name: name); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -233,7 +230,7 @@ namespace Tensorflow | |||||
| /// <returns></returns> | /// <returns></returns> | ||||
| public Tensor _clip_by_value(Tensor t, Tensor clip_value_min, Tensor clip_value_max, string name = null) | 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); | => gen_math_ops._clip_by_value(t, clip_value_min, clip_value_max); | ||||
| /// <summary> | /// <summary> | ||||
| /// Clips tensor values to a specified min and max. | /// Clips tensor values to a specified min and max. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -261,16 +258,16 @@ namespace Tensorflow | |||||
| /// Any values less than <c>clip_value_min</c> are set to <c>clip_value_min</c>. Any values | /// Any values less than <c>clip_value_min</c> are set to <c>clip_value_min</c>. Any values | ||||
| /// greater than <c>clip_value_max</c> are set to <c>clip_value_max</c>. | /// greater than <c>clip_value_max</c> are set to <c>clip_value_max</c>. | ||||
| /// </remarks> | /// </remarks> | ||||
| public Tensor clip_by_value<T1, T2>(Tensor t, T1 clip_value_min, T2 clip_value_max, string name = "ClipByValue") | |||||
| public Tensor clip_by_value<T1, T2>(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); | => clip_ops.clip_by_value(t, clip_value_min, clip_value_max, name); | ||||
| public Tensor sub<Tx, Ty>(Tx a, Ty b, string name = null) | public Tensor sub<Tx, Ty>(Tx a, Ty b, string name = null) | ||||
| => gen_math_ops.sub(a, b, name: name); | => gen_math_ops.sub(a, b, name: name); | ||||
| public Tensor divide(Tensor a, Tensor b) | public Tensor divide(Tensor a, Tensor b) | ||||
| => a / 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); | => gen_math_ops.sqrt(a, name); | ||||
| public Tensor sign(Tensor a, string name = null) | public Tensor sign(Tensor a, string name = null) | ||||
| @@ -367,7 +364,7 @@ namespace Tensorflow | |||||
| /// <param name="y"></param> | /// <param name="y"></param> | ||||
| /// <param name="name"></param> | /// <param name="name"></param> | ||||
| /// <returns></returns> | /// <returns></returns> | ||||
| public Tensor multiply<Tx, Ty>(Tx x, Ty y, string name = null) | |||||
| public Tensor multiply<Tx, Ty>(Tx x, Ty y, string name = null) | |||||
| => gen_math_ops.mul(x, y, name: name); | => gen_math_ops.mul(x, y, name: name); | ||||
| public Tensor negative(Tensor x, string name = null) | public Tensor negative(Tensor x, string name = null) | ||||
| @@ -424,7 +421,7 @@ namespace Tensorflow | |||||
| public Tensor real(Tensor input, string name = null) | public Tensor real(Tensor input, string name = null) | ||||
| => math_ops.real(input, name); | => math_ops.real(input, name); | ||||
| /// <summary> | /// <summary> | ||||
| /// Computes the "logical or" of elements across dimensions of a tensor. | /// Computes the "logical or" of elements across dimensions of a tensor. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -478,7 +475,7 @@ namespace Tensorflow | |||||
| /// <param name="input"></param> | /// <param name="input"></param> | ||||
| /// <param name="axis"></param> | /// <param name="axis"></param> | ||||
| /// <returns></returns> | /// <returns></returns> | ||||
| 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) | bool keepdims = false, string name = null) | ||||
| { | { | ||||
| if (!axis.HasValue && reduction_indices.HasValue && !keepdims) | if (!axis.HasValue && reduction_indices.HasValue && !keepdims) | ||||
| @@ -491,7 +488,7 @@ namespace Tensorflow | |||||
| return math_ops.reduce_sum(input, keepdims: keepdims, name: name); | 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) | bool keepdims = false, string name = null) | ||||
| => math_ops.reduce_sum(input, axis, keepdims: keepdims, name: name); | => 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) | 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); | => math_ops.reduce_variance(input_tensor, axis, keepdims, name); | ||||
| public Tensor sigmoid<T>(T x, string name = null) | public Tensor sigmoid<T>(T x, string name = null) | ||||
| => math_ops.sigmoid(x, name: name); | => math_ops.sigmoid(x, name: name); | ||||
| @@ -536,7 +533,7 @@ namespace Tensorflow | |||||
| public Tensor round(Tensor x, string name = null) | public Tensor round(Tensor x, string name = null) | ||||
| => gen_math_ops.round(x, name: name); | => 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); | => math_ops.cast(x, dtype, name); | ||||
| public Tensor cumsum(Tensor x, int axis = 0, bool exclusive = false, bool reverse = false, string name = null) | public Tensor cumsum(Tensor x, int axis = 0, bool exclusive = false, bool reverse = false, string name = null) | ||||
| @@ -14,7 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | |||||
| using Tensorflow.Operations; | using Tensorflow.Operations; | ||||
| using Tensorflow.Operations.Activation; | using Tensorflow.Operations.Activation; | ||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| @@ -27,8 +26,8 @@ namespace Tensorflow | |||||
| public class nn_internal | 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 | var parameters = new Conv2dParams | ||||
| { | { | ||||
| @@ -92,9 +91,9 @@ namespace Tensorflow | |||||
| public (Tensor, Tensor) moments(Tensor x, | public (Tensor, Tensor) moments(Tensor x, | ||||
| int[] axes, | int[] axes, | ||||
| string name = null, | 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); | keep_dims: keep_dims); | ||||
| public Tensor embedding_lookup(IVariableV1 @params, | public Tensor embedding_lookup(IVariableV1 @params, | ||||
| @@ -121,7 +120,7 @@ namespace Tensorflow | |||||
| public Tensor tanh(Tensor x, string name = null) | public Tensor tanh(Tensor x, string name = null) | ||||
| => gen_nn_ops.tanh(x, name); | => 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); | => gen_nn_ops.relu(features, name); | ||||
| public Tensor[] fused_batch_norm(Tensor x, | public Tensor[] fused_batch_norm(Tensor x, | ||||
| @@ -140,7 +139,7 @@ namespace Tensorflow | |||||
| public IPoolFunction max_pool_fn => new MaxPoolFunction(); | 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); | => 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") | 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) | public Tensor softmax(Tensor logits, int axis = -1, string name = null) | ||||
| => gen_nn_ops.softmax(logits, name); | => gen_nn_ops.softmax(logits, name); | ||||
| /// <summary> | /// <summary> | ||||
| /// Computes sparse softmax cross entropy between `logits` and `labels`. | /// Computes sparse softmax cross entropy between `logits` and `labels`. | ||||
| @@ -27,7 +27,7 @@ namespace Tensorflow | |||||
| public void add_to_collections<T>(List<string> names, T value) | public void add_to_collections<T>(List<string> names, T value) | ||||
| => get_default_graph().add_to_collections(names, 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); | => 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) | 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) | public void device(string device_name) | ||||
| => get_default_graph().device(device_name); | => get_default_graph().device(device_name); | ||||
| public List<T> get_collection<T>(string key, string scope = "") | |||||
| public List<T> get_collection<T>(string key, string scope = "") | |||||
| => get_default_graph().get_collection<T>(key, scope: scope); | => get_default_graph().get_collection<T>(key, scope: scope); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -54,7 +54,7 @@ namespace Tensorflow | |||||
| /// <param name="default_name">The default name to use if the name argument is None.</param> | /// <param name="default_name">The default name to use if the name argument is None.</param> | ||||
| /// <param name="values">The list of Tensor arguments that are passed to the op function.</param> | /// <param name="values">The list of Tensor arguments that are passed to the op function.</param> | ||||
| /// <returns>The scope name.</returns> | /// <returns>The scope name.</returns> | ||||
| 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); | => new ops.NameScope(name, default_name, values); | ||||
| /// <summary> | /// <summary> | ||||
| @@ -14,8 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using Tensorflow.Keras; | |||||
| using Tensorflow.Keras.Engine; | |||||
| using Tensorflow.Keras.Optimizers; | using Tensorflow.Keras.Optimizers; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -14,7 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | |||||
| using Tensorflow.Queues; | using Tensorflow.Queues; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -97,7 +97,7 @@ namespace Tensorflow | |||||
| public Tensor multinomial(Tensor logits, int num_samples, int? seed = null, | public Tensor multinomial(Tensor logits, int num_samples, int? seed = null, | ||||
| string name = null, TF_DataType output_dtype = TF_DataType.DtInvalid) | 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); | name: name, output_dtype: output_dtype); | ||||
| } | } | ||||
| } | } | ||||
| @@ -52,7 +52,7 @@ namespace Tensorflow | |||||
| bool validate_indices = true, | bool validate_indices = true, | ||||
| string name = null) | string name = null) | ||||
| => gen_sparse_ops.sparse_to_dense(sparse_indices, | => gen_sparse_ops.sparse_to_dense(sparse_indices, | ||||
| output_shape, | |||||
| output_shape, | |||||
| sparse_values, | sparse_values, | ||||
| default_value: default_value, | default_value: default_value, | ||||
| validate_indices: validate_indices, | validate_indices: validate_indices, | ||||
| @@ -14,9 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System.Collections.Generic; | |||||
| using Tensorflow.IO; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| public partial class tensorflow | public partial class tensorflow | ||||
| @@ -20,7 +20,7 @@ namespace Tensorflow | |||||
| { | { | ||||
| public Summaries.Summary summary = new Summaries.Summary(); | 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); | => summary.scalar(name, tensor); | ||||
| } | } | ||||
| } | } | ||||
| @@ -18,7 +18,7 @@ namespace Tensorflow | |||||
| { | { | ||||
| public partial class 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); | => ops.convert_to_tensor(value, dtype, name, preferred_dtype); | ||||
| public Tensor strided_slice(Tensor input, Tensor begin, Tensor end, Tensor strides = null, | public Tensor strided_slice(Tensor input, Tensor begin, Tensor end, Tensor strides = null, | ||||
| @@ -66,7 +66,7 @@ namespace Tensorflow | |||||
| /// <param name="name">A name for the operation (optional)</param> | /// <param name="name">A name for the operation (optional)</param> | ||||
| /// <returns>if num_or_size_splits is a scalar returns num_or_size_splits Tensor objects; | /// <returns>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.</returns> | /// if num_or_size_splits is a 1-D Tensor returns num_or_size_splits.get_shape[0] Tensor objects resulting from splitting value.</returns> | ||||
| 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( | => array_ops.split( | ||||
| value: value, | value: value, | ||||
| num_split: num_split, | num_split: num_split, | ||||
| @@ -14,8 +14,6 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| public partial class tensorflow | public partial class tensorflow | ||||
| @@ -32,14 +32,14 @@ namespace Tensorflow | |||||
| public IVariableV1 get_global_step(Graph graph) | public IVariableV1 get_global_step(Graph graph) | ||||
| => TrainingUtil.get_global_step(graph); | => TrainingUtil.get_global_step(graph); | ||||
| public Optimizer GradientDescentOptimizer(float learning_rate) | |||||
| public Optimizer GradientDescentOptimizer(float learning_rate) | |||||
| => new GradientDescentOptimizer(learning_rate); | => new GradientDescentOptimizer(learning_rate); | ||||
| public Optimizer GradientDescentOptimizer(Tensor learning_rate) | public Optimizer GradientDescentOptimizer(Tensor learning_rate) | ||||
| => new GradientDescentOptimizer(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") | public Optimizer AdamOptimizer(float learning_rate, TF_DataType dtype, string name = "Adam") | ||||
| => new AdamOptimizer(learning_rate, name: name, dtype: dtype); | => new AdamOptimizer(learning_rate, name: name, dtype: dtype); | ||||
| @@ -53,10 +53,10 @@ namespace Tensorflow | |||||
| public ExponentialMovingAverage ExponentialMovingAverage(float decay) | public ExponentialMovingAverage ExponentialMovingAverage(float decay) | ||||
| => new ExponentialMovingAverage(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); | => 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); | => graph_io.write_graph(graph, logdir, name, as_text); | ||||
| public Graph load_graph(string freeze_graph_pb) | public Graph load_graph(string freeze_graph_pb) | ||||
| @@ -47,7 +47,7 @@ namespace Tensorflow | |||||
| /// <param name="status">TF_Status*</param> | /// <param name="status">TF_Status*</param> | ||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static extern void TF_OperationGetAttrString(IntPtr oper, string attr_name, IntPtr value, uint max_length, SafeStatusHandle status); | public static extern void TF_OperationGetAttrString(IntPtr oper, string attr_name, IntPtr value, uint max_length, SafeStatusHandle status); | ||||
| /// <summary> | /// <summary> | ||||
| /// Sets `output_attr_value` to the binary-serialized AttrValue proto | /// Sets `output_attr_value` to the binary-serialized AttrValue proto | ||||
| /// representation of the value of the `attr_name` attr of `oper`. | /// representation of the value of the `attr_name` attr of `oper`. | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Threading.Tasks; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -15,14 +15,13 @@ | |||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using NumSharp; | using NumSharp; | ||||
| using NumSharp.Utilities; | |||||
| using System; | using System; | ||||
| using System.Collections; | using System.Collections; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.ComponentModel; | using System.ComponentModel; | ||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| using System.Linq; | using System.Linq; | ||||
| using NumSharp.Utilities; | |||||
| using System.Runtime.CompilerServices; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -32,8 +31,8 @@ namespace Tensorflow | |||||
| public static partial class Binding | public static partial class Binding | ||||
| { | { | ||||
| public static T2 get<T1, T2>(this Dictionary<T1, T2> dict, T1 key) | public static T2 get<T1, T2>(this Dictionary<T1, T2> dict, T1 key) | ||||
| => key == null ? | |||||
| default : | |||||
| => key == null ? | |||||
| default : | |||||
| (dict.ContainsKey(key) ? dict[key] : default); | (dict.ContainsKey(key) ? dict[key] : default); | ||||
| public static void Update<T>(this IList<T> list, T element) | public static void Update<T>(this IList<T> list, T element) | ||||
| @@ -71,7 +70,7 @@ namespace Tensorflow | |||||
| case NDArray nd: | case NDArray nd: | ||||
| return nd.ToString(false); | return nd.ToString(false); | ||||
| case Array arr: | 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); | arr = Arrays.Flatten(arr); | ||||
| var objs = toObjectArray(arr); | var objs = toObjectArray(arr); | ||||
| return $"[{string.Join(", ", objs.Select(_tostring))}]"; | return $"[{string.Join(", ", objs.Select(_tostring))}]"; | ||||
| @@ -105,7 +104,7 @@ namespace Tensorflow | |||||
| return; | 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]); | yield return (t1[i], t2[i], t3[i]); | ||||
| } | } | ||||
| public static IEnumerable<(T1, T2)> zip<T1, T2>(NDArray t1, NDArray t2) | |||||
| where T1: unmanaged | |||||
| where T2: unmanaged | |||||
| public static IEnumerable<(T1, T2)> zip<T1, T2>(NDArray t1, NDArray t2) | |||||
| where T1 : unmanaged | |||||
| where T2 : unmanaged | |||||
| { | { | ||||
| var a = t1.AsIterator<T1>(); | var a = t1.AsIterator<T1>(); | ||||
| var b = t2.AsIterator<T2>(); | var b = t2.AsIterator<T2>(); | ||||
| while(a.HasNext() && b.HasNext()) | |||||
| while (a.HasNext() && b.HasNext()) | |||||
| yield return (a.MoveNext(), b.MoveNext()); | yield return (a.MoveNext(), b.MoveNext()); | ||||
| } | } | ||||
| @@ -390,7 +389,8 @@ namespace Tensorflow | |||||
| { | { | ||||
| yield return flds[i].GetValue(tuple); | yield return flds[i].GetValue(tuple); | ||||
| } | } | ||||
| } else | |||||
| } | |||||
| else | |||||
| { | { | ||||
| throw new System.Exception("Expected Tuple."); | throw new System.Exception("Expected Tuple."); | ||||
| } | } | ||||
| @@ -404,7 +404,7 @@ namespace Tensorflow | |||||
| public static bool isinstance(object Item1, object tuple) | public static bool isinstance(object Item1, object tuple) | ||||
| { | { | ||||
| foreach (var t in TupleToEnumerable(tuple)) | foreach (var t in TupleToEnumerable(tuple)) | ||||
| if (isinstance(Item1, (Type) t)) | |||||
| if (isinstance(Item1, (Type)t)) | |||||
| return true; | return true; | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Diagnostics; | |||||
| using System.Dynamic; | |||||
| using System.Text; | |||||
| using System.Diagnostics; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -17,7 +17,6 @@ | |||||
| using NumSharp.Backends.Unmanaged; | using NumSharp.Backends.Unmanaged; | ||||
| using System; | using System; | ||||
| using System.Runtime.CompilerServices; | using System.Runtime.CompilerServices; | ||||
| using System.Runtime.InteropServices; | |||||
| using Tensorflow.Util; | using Tensorflow.Util; | ||||
| using static Tensorflow.c_api; | using static Tensorflow.c_api; | ||||
| @@ -89,7 +89,7 @@ namespace Tensorflow.Clustering | |||||
| public Tensor op() | public Tensor op() | ||||
| { | { | ||||
| var x = control_flow_ops.cond(gen_math_ops.equal(_num_remaining, 0), | var x = control_flow_ops.cond(gen_math_ops.equal(_num_remaining, 0), | ||||
| () => | |||||
| () => | |||||
| { | { | ||||
| return check_ops.assert_equal(_cluster_centers_initialized, true); | return check_ops.assert_equal(_cluster_centers_initialized, true); | ||||
| }, | }, | ||||
| @@ -70,8 +70,8 @@ namespace Tensorflow.Contexts | |||||
| => context_switches.Current().EagerMode; | => context_switches.Current().EagerMode; | ||||
| public string shared_name(string name = null) | public string shared_name(string name = null) | ||||
| => !string.IsNullOrEmpty(name) || !executing_eagerly() ? | |||||
| name : | |||||
| => !string.IsNullOrEmpty(name) || !executing_eagerly() ? | |||||
| name : | |||||
| "cd2c89b7-88b7-44c8-ad83-06c2a9158347"; | "cd2c89b7-88b7-44c8-ad83-06c2a9158347"; | ||||
| public void graph_mode() | public void graph_mode() | ||||
| @@ -15,8 +15,6 @@ | |||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow.Contexts | namespace Tensorflow.Contexts | ||||
| { | { | ||||
| @@ -14,9 +14,7 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | |||||
| namespace Tensorflow.Contexts | namespace Tensorflow.Contexts | ||||
| { | { | ||||
| @@ -1,5 +1,5 @@ | |||||
| using System.Linq; | |||||
| using NumSharp; | |||||
| using NumSharp; | |||||
| using System.Linq; | |||||
| using Tensorflow.Framework; | using Tensorflow.Framework; | ||||
| namespace Tensorflow.Contrib.Learn.Estimators | namespace Tensorflow.Contrib.Learn.Estimators | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow.Contrib.Train | |||||
| namespace Tensorflow.Contrib.Train | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Class to hold a set of hyperparameters as name-value pairs. | /// Class to hold a set of hyperparameters as name-value pairs. | ||||
| @@ -1,8 +1,5 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using Tensorflow.Framework.Models; | |||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -15,13 +12,13 @@ namespace Tensorflow | |||||
| Tensor _batch_size; | Tensor _batch_size; | ||||
| Tensor _drop_remainder; | 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) | base(input_dataset) | ||||
| { | { | ||||
| _input_dataset = input_dataset; | _input_dataset = input_dataset; | ||||
| _batch_size = tf.convert_to_tensor(batch_size, dtype: TF_DataType.TF_INT64, name: "batch_size"); | _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"); | _drop_remainder = tf.convert_to_tensor(drop_remainder, dtype: TF_DataType.TF_BOOL, name: "drop_remainder"); | ||||
| if (drop_remainder) | if (drop_remainder) | ||||
| { | { | ||||
| throw new NotImplementedException(""); | throw new NotImplementedException(""); | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using NumSharp; | |||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,7 +1,5 @@ | |||||
| using NumSharp; | using NumSharp; | ||||
| using System; | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Text; | |||||
| using Tensorflow.Data; | using Tensorflow.Data; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class DatasetOps | public class DatasetOps | ||||
| { | { | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class DatasetOptions | public class DatasetOptions | ||||
| { | { | ||||
| @@ -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 | public class DatasetSource : DatasetV2 | ||||
| { | { | ||||
| @@ -2,7 +2,6 @@ | |||||
| using System.Collections; | using System.Collections; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using Tensorflow.Framework.Models; | using Tensorflow.Framework.Models; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -18,9 +17,9 @@ namespace Tensorflow | |||||
| public TensorSpec[] structure { get; set; } | public TensorSpec[] structure { get; set; } | ||||
| public TensorShape[] output_shapes => structure.Select(x => x.shape).ToArray(); | public TensorShape[] output_shapes => structure.Select(x => x.shape).ToArray(); | ||||
| public TF_DataType[] output_types => structure.Select(x => x.dtype).ToArray(); | public TF_DataType[] output_types => structure.Select(x => x.dtype).ToArray(); | ||||
| public TensorSpec[] element_spec => structure; | public TensorSpec[] element_spec => structure; | ||||
| public IDatasetV2 cache(string filename = "") | public IDatasetV2 cache(string filename = "") | ||||
| @@ -54,7 +53,7 @@ namespace Tensorflow | |||||
| bool use_inter_op_parallelism = true, | bool use_inter_op_parallelism = true, | ||||
| bool preserve_cardinality = true, | bool preserve_cardinality = true, | ||||
| bool use_legacy_function = false) | bool use_legacy_function = false) | ||||
| => new MapDataset(this, | |||||
| => new MapDataset(this, | |||||
| map_func, | map_func, | ||||
| use_inter_op_parallelism: use_inter_op_parallelism, | use_inter_op_parallelism: use_inter_op_parallelism, | ||||
| preserve_cardinality: preserve_cardinality, | preserve_cardinality: preserve_cardinality, | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using NumSharp; | |||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using Tensorflow.Functions; | using Tensorflow.Functions; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow.Data | |||||
| namespace Tensorflow.Data | |||||
| { | { | ||||
| public class GeneratorDataset : DatasetSource | public class GeneratorDataset : DatasetSource | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using NumSharp; | |||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,7 +1,5 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Linq.Expressions; | |||||
| using System.Text; | |||||
| using Tensorflow.Framework.Models; | using Tensorflow.Framework.Models; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -23,7 +21,7 @@ namespace Tensorflow | |||||
| /// </summary> | /// </summary> | ||||
| /// <param name="filename"></param> | /// <param name="filename"></param> | ||||
| /// <returns></returns> | /// <returns></returns> | ||||
| IDatasetV2 cache(string filename=""); | |||||
| IDatasetV2 cache(string filename = ""); | |||||
| /// <summary> | /// <summary> | ||||
| /// | /// | ||||
| @@ -57,12 +55,12 @@ namespace Tensorflow | |||||
| IDatasetV2 optimize(string[] optimizations, string[] optimization_configs); | IDatasetV2 optimize(string[] optimizations, string[] optimization_configs); | ||||
| IDatasetV2 map(Func<Tensor, Tensor> map_func, | |||||
| IDatasetV2 map(Func<Tensor, Tensor> map_func, | |||||
| bool use_inter_op_parallelism = true, | bool use_inter_op_parallelism = true, | ||||
| bool preserve_cardinality = false, | bool preserve_cardinality = false, | ||||
| bool use_legacy_function = false); | bool use_legacy_function = false); | ||||
| IDatasetV2 map(Func<Tensor, (Tensor, Tensor), (Tensor, Tensor)> map_func, | |||||
| IDatasetV2 map(Func<Tensor, (Tensor, Tensor), (Tensor, Tensor)> map_func, | |||||
| int num_parallel_calls = -1); | int num_parallel_calls = -1); | ||||
| IDatasetV2 flat_map(Func<Tensor, IDatasetV2> map_func); | IDatasetV2 flat_map(Func<Tensor, IDatasetV2> map_func); | ||||
| @@ -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 | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class IteratorBase | public class IteratorBase | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,10 +1,5 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using Tensorflow.Functions; | using Tensorflow.Functions; | ||||
| using Tensorflow.Graphs; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,8 +1,6 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using NumSharp; | |||||
| using System; | |||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| using System.Text; | |||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -40,7 +38,7 @@ namespace Tensorflow | |||||
| var start = IndexInEpoch; | var start = IndexInEpoch; | ||||
| // Shuffle for the first epoch | // Shuffle for the first epoch | ||||
| if(EpochsCompleted == 0 && start == 0 && shuffle) | |||||
| if (EpochsCompleted == 0 && start == 0 && shuffle) | |||||
| { | { | ||||
| var perm0 = np.arange(NumOfExamples); | var perm0 = np.arange(NumOfExamples); | ||||
| np.random.shuffle(perm0); | np.random.shuffle(perm0); | ||||
| @@ -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 System.IO; | ||||
| using NumSharp; | |||||
| using System.Threading.Tasks; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -90,7 +88,7 @@ namespace Tensorflow | |||||
| var validationImages = trainImages[np.arange(validationSize)]; | var validationImages = trainImages[np.arange(validationSize)]; | ||||
| var validationLabels = trainLabels[np.arange(validationSize)]; | var validationLabels = trainLabels[np.arange(validationSize)]; | ||||
| trainImages = trainImages[np.arange(validationSize, end)]; | trainImages = trainImages[np.arange(validationSize, end)]; | ||||
| trainLabels = trainLabels[np.arange(validationSize, end)]; | trainLabels = trainLabels[np.arange(validationSize, end)]; | ||||
| @@ -114,8 +112,8 @@ namespace Tensorflow | |||||
| var magic = Read32(bytestream); | var magic = Read32(bytestream); | ||||
| if (magic != 2051) | if (magic != 2051) | ||||
| throw new Exception($"Invalid magic number {magic} in MNIST image file: {file}"); | 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); | num_images = limit == null ? num_images : Math.Min(num_images, (int)limit); | ||||
| var rows = Read32(bytestream); | var rows = Read32(bytestream); | ||||
| @@ -136,25 +134,25 @@ namespace Tensorflow | |||||
| { | { | ||||
| if (!Path.IsPathRooted(file)) | if (!Path.IsPathRooted(file)) | ||||
| file = Path.Combine(AppContext.BaseDirectory, file); | file = Path.Combine(AppContext.BaseDirectory, file); | ||||
| using (var bytestream = new FileStream(file, FileMode.Open)) | using (var bytestream = new FileStream(file, FileMode.Open)) | ||||
| { | { | ||||
| var magic = Read32(bytestream); | var magic = Read32(bytestream); | ||||
| if (magic != 2049) | if (magic != 2049) | ||||
| throw new Exception($"Invalid magic number {magic} in MNIST label file: {file}"); | throw new Exception($"Invalid magic number {magic} in MNIST label file: {file}"); | ||||
| var num_items = Read32(bytestream); | var num_items = Read32(bytestream); | ||||
| num_items = limit == null ? num_items : Math.Min(num_items, (int)limit); | num_items = limit == null ? num_items : Math.Min(num_items, (int)limit); | ||||
| var buf = new byte[num_items]; | var buf = new byte[num_items]; | ||||
| bytestream.Read(buf, 0, buf.Length); | bytestream.Read(buf, 0, buf.Length); | ||||
| var labels = np.frombuffer(buf, np.uint8); | var labels = np.frombuffer(buf, np.uint8); | ||||
| if (one_hot) | if (one_hot) | ||||
| return DenseToOneHot(labels, num_classes); | return DenseToOneHot(labels, num_classes); | ||||
| return labels; | return labels; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow.Framework.Models; | |||||
| using Tensorflow.Framework.Models; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -10,8 +7,8 @@ namespace Tensorflow | |||||
| /// </summary> | /// </summary> | ||||
| public class ModelDataset : UnaryUnchangedStructureDataset | public class ModelDataset : UnaryUnchangedStructureDataset | ||||
| { | { | ||||
| public ModelDataset(IDatasetV2 input_dataset, | |||||
| AutotuneAlgorithm algorithm, | |||||
| public ModelDataset(IDatasetV2 input_dataset, | |||||
| AutotuneAlgorithm algorithm, | |||||
| long cpu_budget) : | long cpu_budget) : | ||||
| base(input_dataset) | base(input_dataset) | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using NumSharp; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -12,7 +9,7 @@ namespace Tensorflow | |||||
| public Type DataType { get; set; } = typeof(float); | public Type DataType { get; set; } = typeof(float); | ||||
| public bool ReShape { get; set; } | public bool ReShape { get; set; } | ||||
| public int ValidationSize { get; set; } = 5000; | public int ValidationSize { get; set; } = 5000; | ||||
| public int? TrainSize { get; set; } | |||||
| public int? TrainSize { get; set; } | |||||
| public int? TestSize { get; set; } | public int? TestSize { get; set; } | ||||
| public string SourceUrl { get; set; } | public string SourceUrl { get; set; } | ||||
| public bool ShowProgressInConsole { get; set; } | public bool ShowProgressInConsole { get; set; } | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -12,9 +9,9 @@ namespace Tensorflow | |||||
| { | { | ||||
| Tensor _optimizations; | 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) | base(dataset) | ||||
| { | { | ||||
| if (optimizations == null) | if (optimizations == null) | ||||
| @@ -26,7 +23,7 @@ namespace Tensorflow | |||||
| variant_tensor = ops.optimize_dataset( | variant_tensor = ops.optimize_dataset( | ||||
| _input_dataset.variant_tensor, | _input_dataset.variant_tensor, | ||||
| _optimizations, | _optimizations, | ||||
| output_types, | |||||
| output_types, | |||||
| output_shapes, | output_shapes, | ||||
| optimization_configs: optimization_configs); | optimization_configs: optimization_configs); | ||||
| } | } | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// An identity `Dataset` that stores options. | /// An identity `Dataset` that stores options. | ||||
| @@ -11,7 +7,7 @@ namespace Tensorflow | |||||
| { | { | ||||
| DatasetOptions options; | DatasetOptions options; | ||||
| public OptionsDataset(IDatasetV2 input_dataset, DatasetOptions options) | |||||
| public OptionsDataset(IDatasetV2 input_dataset, DatasetOptions options) | |||||
| : base(input_dataset) | : base(input_dataset) | ||||
| { | { | ||||
| this.options = options; | this.options = options; | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow.Framework.Models; | using Tensorflow.Framework.Models; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -1,7 +1,5 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using Tensorflow.Functions; | using Tensorflow.Functions; | ||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| @@ -10,14 +8,14 @@ namespace Tensorflow | |||||
| //A `Dataset` that maps a function over elements in its input in parallel. | //A `Dataset` that maps a function over elements in its input in parallel. | ||||
| public class ParallelMapDataset : UnaryDataset | public class ParallelMapDataset : UnaryDataset | ||||
| { | { | ||||
| public ParallelMapDataset(IDatasetV2 input_dataset, | |||||
| public ParallelMapDataset(IDatasetV2 input_dataset, | |||||
| Func<Tensor, (Tensor, Tensor), (Tensor, Tensor)> map_func, | Func<Tensor, (Tensor, Tensor), (Tensor, Tensor)> map_func, | ||||
| int num_parallel_calls = -1, | int num_parallel_calls = -1, | ||||
| bool use_inter_op_parallelism = true, | bool use_inter_op_parallelism = true, | ||||
| bool preserve_cardinality = false, | bool preserve_cardinality = false, | ||||
| bool use_legacy_function = false) : base(input_dataset) | 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.dtype).ToArray(), | ||||
| input_dataset.element_spec.Select(x => x.shape).ToArray()); | input_dataset.element_spec.Select(x => x.shape).ToArray()); | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -13,7 +10,7 @@ namespace Tensorflow | |||||
| Tensor _buffer_size; | Tensor _buffer_size; | ||||
| public PrefetchDataset(IDatasetV2 input_dataset, | public PrefetchDataset(IDatasetV2 input_dataset, | ||||
| long buffer_size = -1, | |||||
| long buffer_size = -1, | |||||
| int? slack_period = null) : | int? slack_period = null) : | ||||
| base(input_dataset) | base(input_dataset) | ||||
| { | { | ||||
| @@ -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; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow.Data | namespace Tensorflow.Data | ||||
| @@ -12,8 +9,8 @@ namespace Tensorflow.Data | |||||
| Tensor step; | Tensor step; | ||||
| Tensor stop; | Tensor stop; | ||||
| public RangeDataset(int stop, | |||||
| int start = 0, | |||||
| public RangeDataset(int stop, | |||||
| int start = 0, | |||||
| int step = 1, | int step = 1, | ||||
| TF_DataType output_type = TF_DataType.TF_INT64) | TF_DataType output_type = TF_DataType.TF_INT64) | ||||
| { | { | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// A `Dataset` that repeats its input several times. | /// A `Dataset` that repeats its input several times. | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -15,9 +13,9 @@ namespace Tensorflow | |||||
| Tensor _seed2; | Tensor _seed2; | ||||
| bool _reshuffle_each_iteration; | 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) : | bool reshuffle_each_iteration = true) : | ||||
| base(input_dataset) | base(input_dataset) | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -16,7 +13,7 @@ namespace Tensorflow | |||||
| int count) : base(input_dataset) | int count) : base(input_dataset) | ||||
| { | { | ||||
| _count = tf.convert_to_tensor(count, dtype: dtypes.int64, name: "count"); | _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, | _count, | ||||
| output_types, output_shapes); | output_types, output_shapes); | ||||
| } | } | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -1,8 +1,5 @@ | |||||
| using NumSharp; | using NumSharp; | ||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -1,10 +1,5 @@ | |||||
| using NumSharp; | using NumSharp; | ||||
| using NumSharp.Utilities; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using Tensorflow.Framework.Models; | |||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow.Data | namespace Tensorflow.Data | ||||
| @@ -45,7 +40,7 @@ namespace Tensorflow.Data | |||||
| _tensors = new[] { features, labels }; | _tensors = new[] { features, labels }; | ||||
| var batched_spec = _tensors.Select(x => x.ToTensorSpec()).ToArray(); | var batched_spec = _tensors.Select(x => x.ToTensorSpec()).ToArray(); | ||||
| structure = batched_spec.Select(x => x._unbatch()).ToArray(); | structure = batched_spec.Select(x => x._unbatch()).ToArray(); | ||||
| variant_tensor = ops.tensor_slice_dataset(_tensors, output_shapes); | variant_tensor = ops.tensor_slice_dataset(_tensors, output_shapes); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,9 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow.Framework.Models; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Abstract class representing a dataset with one input. | /// Abstract class representing a dataset with one input. | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Represents a unary dataset with the same input and output structure. | /// Represents a unary dataset with the same input and output structure. | ||||
| @@ -12,7 +8,7 @@ namespace Tensorflow | |||||
| public UnaryUnchangedStructureDataset(IDatasetV2 input_dataset) : | public UnaryUnchangedStructureDataset(IDatasetV2 input_dataset) : | ||||
| base(input_dataset) | base(input_dataset) | ||||
| { | { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,12 +1,9 @@ | |||||
| using System; | using System; | ||||
| using System.IO; | using System.IO; | ||||
| using System.IO.Compression; | using System.IO.Compression; | ||||
| using System.Collections.Generic; | |||||
| using System.Net; | using System.Net; | ||||
| using System.Text; | |||||
| using System.Threading; | using System.Threading; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using Tensorflow.Framework.Models; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -42,9 +39,9 @@ namespace Tensorflow | |||||
| return; | return; | ||||
| } | } | ||||
| Directory.CreateDirectory(dirSaveTo); | Directory.CreateDirectory(dirSaveTo); | ||||
| using (var wc = new WebClient()) | using (var wc = new WebClient()) | ||||
| { | { | ||||
| await wc.DownloadFileTaskAsync(url, fileSaveTo).ConfigureAwait(false); | await wc.DownloadFileTaskAsync(url, fileSaveTo).ConfigureAwait(false); | ||||
| @@ -73,7 +70,7 @@ namespace Tensorflow | |||||
| { | { | ||||
| if (showProgressInConsole) | if (showProgressInConsole) | ||||
| Console.WriteLine($"The file {destFileName} already exists"); | Console.WriteLine($"The file {destFileName} already exists"); | ||||
| } | |||||
| } | |||||
| using (GZipStream unzipStream = new GZipStream(File.OpenRead(zipFile), CompressionMode.Decompress)) | using (GZipStream unzipStream = new GZipStream(File.OpenRead(zipFile), CompressionMode.Decompress)) | ||||
| { | { | ||||
| @@ -86,7 +83,7 @@ namespace Tensorflow | |||||
| unzipStream.Close(); | unzipStream.Close(); | ||||
| } | } | ||||
| } | |||||
| } | |||||
| public static async Task ShowProgressInConsole(this Task task, bool enable) | public static async Task ShowProgressInConsole(this Task task, bool enable) | ||||
| { | { | ||||
| @@ -101,12 +98,12 @@ namespace Tensorflow | |||||
| var showProgressTask = ShowProgressInConsole(cts); | var showProgressTask = ShowProgressInConsole(cts); | ||||
| try | try | ||||
| { | |||||
| { | |||||
| await task; | await task; | ||||
| } | } | ||||
| finally | finally | ||||
| { | { | ||||
| cts.Cancel(); | |||||
| cts.Cancel(); | |||||
| } | } | ||||
| await showProgressTask; | await showProgressTask; | ||||
| @@ -1,7 +1,5 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System.Text; | |||||
| using Tensorflow.Framework.Models; | using Tensorflow.Framework.Models; | ||||
| namespace Tensorflow | namespace Tensorflow | ||||
| @@ -15,10 +15,8 @@ | |||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Diagnostics.CodeAnalysis; | using System.Diagnostics.CodeAnalysis; | ||||
| using System.Runtime.CompilerServices; | using System.Runtime.CompilerServices; | ||||
| using System.Text; | |||||
| namespace Tensorflow | namespace Tensorflow | ||||
| { | { | ||||
| @@ -77,7 +75,7 @@ namespace Tensorflow | |||||
| public void Dispose() | public void Dispose() | ||||
| { | { | ||||
| lock(this) | |||||
| lock (this) | |||||
| { | { | ||||
| internal_dispose(true); | internal_dispose(true); | ||||
| GC.SuppressFinalize(this); | GC.SuppressFinalize(this); | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| { | { | ||||
| @@ -14,10 +14,9 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System.Collections.Generic; | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using static Tensorflow.Binding; | |||||
| using Tensorflow.Contexts; | using Tensorflow.Contexts; | ||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| @@ -14,10 +14,8 @@ | |||||
| limitations under the License. | limitations under the License. | ||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System.Linq; | |||||
| using System; | |||||
| using static Tensorflow.Binding; | |||||
| using Tensorflow.Contexts; | using Tensorflow.Contexts; | ||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Linq; | |||||
| using Tensorflow.Gradients; | using Tensorflow.Gradients; | ||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| using static Tensorflow.tensorflow; | using static Tensorflow.tensorflow; | ||||
| @@ -21,7 +18,7 @@ namespace Tensorflow.Eager | |||||
| bool should_record = false; | bool should_record = false; | ||||
| foreach (var tape in tf.GetTapeSet()) | foreach (var tape in tf.GetTapeSet()) | ||||
| { | { | ||||
| if(tape.ShouldRecord(input_ids, input_dtypes)) | |||||
| if (tape.ShouldRecord(input_ids, input_dtypes)) | |||||
| { | { | ||||
| should_record = true; | should_record = true; | ||||
| break; | break; | ||||
| @@ -66,7 +63,7 @@ namespace Tensorflow.Eager | |||||
| bool op_inputs_tuple_created = false; | bool op_inputs_tuple_created = false; | ||||
| #pragma warning restore CS0219 // Variable is assigned but its value is never used | #pragma warning restore CS0219 // Variable is assigned but its value is never used | ||||
| var unused_input_indices = gradient_exclustions.OpGradientUnusedInputIndices(op_name); | 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) | if (unused_input_indices.Length == 0) | ||||
| op_inputs = new Tensor[0]; | op_inputs = new Tensor[0]; | ||||
| @@ -79,7 +76,7 @@ namespace Tensorflow.Eager | |||||
| else | else | ||||
| op_inputs = inputs; | 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)); | () => GetGradientFunction(op_name, inputs, attrs, results)); | ||||
| @@ -1,8 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| namespace Tensorflow.Eager | |||||
| namespace Tensorflow.Eager | |||||
| { | { | ||||
| public partial class EagerRunner | public partial class EagerRunner | ||||
| { | { | ||||
| @@ -15,9 +15,8 @@ | |||||
| ******************************************************************************/ | ******************************************************************************/ | ||||
| using System.Linq; | using System.Linq; | ||||
| using System; | |||||
| using static Tensorflow.Binding; | |||||
| using Tensorflow.Contexts; | using Tensorflow.Contexts; | ||||
| using static Tensorflow.Binding; | |||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| { | { | ||||
| @@ -1,12 +1,12 @@ | |||||
| using System.Collections.Generic; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | using System.Linq; | ||||
| using System; | |||||
| using static Tensorflow.OpDef.Types; | |||||
| using static Tensorflow.Binding; | |||||
| using Tensorflow.Util; | |||||
| using System.Runtime.InteropServices; | using System.Runtime.InteropServices; | ||||
| using Tensorflow.Contexts; | using Tensorflow.Contexts; | ||||
| using Tensorflow.Functions; | using Tensorflow.Functions; | ||||
| using Tensorflow.Util; | |||||
| using static Tensorflow.Binding; | |||||
| using static Tensorflow.OpDef.Types; | |||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| { | { | ||||
| @@ -61,7 +61,7 @@ namespace Tensorflow.Eager | |||||
| var attr_value = args[i + 1]; | var attr_value = args[i + 1]; | ||||
| var attr = op_def.Attr.FirstOrDefault(x => x.Name == attr_name); | 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_name); | ||||
| flattened_attrs.Add(attr_value); | flattened_attrs.Add(attr_value); | ||||
| @@ -89,7 +89,7 @@ namespace Tensorflow.Eager | |||||
| flattened_attrs.Add(len); | flattened_attrs.Add(len); | ||||
| } | } | ||||
| attr_list_sizes[input_arg.NumberAttr] = len; | attr_list_sizes[input_arg.NumberAttr] = len; | ||||
| if (len > 0) | if (len > 0) | ||||
| { | { | ||||
| var fast_input_array = (object[])args[i]; | 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); | op = c_api.TFE_NewOp(ctx.Handle, op_or_function_name, status.Handle); | ||||
| thread_local_eager_operation_map[ctx] = op; | thread_local_eager_operation_map[ctx] = op; | ||||
| } | } | ||||
| status.Check(true); | status.Check(true); | ||||
| return op; | return op; | ||||
| } | } | ||||
| @@ -189,7 +189,7 @@ namespace Tensorflow.Eager | |||||
| //return !GetAccumulatorSet()->empty(); | //return !GetAccumulatorSet()->empty(); | ||||
| return false; | return false; | ||||
| } | } | ||||
| bool HasGradientTape() | bool HasGradientTape() | ||||
| { | { | ||||
| return tf.GetTapeSet().Count > 0; | return tf.GetTapeSet().Count > 0; | ||||
| @@ -262,7 +262,7 @@ namespace Tensorflow.Eager | |||||
| var key = attrs[i].ToString(); | var key = attrs[i].ToString(); | ||||
| var value = attrs[i + 1]; | 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); | var type = c_api.TFE_OpGetAttrType(op, key, ref is_list, status.Handle); | ||||
| if (!status.ok()) return; | if (!status.ok()) return; | ||||
| if (is_list != 0) | if (is_list != 0) | ||||
| @@ -286,8 +286,8 @@ namespace Tensorflow.Eager | |||||
| /// <param name="attr_value"></param> | /// <param name="attr_value"></param> | ||||
| /// <param name="attr_list_sizes"></param> | /// <param name="attr_list_sizes"></param> | ||||
| /// <param name="status"></param> | /// <param name="status"></param> | ||||
| 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<string, long> attr_list_sizes, | Dictionary<string, long> attr_list_sizes, | ||||
| Status status) | Status status) | ||||
| { | { | ||||
| @@ -295,7 +295,7 @@ namespace Tensorflow.Eager | |||||
| var type = c_api.TFE_OpGetAttrType(op, attr_name, ref is_list, status.Handle); | var type = c_api.TFE_OpGetAttrType(op, attr_name, ref is_list, status.Handle); | ||||
| if (status.Code != TF_Code.TF_OK) return; | if (status.Code != TF_Code.TF_OK) return; | ||||
| if(attr_value == null) | |||||
| if (attr_value == null) | |||||
| { | { | ||||
| if (is_list != 0) | if (is_list != 0) | ||||
| #pragma warning disable CS0642 // Possible mistaken empty statement | #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); | c_api.TFE_OpSetAttrShapeList(op, key, dims, num_dims, num_values, status.Handle); | ||||
| Array.ForEach(dims, x => Marshal.FreeHGlobal(x)); | 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); | c_api.TFE_OpSetAttrTypeList(op, key, values2, values2.Length); | ||||
| attr_list_sizes[key] = values2.Length; | attr_list_sizes[key] = values2.Length; | ||||
| @@ -363,12 +363,12 @@ namespace Tensorflow.Eager | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool SetOpAttrScalar(Context ctx, SafeOpHandle op, | |||||
| bool SetOpAttrScalar(Context ctx, SafeOpHandle op, | |||||
| string key, object value, TF_AttrType type, | string key, object value, TF_AttrType type, | ||||
| Dictionary<string, long> attr_list_sizes, | Dictionary<string, long> attr_list_sizes, | ||||
| Status status) | Status status) | ||||
| { | { | ||||
| switch(type) | |||||
| switch (type) | |||||
| { | { | ||||
| case TF_AttrType.TF_ATTR_STRING: | case TF_AttrType.TF_ATTR_STRING: | ||||
| c_api.TFE_OpSetAttrString(op, key, value.ToString(), (uint)value.ToString().Length); | c_api.TFE_OpSetAttrString(op, key, value.ToString(), (uint)value.ToString().Length); | ||||
| @@ -394,7 +394,7 @@ namespace Tensorflow.Eager | |||||
| if (value is ConcreteFunction func) | if (value is ConcreteFunction func) | ||||
| c_api.TFE_OpSetAttrFunctionName(op, key, func.Name, func.Name.Length); | c_api.TFE_OpSetAttrFunctionName(op, key, func.Name, func.Name.Length); | ||||
| else | else | ||||
| throw new NotImplementedException("TF_AttrType.TF_ATTR_FUNC"); | |||||
| throw new NotImplementedException("TF_AttrType.TF_ATTR_FUNC"); | |||||
| break; | break; | ||||
| default: | default: | ||||
| throw new NotImplementedException($"SetOpAttrScalar for {type}"); | throw new NotImplementedException($"SetOpAttrScalar for {type}"); | ||||
| @@ -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.Gradients; | ||||
| using Tensorflow.Util; | using Tensorflow.Util; | ||||
| @@ -31,7 +28,7 @@ namespace Tensorflow.Eager | |||||
| source_tensors_that_are_targets.Add(target_id, TapeTensorFromTensor(tensor)); | source_tensors_that_are_targets.Add(target_id, TapeTensorFromTensor(tensor)); | ||||
| } | } | ||||
| if(output_gradients != null) | |||||
| if (output_gradients != null) | |||||
| { | { | ||||
| throw new NotImplementedException(""); | throw new NotImplementedException(""); | ||||
| } | } | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow.Gradients; | using Tensorflow.Gradients; | ||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| using static Tensorflow.tensorflow; | using static Tensorflow.tensorflow; | ||||
| @@ -21,7 +19,7 @@ namespace Tensorflow.Eager | |||||
| return; | return; | ||||
| } | } | ||||
| foreach(var tape in tf.GetTapeSet()) | |||||
| foreach (var tape in tf.GetTapeSet()) | |||||
| { | { | ||||
| tape.RecordOperation(op_type, input_tensors, output_tensors, | tape.RecordOperation(op_type, input_tensors, output_tensors, | ||||
| input_ids, input_dtypes, | input_ids, input_dtypes, | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow.Gradients; | using Tensorflow.Gradients; | ||||
| using static Tensorflow.tensorflow; | using static Tensorflow.tensorflow; | ||||
| @@ -1,7 +1,5 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using Tensorflow.Gradients; | using Tensorflow.Gradients; | ||||
| using static Tensorflow.tensorflow; | using static Tensorflow.tensorflow; | ||||
| @@ -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 | namespace Tensorflow.Eager | ||||
| { | { | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Linq; | |||||
| using System.Text; | |||||
| using System.Collections.Generic; | |||||
| using Tensorflow.Gradients; | using Tensorflow.Gradients; | ||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| @@ -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 | |||||
| { | { | ||||
| /// <summary> | /// <summary> | ||||
| /// Eager mode runner | /// Eager mode runner | ||||
| @@ -1,8 +1,5 @@ | |||||
| using NumSharp; | using NumSharp; | ||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using System.Threading; | |||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| @@ -11,7 +8,7 @@ namespace Tensorflow.Eager | |||||
| { | { | ||||
| public EagerTensor() : base(IntPtr.Zero) | public EagerTensor() : base(IntPtr.Zero) | ||||
| { | { | ||||
| } | } | ||||
| public EagerTensor(SafeTensorHandleHandle handle) : base(IntPtr.Zero) | public EagerTensor(SafeTensorHandleHandle handle) : base(IntPtr.Zero) | ||||
| @@ -84,7 +81,7 @@ namespace Tensorflow.Eager | |||||
| void copy_handle_data(Tensor target_t) | 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) | target_t.dtype == TF_DataType.TF_VARIANT) | ||||
| { | { | ||||
| // need to export | // need to export | ||||
| @@ -1,8 +1,4 @@ | |||||
| using NumSharp; | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow.Eager; | |||||
| using System; | |||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| { | { | ||||
| @@ -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 | public partial class EagerTensor | ||||
| { | { | ||||
| @@ -1,6 +1,4 @@ | |||||
| using NumSharp; | |||||
| using System; | |||||
| using System.Linq; | |||||
| using System; | |||||
| using Tensorflow.Util; | using Tensorflow.Util; | ||||
| using static Tensorflow.Binding; | using static Tensorflow.Binding; | ||||
| @@ -1,7 +1,4 @@ | |||||
| using System; | |||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow.Contexts; | |||||
| using Tensorflow.Contexts; | |||||
| namespace Tensorflow.Eager | namespace Tensorflow.Eager | ||||
| { | { | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | using System; | ||||
| using System.Collections.Generic; | |||||
| using System.Text; | |||||
| using Tensorflow.Contexts; | using Tensorflow.Contexts; | ||||
| using Tensorflow.Gradients; | using Tensorflow.Gradients; | ||||
| @@ -13,8 +11,8 @@ namespace Tensorflow.Eager | |||||
| Tensor[] inputs, object[] attrs, | Tensor[] inputs, object[] attrs, | ||||
| string name = null); | 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); | object[] args = null); | ||||
| Tensor[] TFE_FastPathExecute(Context ctx, | Tensor[] TFE_FastPathExecute(Context ctx, | ||||
| @@ -242,7 +242,7 @@ namespace Tensorflow | |||||
| /// <param name="length">size_t</param> | /// <param name="length">size_t</param> | ||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static extern void TFE_OpSetAttrString(SafeOpHandle op, string attr_name, string value, uint length); | public static extern void TFE_OpSetAttrString(SafeOpHandle op, string attr_name, string value, uint length); | ||||
| [DllImport(TensorFlowLibName)] | [DllImport(TensorFlowLibName)] | ||||
| public static extern void TFE_OpSetAttrTypeList(SafeOpHandle op, string attr_name, TF_DataType[] values, int num_values); | 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); | public static extern IntPtr ResourceVariable_Handle(IntPtr variable); | ||||
| [DllImport(TensorFlowLibName)] | [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[] sources, int source_size, | ||||
| IntPtr[] outputs, int output_size); | IntPtr[] outputs, int output_size); | ||||
| } | } | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class InvalidArgumentError : TensorflowException | public class InvalidArgumentError : TensorflowException | ||||
| { | { | ||||
| @@ -1,6 +1,4 @@ | |||||
| using System; | |||||
| namespace Tensorflow | |||||
| namespace Tensorflow | |||||
| { | { | ||||
| public class KeyError : TensorflowException | public class KeyError : TensorflowException | ||||
| { | { | ||||