@@ -151,7 +151,7 @@ namespace Tensorflow | |||
public Action<int, int> Dataset | |||
=> (epoch, iterate) => | |||
{ | |||
TensorShape shape = (16, 32, 32, 3); | |||
Shape shape = (16, 32, 32, 3); | |||
var images = np.arange(shape.size).astype(np.float32).reshape(shape.dims); | |||
var data_handler = new DataHandler(new DataHandlerArgs | |||
{ | |||
@@ -22,7 +22,7 @@ namespace Tensorflow | |||
Tensor permutation(Tensor tensor) | |||
{ | |||
TensorShape shape = (8, 64, 64, 3); | |||
Shape shape = (8, 64, 64, 3); | |||
var images = np.arange(shape.size).astype(np.float32).reshape(shape.dims); | |||
return tf.constant(images); | |||
} | |||
@@ -19,7 +19,7 @@ namespace Tensorflow | |||
public Action<int, int> InputLayer | |||
=> (epoch, iterate) => | |||
{ | |||
TensorShape shape = (32, 256, 256, 3); // 48M | |||
Shape shape = (32, 256, 256, 3); // 48M | |||
var images = np.arange(shape.size).astype(np.float32).reshape(shape.dims); | |||
var inputs = keras.Input((shape.dims[1], shape.dims[2], 3)); | |||
@@ -31,7 +31,7 @@ namespace Tensorflow | |||
public Action<int, int> Prediction | |||
=> (epoch, iterate) => | |||
{ | |||
TensorShape shape = (32, 256, 256, 3); // 48M | |||
Shape shape = (32, 256, 256, 3); // 48M | |||
var images = np.arange(shape.size).astype(np.float32).reshape(shape.dims); | |||
var inputs = keras.Input((shape.dims[1], shape.dims[2], 3)); | |||
@@ -65,7 +65,7 @@ namespace Tensorflow | |||
/// <param name="shape"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor broadcast_to(Tensor input, TensorShape shape, string name = null) | |||
public Tensor broadcast_to(Tensor input, Shape shape, string name = null) | |||
=> gen_array_ops.broadcast_to(input, shape, name: name); | |||
public Tensor check_numerics(Tensor tensor, string message, string name = null) | |||
@@ -85,7 +85,7 @@ namespace Tensorflow | |||
return tf_with(ops.name_scope(name), scope => | |||
{ | |||
var tensor = ops.convert_to_tensor(axis, name: "concat_dim", dtype: dtypes.int32); | |||
Debug.Assert(tensor.TensorShape.ndim == 0); | |||
Debug.Assert(tensor.shape.ndim == 0); | |||
return identity(values.First(), name: scope); | |||
}); | |||
} | |||
@@ -152,7 +152,7 @@ namespace Tensorflow | |||
/// <param name="name"></param> | |||
/// <param name="conjugate"></param> | |||
/// <returns></returns> | |||
public Tensor transpose<T1>(T1 a, TensorShape perm = null, string name = "transpose", bool conjugate = false) | |||
public Tensor transpose<T1>(T1 a, Shape perm = null, string name = "transpose", bool conjugate = false) | |||
=> array_ops.transpose(a, perm, name, conjugate); | |||
/// <summary> | |||
@@ -246,7 +246,7 @@ namespace Tensorflow | |||
/// <typeparam name="T"></typeparam> | |||
/// <param name="input">A `Tensor`. The default value to produce when output is not fed.</param> | |||
/// <param name="shape"> | |||
/// A `tf.TensorShape` or list of `int`s. The (possibly partial) shape of | |||
/// A `tf.Shape` or list of `int`s. The (possibly partial) shape of | |||
/// the tensor. | |||
/// </param> | |||
/// <param name="name">A name for the operation (optional).</param> | |||
@@ -25,7 +25,7 @@ namespace Tensorflow | |||
=> tf.Context.graph_mode(); | |||
public IVariableV1 get_variable(string name, | |||
TensorShape shape = null, | |||
Shape shape = null, | |||
TF_DataType dtype = TF_DataType.DtInvalid, | |||
object initializer = null, // IInitializer or Tensor | |||
bool? trainable = null, | |||
@@ -58,7 +58,7 @@ namespace Tensorflow | |||
string name = null) | |||
=> image_ops_impl.resize_images(images, size, method, preserve_aspect_ratio, antialias, name); | |||
public Tensor resize_images_v2(Tensor images, TensorShape size, string method = ResizeMethod.BILINEAR, bool preserve_aspect_ratio = false, bool antialias = false, | |||
public Tensor resize_images_v2(Tensor images, Shape size, string method = ResizeMethod.BILINEAR, bool preserve_aspect_ratio = false, bool antialias = false, | |||
string name = null) | |||
=> image_ops_impl.resize_images_v2(images, size, method, preserve_aspect_ratio, antialias, name); | |||
@@ -96,7 +96,7 @@ namespace Tensorflow | |||
seed: seed, | |||
dtype: dtype); | |||
public IInitializer zeros_initializer(TensorShape shape = null, | |||
public IInitializer zeros_initializer(Shape shape = null, | |||
TF_DataType dtype = TF_DataType.TF_FLOAT) => new Zeros(shape: shape, | |||
dtype: dtype); | |||
} | |||
@@ -27,7 +27,7 @@ namespace Tensorflow | |||
public Tensor eye(int num_rows, | |||
int num_columns = -1, | |||
TensorShape batch_shape = null, | |||
Shape batch_shape = null, | |||
TF_DataType dtype = TF_DataType.TF_DOUBLE, | |||
string name = null) | |||
=> ops.eye(num_rows, num_columns: num_columns, batch_shape: batch_shape, dtype: dtype, name: name); | |||
@@ -50,7 +50,7 @@ namespace Tensorflow | |||
Tensor maxlength = null, | |||
TF_DataType dtype = TF_DataType.TF_INT32, | |||
string name = null, | |||
TensorShape axis = null, | |||
Shape axis = null, | |||
bool binary_output = false) | |||
=> math_ops.bincount(arr, weights: weights, minlength: minlength, maxlength: maxlength, | |||
dtype: dtype, name: name, axis: axis, binary_output: binary_output); | |||
@@ -327,7 +327,7 @@ namespace Tensorflow | |||
=> gen_math_ops.log(x, name); | |||
public Tensor equal(Tensor x, Tensor y, string name = null) | |||
=> gen_math_ops.equal(x, y, name); | |||
=> gen_math_ops.equal(x, y, name: name); | |||
/// <summary> | |||
/// Computes arctangent of `y/x` element-wise, respecting signs of the arguments. | |||
@@ -453,7 +453,7 @@ namespace Tensorflow | |||
public static Tensor truediv(Tensor x, Tensor y, string name = null) | |||
=> math_ops.truediv(x, y, name: name); | |||
public Tensor range(object start, object limit = null, object delta = null, TF_DataType dtype = TF_DataType.DtInvalid, string name = "range") | |||
public Tensor range(object start, object limit = null, object delta = null, TF_DataType? dtype = null, string name = "range") | |||
=> math_ops.range(start, limit: limit, delta: delta, dtype: dtype, name: name); | |||
public Tensor real(Tensor input, string name = null) | |||
@@ -522,7 +522,7 @@ namespace Tensorflow | |||
return math_ops.reduce_sum(input, keepdims: keepdims, name: name); | |||
} | |||
public Tensor reduce_sum(Tensor input, TensorShape axis, int? reduction_indices = null, | |||
public Tensor reduce_sum(Tensor input, Shape axis, int? reduction_indices = null, | |||
bool keepdims = false, string name = null) | |||
=> math_ops.reduce_sum(input, axis, keepdims: keepdims, name: name); | |||
@@ -32,7 +32,7 @@ namespace Tensorflow | |||
/// <returns></returns> | |||
public PaddingFIFOQueue PaddingFIFOQueue(int capacity, | |||
TF_DataType[] dtypes, | |||
TensorShape[] shapes, | |||
Shape[] shapes, | |||
string[] names = null, | |||
string shared_name = null, | |||
string name = "padding_fifo_queue") | |||
@@ -45,7 +45,7 @@ namespace Tensorflow | |||
public PaddingFIFOQueue PaddingFIFOQueue(int capacity, | |||
TF_DataType dtype, | |||
TensorShape shape, | |||
Shape shape, | |||
string shared_name = null, | |||
string name = "padding_fifo_queue") | |||
=> new PaddingFIFOQueue(capacity, | |||
@@ -66,7 +66,7 @@ namespace Tensorflow | |||
/// <returns></returns> | |||
public FIFOQueue FIFOQueue(int capacity, | |||
TF_DataType[] dtypes, | |||
TensorShape[] shapes = null, | |||
Shape[] shapes = null, | |||
string[] names = null, | |||
string shared_name = null, | |||
string name = "fifo_queue") | |||
@@ -79,12 +79,12 @@ namespace Tensorflow | |||
public FIFOQueue FIFOQueue(int capacity, | |||
TF_DataType dtype, | |||
TensorShape shape = null, | |||
Shape shape = null, | |||
string shared_name = null, | |||
string name = "fifo_queue") | |||
=> new FIFOQueue(capacity, | |||
new[] { dtype }, | |||
new[] { shape ?? new TensorShape() }, | |||
new[] { shape ?? Shape.Null }, | |||
shared_name: shared_name, | |||
name: name); | |||
@@ -99,26 +99,26 @@ namespace Tensorflow | |||
/// <returns></returns> | |||
public PriorityQueue PriorityQueue(int capacity, | |||
TF_DataType dtype, | |||
TensorShape shape = null, | |||
Shape shape = null, | |||
string shared_name = null, | |||
string name = "priority_queue") | |||
=> new PriorityQueue(capacity, | |||
new[] { dtype }, | |||
new[] { shape ?? new TensorShape() }, | |||
new[] { shape ?? Shape.Null }, | |||
shared_name: shared_name, | |||
name: name); | |||
public RandomShuffleQueue RandomShuffleQueue(int capacity, | |||
int min_after_dequeue, | |||
TF_DataType dtype, | |||
TensorShape shape = null, | |||
Shape shape = null, | |||
int? seed = null, | |||
string shared_name = null, | |||
string name = "random_shuffle_queue") | |||
=> new RandomShuffleQueue(capacity, | |||
min_after_dequeue: min_after_dequeue, | |||
new[] { dtype }, | |||
new[] { shape ?? new TensorShape() }, | |||
new[] { shape ?? Shape.Null }, | |||
seed: seed, | |||
shared_name: shared_name, | |||
name: name); | |||
@@ -32,7 +32,7 @@ namespace Tensorflow | |||
/// <param name="seed"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor normal(TensorShape shape, | |||
public Tensor normal(Shape shape, | |||
float mean = 0.0f, | |||
float stddev = 1.0f, | |||
TF_DataType dtype = TF_DataType.TF_FLOAT, | |||
@@ -49,7 +49,7 @@ namespace Tensorflow | |||
/// <param name="seed"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor truncated_normal(TensorShape shape, | |||
public Tensor truncated_normal(Shape shape, | |||
float mean = 0.0f, | |||
float stddev = 1.0f, | |||
TF_DataType dtype = TF_DataType.TF_FLOAT, | |||
@@ -63,7 +63,7 @@ namespace Tensorflow | |||
string name = null, | |||
TF_DataType output_dtype = TF_DataType.DtInvalid) => random_ops.multinomial(logits, num_samples, seed: seed, name: name, output_dtype: output_dtype); | |||
public Tensor uniform(TensorShape shape, | |||
public Tensor uniform(Shape shape, | |||
float minval = 0, | |||
float maxval = 1, | |||
TF_DataType dtype = TF_DataType.TF_FLOAT, | |||
@@ -77,7 +77,7 @@ namespace Tensorflow | |||
} | |||
} | |||
public Tensor random_uniform(TensorShape shape, | |||
public Tensor random_uniform(Shape shape, | |||
float minval = 0, | |||
float maxval = 1, | |||
TF_DataType dtype = TF_DataType.TF_FLOAT, | |||
@@ -85,7 +85,7 @@ namespace Tensorflow | |||
string name = null) | |||
=> random.uniform(shape, minval: minval, maxval: maxval, dtype: dtype, seed: seed, name: name); | |||
public Tensor truncated_normal(TensorShape shape, | |||
public Tensor truncated_normal(Shape shape, | |||
float mean = 0.0f, | |||
float stddev = 1.0f, | |||
TF_DataType dtype = TF_DataType.TF_FLOAT, | |||
@@ -19,7 +19,7 @@ namespace Tensorflow | |||
public partial class tensorflow | |||
{ | |||
public Tensor reshape(Tensor tensor, | |||
TensorShape shape, | |||
Shape shape, | |||
string name = null) | |||
=> gen_array_ops.reshape(tensor, shape, name); | |||
@@ -47,7 +47,7 @@ namespace Tensorflow | |||
/// <param name="name"></param> | |||
/// <returns>Dense `Tensor` of shape `output_shape`. Has the same type as `sparse_values`.</returns> | |||
public Tensor sparse_to_dense<T>(Tensor sparse_indices, | |||
TensorShape output_shape, | |||
Shape output_shape, | |||
T sparse_values, | |||
T default_value = default, | |||
bool validate_indices = true, | |||
@@ -25,7 +25,7 @@ namespace Tensorflow | |||
public Tensor tile(Tensor input, object[] multiples, string name = null) | |||
=> gen_array_ops.tile(input, multiples, name); | |||
public Tensor tile(Tensor input, TensorShape multiples, string name = null) | |||
public Tensor tile(Tensor input, Shape multiples, string name = null) | |||
{ | |||
var multiples_tensor = constant_op.constant(multiples); | |||
return gen_array_ops.tile(input, multiples_tensor, name); | |||
@@ -168,7 +168,7 @@ namespace Tensorflow | |||
return ndArray.ndim == 0 ? 1 : (int)ndArray.dims[0]; | |||
case IEnumerable enumerable: | |||
return enumerable.OfType<object>().Count(); | |||
case TensorShape arr: | |||
case Shape arr: | |||
return arr.ndim; | |||
} | |||
throw new NotImplementedException("len() not implemented for type: " + a.GetType()); | |||
@@ -532,7 +532,6 @@ namespace Tensorflow | |||
var type = data.GetType(); | |||
switch (data) | |||
{ | |||
case TensorShape: | |||
case Shape: | |||
return TF_DataType.TF_INT64; | |||
case Axis: | |||
@@ -8,12 +8,12 @@ namespace Tensorflow | |||
/// <summary> | |||
/// Alias to null, similar to python's None. | |||
/// For TensorShape, please use Unknown | |||
/// For Shape, please use Unknown | |||
/// </summary> | |||
public static readonly object None = null; | |||
/// <summary> | |||
/// Used for TensorShape None | |||
/// Used for Shape None | |||
/// </summary> | |||
/// | |||
public static readonly int Unknown = -1; | |||
@@ -6,7 +6,7 @@ namespace Tensorflow | |||
{ | |||
public class DatasetManager | |||
{ | |||
public IDatasetV2 from_generator<T>(IEnumerable<T> generator, TF_DataType[] output_types, TensorShape[] output_shapes) | |||
public IDatasetV2 from_generator<T>(IEnumerable<T> generator, TF_DataType[] output_types, Shape[] output_shapes) | |||
=> new GeneratorDataset(); | |||
/// <summary> | |||
@@ -19,7 +19,7 @@ namespace Tensorflow | |||
public TensorSpec[] structure { get; set; } | |||
public TensorShape[] output_shapes => structure.Select(x => x.shape).ToArray(); | |||
public Shape[] output_shapes => structure.Select(x => x.shape).ToArray(); | |||
public TF_DataType[] output_types => structure.Select(x => x.dtype).ToArray(); | |||
@@ -10,7 +10,7 @@ namespace Tensorflow | |||
Tensor variant_tensor { get; set; } | |||
TensorShape[] output_shapes { get; } | |||
Shape[] output_shapes { get; } | |||
TF_DataType[] output_types { get; } | |||
@@ -37,7 +37,7 @@ namespace Tensorflow | |||
{ | |||
var results = ops.iterator_get_next(_iterator_resource, _dataset.output_types, _dataset.output_shapes); | |||
foreach(var (i, tensor) in enumerate(results)) | |||
tensor.set_shape(_element_spec[i].shape); | |||
tensor.shape = _element_spec[i].shape; | |||
return results; | |||
} | |||
catch (OutOfRangeError ex) | |||
@@ -298,7 +298,7 @@ namespace Tensorflow.Eager | |||
c_api.TFE_OpSetAttrStringList(op, key, values3, values3.Select(x => Convert.ToUInt64(x.Length)).ToArray(), values3.Length); | |||
attr_list_sizes[key] = values3.Length; | |||
} | |||
else if (type == TF_AttrType.TF_ATTR_SHAPE && values is TensorShape[] values1) | |||
else if (type == TF_AttrType.TF_ATTR_SHAPE && values is Shape[] values1) | |||
{ | |||
// Make one pass through the input counting the total number of | |||
// dims across all the input lists. | |||
@@ -3,6 +3,6 @@ | |||
public partial class EagerTensor | |||
{ | |||
public override string ToString() | |||
=> $"tf.Tensor: shape={TensorShape}, dtype={dtype.as_numpy_name()}, numpy={tensor_util.to_numpy_string(this)}"; | |||
=> $"tf.Tensor: shape={shape}, dtype={dtype.as_numpy_name()}, numpy={tensor_util.to_numpy_string(this)}"; | |||
} | |||
} |
@@ -17,12 +17,6 @@ namespace Tensorflow.Eager | |||
public override int rank => c_api.TFE_TensorHandleNumDims(EagerTensorHandle, tf.Status.Handle); | |||
public override void set_shape(TensorShape shape) | |||
{ | |||
if (!shape.is_compatible_with(this.shape)) | |||
throw new ValueError($"Tensor's shape is not compatible."); | |||
} | |||
public static int GetRank(IntPtr handle) | |||
{ | |||
var tfe_tensor_handle = c_api.TFE_EagerTensorHandle(handle); | |||
@@ -5,8 +5,8 @@ | |||
/// </summary> | |||
public class DenseSpec : TypeSpec | |||
{ | |||
protected TensorShape _shape; | |||
public TensorShape shape => _shape; | |||
protected Shape _shape; | |||
public Shape shape => _shape; | |||
protected TF_DataType _dtype; | |||
public TF_DataType dtype => _dtype; | |||
@@ -14,7 +14,7 @@ | |||
protected string _name; | |||
public string name => _name; | |||
public DenseSpec(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) | |||
public DenseSpec(Shape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) | |||
{ | |||
_shape = shape; | |||
_dtype = dtype; | |||
@@ -4,7 +4,7 @@ namespace Tensorflow.Framework.Models | |||
{ | |||
public class TensorSpec : DenseSpec | |||
{ | |||
public TensorSpec(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) : | |||
public TensorSpec(Shape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) : | |||
base(shape, dtype, name) | |||
{ | |||
@@ -34,8 +34,8 @@ namespace Tensorflow.Framework | |||
/// <summary> | |||
/// Helper functions for is_broadcast_compatible and broadcast_shape. | |||
/// </summary> | |||
/// <param name="shape_x"> A `TensorShape`</param> | |||
/// <param name="shape_y"> A `TensorShape`</param> | |||
/// <param name="shape_x"> A `Shape`</param> | |||
/// <param name="shape_y"> A `Shape`</param> | |||
/// <return> Returns None if the shapes are not broadcast compatible, | |||
/// a list of the broadcast dimensions otherwise. | |||
/// </return> | |||
@@ -51,7 +51,7 @@ namespace Tensorflow.Framework | |||
public static bool has_fully_defined_shape(Tensor tensor) | |||
{ | |||
return tensor.TensorShape.is_fully_defined(); | |||
return tensor.shape.IsFullyDefined; | |||
} | |||
} | |||
} |
@@ -28,7 +28,7 @@ namespace Tensorflow.Framework | |||
{ | |||
bool _shape_is_compatible_0dim(Shape _this, Shape _other) | |||
{ | |||
var __other = tensor_shape.as_shape(_other); | |||
var __other = _other; | |||
if (_this.dims == null || __other.dims == null) | |||
return true; | |||
@@ -54,9 +54,9 @@ namespace Tensorflow.Framework | |||
!self.IsSparseTensor; | |||
} | |||
public static Dimension dimension_at_index(TensorShape shape, int index) | |||
public static Dimension dimension_at_index(Shape shape, int index) | |||
{ | |||
return shape.rank < 0 ? | |||
return shape.ndim < 0 ? | |||
new Dimension(-1) : | |||
new Dimension(shape.dims[index]); | |||
} | |||
@@ -64,19 +64,16 @@ namespace Tensorflow.Framework | |||
public static int dimension_value(Dimension dimension) | |||
=> (int)dimension.value; | |||
public static TensorShape as_shape(this Shape shape) | |||
=> new TensorShape(shape.dims); | |||
public static TensorShape most_specific_compatible_shape(this TensorShape self, TensorShape other) | |||
public static Shape most_specific_compatible_shape(this Shape self, Shape other) | |||
{ | |||
var dims = range(self.rank).Select(x => -1L).ToArray(); | |||
var dims = range(self.ndim).Select(x => -1L).ToArray(); | |||
foreach(var (i, (d1, d2)) in enumerate(zip(self.dims, other.dims))) | |||
{ | |||
if (d1 == d2) | |||
dims[i] = d1; | |||
} | |||
return new TensorShape(dims); | |||
return new Shape(dims); | |||
} | |||
} | |||
} |
@@ -72,7 +72,7 @@ namespace Tensorflow.Functions | |||
} | |||
/*public ConcreteFunction(Func<Tensors, Tensors> func, | |||
TF_DataType[] dtypes, TensorShape[] shapes) | |||
TF_DataType[] dtypes, Shape[] shapes) | |||
{ | |||
string func_name = $"{func.Method.Name}_{ops.uid_function()}"; | |||
@@ -6,9 +6,9 @@ namespace Tensorflow.Gradients | |||
{ | |||
long id; | |||
TF_DataType dtype; | |||
TensorShape shape; | |||
Shape shape; | |||
public TapeTensor(long id, TF_DataType dtype, TensorShape shape) | |||
public TapeTensor(long id, TF_DataType dtype, Shape shape) | |||
{ | |||
this.id = id; | |||
this.dtype = dtype; | |||
@@ -234,7 +234,7 @@ namespace Tensorflow | |||
in_grad.Tag == null && // maybe a IndexedSlice | |||
t_in.dtype != TF_DataType.TF_RESOURCE) | |||
{ | |||
in_grad.set_shape(t_in.TensorShape); | |||
in_grad.shape = t_in.shape; | |||
} | |||
_SetGrad(grads, t_in, in_grad); | |||
@@ -27,9 +27,9 @@ namespace Tensorflow.Gradients | |||
{ | |||
var grad = grads[0]; | |||
var image = op.inputs[0]; | |||
var shape = new TensorShape(image.shape.dims.Skip(1).Take(2).ToArray()); | |||
var shape = new Shape(image.shape.dims.Skip(1).Take(2).ToArray()); | |||
Tensor image_shape = null; | |||
if (shape.is_fully_defined()) | |||
if (shape.IsFullyDefined) | |||
image_shape = constant_op.constant(image.shape.dims.Skip(1).Take(2).ToArray()); | |||
else | |||
image_shape = array_ops.shape(image)["1:3"]; | |||
@@ -810,8 +810,8 @@ namespace Tensorflow.Gradients | |||
private static (Tensor, Tensor, bool)[] SmartBroadcastGradientArgs(Tensor x, Tensor y, Tensor grad) | |||
{ | |||
Tensor sx, sy; | |||
if (x.TensorShape.is_fully_defined() && | |||
y.TensorShape.is_fully_defined()) | |||
if (x.shape.IsFullyDefined && | |||
y.shape.IsFullyDefined) | |||
{ | |||
sx = array_ops.shape(x); | |||
sy = array_ops.shape(y); | |||
@@ -825,8 +825,8 @@ namespace Tensorflow.Gradients | |||
var (rx, ry) = gen_array_ops.broadcast_gradient_args(sx, sy); | |||
return new[] | |||
{ | |||
(sx, rx, !x.TensorShape.Equals(grad.TensorShape)), | |||
(sy, ry, !y.TensorShape.Equals(grad.TensorShape)) | |||
(sx, rx, !x.shape.Equals(grad.shape)), | |||
(sy, ry, !y.shape.Equals(grad.shape)) | |||
}; | |||
} | |||
} | |||
@@ -17,6 +17,7 @@ | |||
using System; | |||
using System.Linq; | |||
using Tensorflow.Operations; | |||
using static Tensorflow.Binding; | |||
namespace Tensorflow.Gradients | |||
{ | |||
@@ -323,7 +324,7 @@ namespace Tensorflow.Gradients | |||
// Compute linear indices(flattened to 1D). | |||
var cast1 = math_ops.cast(outerdim, TF_DataType.TF_INT64); | |||
var range2 = math_ops.range(0L, cast1 * in_lastdim, in_lastdim); | |||
var range2 = math_ops.range(tf.constant(0L), cast1 * in_lastdim, in_lastdim); | |||
var dim2 = array_ops.expand_dims(range2, -1); | |||
var cast2 = math_ops.cast(dim2, TF_DataType.TF_INT32); | |||
var ind = array_ops.reshape(ind_2d + cast2, new int[] { -1 }); | |||
@@ -56,7 +56,7 @@ namespace Tensorflow | |||
null, | |||
args: new object[] { oper, out_grads }) as Tensor[]; | |||
foreach (var result in results.Where(x => x != null)) | |||
tf.Logger.Debug($"Gradient: {result.name} {result.TensorShape}"); | |||
tf.Logger.Debug($"Gradient: {result.name} {result.shape}"); | |||
return results; | |||
} | |||
); | |||
@@ -44,7 +44,7 @@ namespace Tensorflow.Graphs | |||
if (args.Arguments[0] is Tensors inputs) | |||
{ | |||
originalInputs = inputs; | |||
var new_inputs = inputs.Select(x => tf.placeholder(x.dtype, shape: x.TensorShape, name: "inputs")).ToArray(); | |||
var new_inputs = inputs.Select(x => tf.placeholder(x.dtype, shape: x.shape, name: "inputs")).ToArray(); | |||
args.Arguments[0] = new Tensors(new_inputs); | |||
} | |||
else | |||
@@ -56,7 +56,7 @@ namespace Tensorflow.Graphs | |||
if (args.Arguments[i] is EagerTensor tensor) | |||
{ | |||
originalInputs.Add(tensor); | |||
args.Arguments[i] = tf.placeholder(tensor.dtype, shape: tensor.TensorShape, name: "inputs"); | |||
args.Arguments[i] = tf.placeholder(tensor.dtype, shape: tensor.shape, name: "inputs"); | |||
} | |||
} | |||
} | |||
@@ -103,7 +103,7 @@ namespace Tensorflow.Graphs | |||
} | |||
const int _EAGER_CONST_THRESHOLD = 128; | |||
public Tensor capture(Tensor tensor, string name = null, TensorShape shape = null) | |||
public Tensor capture(Tensor tensor, string name = null, Shape shape = null) | |||
{ | |||
if(tensor is EagerTensor) | |||
{ | |||
@@ -167,7 +167,7 @@ namespace Tensorflow.Graphs | |||
return graph_const; | |||
} | |||
Tensor _capture_helper(Tensor tensor, string name, TensorShape shape = null) | |||
Tensor _capture_helper(Tensor tensor, string name, Shape shape = null) | |||
{ | |||
Tensor placeholder = null; | |||
if (!_captures.ContainsKey(tensor.Id)) | |||
@@ -206,7 +206,7 @@ namespace Tensorflow.Graphs | |||
Tensor _create_substitute_placeholder(Tensor value, | |||
string name = null, | |||
TF_DataType dtype = TF_DataType.DtInvalid, | |||
TensorShape shape = null) | |||
Shape shape = null) | |||
{ | |||
if (shape is null) | |||
shape = value.shape; | |||
@@ -515,20 +515,20 @@ namespace Tensorflow | |||
return (Tensor)this.as_graph_element(name, allow_tensor: true, allow_operation: false); | |||
} | |||
public TensorShape GetTensorShape(TF_Output output) | |||
public Shape GetTensorShape(TF_Output output) | |||
{ | |||
var status = tf.Status; | |||
var ndim = c_api.TF_GraphGetTensorNumDims(_handle, output, status.Handle); | |||
status.Check(); | |||
if (ndim == -1) | |||
return new TensorShape(); | |||
return Shape.Null; | |||
var dims = new long[ndim]; | |||
c_api.TF_GraphGetTensorShape(_handle, output, dims, dims.Length, status.Handle); | |||
status.Check(); | |||
return new TensorShape(dims.Select(x => (int)x).ToArray()); | |||
return new Shape(dims.Select(x => (int)x).ToArray()); | |||
} | |||
public virtual void Exit() | |||
@@ -8,16 +8,16 @@ namespace Tensorflow.Keras.ArgsDefinition | |||
public int Rank { get; set; } = 2; | |||
public int Filters { get; set; } | |||
public int NumSpatialDims { get; set; } = Unknown; | |||
public TensorShape KernelSize { get; set; } = 5; | |||
public Shape KernelSize { get; set; } = 5; | |||
/// <summary> | |||
/// specifying the stride length of the convolution. | |||
/// </summary> | |||
public TensorShape Strides { get; set; } = (1, 1); | |||
public Shape Strides { get; set; } = (1, 1); | |||
public string Padding { get; set; } = "valid"; | |||
public string DataFormat { get; set; } | |||
public TensorShape DilationRate { get; set; } = (1, 1); | |||
public Shape DilationRate { get; set; } = (1, 1); | |||
public int Groups { get; set; } = 1; | |||
public Activation Activation { get; set; } | |||
public bool UseBias { get; set; } | |||
@@ -25,12 +25,12 @@ | |||
/// <summary> | |||
/// Only applicable to input layers. | |||
/// </summary> | |||
public TensorShape InputShape { get; set; } | |||
public Shape InputShape { get; set; } | |||
/// <summary> | |||
/// Only applicable to input layers. | |||
/// </summary> | |||
public TensorShape BatchInputShape { get; set; } | |||
public Shape BatchInputShape { get; set; } | |||
public int BatchSize { get; set; } = -1; | |||
@@ -4,7 +4,7 @@ namespace Tensorflow.Keras.ArgsDefinition | |||
{ | |||
public class BatchNormalizationArgs : LayerArgs | |||
{ | |||
public TensorShape Axis { get; set; } = -1; | |||
public Shape Axis { get; set; } = -1; | |||
public float Momentum { get; set; } = 0.99f; | |||
public float Epsilon { get; set; } = 1e-3f; | |||
public bool Center { get; set; } = true; | |||
@@ -10,12 +10,12 @@ | |||
/// <summary> | |||
/// specifying the size of the pooling window. | |||
/// </summary> | |||
public TensorShape PoolSize { get; set; } | |||
public Shape PoolSize { get; set; } | |||
/// <summary> | |||
/// specifying the strides of the pooling operation. | |||
/// </summary> | |||
public TensorShape Strides { get; set; } | |||
public Shape Strides { get; set; } | |||
/// <summary> | |||
/// The padding method, either 'valid' or 'same'. | |||
@@ -11,7 +11,7 @@ | |||
/// 1D integer tensor representing the shape of the | |||
/// binary dropout mask that will be multiplied with the input. | |||
/// </summary> | |||
public TensorShape NoiseShape { get; set; } | |||
public Shape NoiseShape { get; set; } | |||
/// <summary> | |||
/// random seed. | |||
@@ -2,7 +2,7 @@ | |||
{ | |||
public class ReshapeArgs : LayerArgs | |||
{ | |||
public TensorShape TargetShape { get; set; } | |||
public Shape TargetShape { get; set; } | |||
public object[] TargetShapeObjects { get; set; } | |||
} | |||
} |
@@ -2,7 +2,7 @@ | |||
{ | |||
public class UpSampling2DArgs : LayerArgs | |||
{ | |||
public TensorShape Size { get; set; } | |||
public Shape Size { get; set; } | |||
public string DataFormat { get; set; } | |||
/// <summary> | |||
/// 'nearest', 'bilinear' | |||
@@ -27,14 +27,14 @@ namespace Tensorflow.Keras.Engine | |||
public int? ndim; | |||
public int? min_ndim; | |||
Dictionary<int, int> axes; | |||
TensorShape shape; | |||
Shape shape; | |||
public int[] AllAxisDim; | |||
public InputSpec(TF_DataType dtype = TF_DataType.DtInvalid, | |||
int? ndim = null, | |||
int? min_ndim = null, | |||
Dictionary<int, int> axes = null, | |||
TensorShape shape = null) | |||
Shape shape = null) | |||
{ | |||
this.ndim = ndim; | |||
if (axes == null) | |||
@@ -16,8 +16,8 @@ namespace Tensorflow.Keras | |||
List<IVariableV1> trainable_variables { get; } | |||
List<IVariableV1> trainable_weights { get; } | |||
List<IVariableV1> non_trainable_weights { get; } | |||
TensorShape output_shape { get; } | |||
TensorShape BatchInputShape { get; } | |||
Shape output_shape { get; } | |||
Shape BatchInputShape { get; } | |||
TF_DataType DType { get; } | |||
int count_params(); | |||
LayerArgs get_config(); | |||
@@ -28,7 +28,7 @@ namespace Tensorflow.NumPy | |||
diag_len = N + k; | |||
} | |||
var diagonal_ = array_ops.ones(new TensorShape(diag_len), dtype: dtype); | |||
var diagonal_ = array_ops.ones(new Shape(diag_len), dtype: dtype); | |||
var tensor = array_ops.matrix_diag(diagonal: diagonal_, num_rows: N, num_cols: M.Value, k: k); | |||
return new NDArray(tensor); | |||
} | |||
@@ -38,13 +38,13 @@ namespace Tensorflow.NumPy | |||
{ | |||
var start_tensor = array_ops.constant(start, dtype: dtype); | |||
var stop_tensor = array_ops.constant(stop, dtype: dtype); | |||
var num_tensor = array_ops.constant(num); | |||
// var step_tensor = array_ops.constant(np.nan); | |||
Tensor result = null; | |||
if (endpoint) | |||
{ | |||
result = math_ops.linspace(start_tensor, stop_tensor, num_tensor, axis: axis); | |||
result = math_ops.linspace(start_tensor, stop_tensor, num, axis: axis); | |||
} | |||
else | |||
{ | |||
@@ -53,10 +53,10 @@ namespace Tensorflow.NumPy | |||
var step = (stop_tensor - start_tensor) / num; | |||
var new_stop = math_ops.cast(stop_tensor, step.dtype) - step; | |||
start_tensor = math_ops.cast(start_tensor, new_stop.dtype); | |||
result = math_ops.linspace(start_tensor, new_stop, num_tensor, axis: axis); | |||
result = math_ops.linspace(start_tensor, new_stop, num, axis: axis); | |||
} | |||
else | |||
result = math_ops.linspace(start_tensor, stop_tensor, num_tensor, axis: axis); | |||
result = math_ops.linspace(start_tensor, stop_tensor, num, axis: axis); | |||
} | |||
return new NDArray(result); | |||
@@ -7,16 +7,27 @@ namespace Tensorflow | |||
{ | |||
public class Shape | |||
{ | |||
public int ndim => _dims.Length; | |||
public int ndim => _dims == null ? -1 : _dims.Length; | |||
long[] _dims; | |||
public long[] dims => _dims; | |||
public Shape() | |||
private Shape() | |||
{ | |||
} | |||
public Shape(TensorShapeProto proto) | |||
{ | |||
_dims = proto.Dim.Select(x => x.Size).ToArray(); | |||
} | |||
public void Deconstruct(out long h, out long w) | |||
{ | |||
h = dims[0]; | |||
w = dims[1]; | |||
} | |||
public Shape(params int[] dims) | |||
=> _dims = dims.Select(x => Convert.ToInt64(x)).ToArray(); | |||
=> _dims = dims?.Select(x => Convert.ToInt64(x))?.ToArray(); | |||
public Shape(params long[] dims) | |||
=> _dims = dims; | |||
@@ -25,10 +36,10 @@ namespace Tensorflow | |||
=> new Shape(dims); | |||
public static implicit operator Shape(long[] dims) | |||
=> new Shape(dims); | |||
=> dims == null ? null : new Shape(dims); | |||
public static implicit operator Shape(int[] dims) | |||
=> new Shape(dims); | |||
=> dims == null ? null : new Shape(dims); | |||
public static implicit operator Shape((int, int) dims) | |||
=> new Shape(dims.Item1, dims.Item2); | |||
@@ -57,16 +68,39 @@ namespace Tensorflow | |||
public bool IsEmpty => size == 0; | |||
public bool IsScalar => ndim == 0; | |||
public bool IsNull => _dims == null; | |||
public bool IsFullyDefined => ndim > -1 && dims.Count(x => x < 1) == 0; | |||
public static Shape Scalar => new Shape(new long[0]); | |||
public static Shape Null => new Shape(); | |||
public long this[int n] | |||
{ | |||
get => dims[n]; | |||
set => dims[n] = value; | |||
} | |||
public Shape this[Slice slice] | |||
{ | |||
get | |||
{ | |||
if (!slice.Stop.HasValue) | |||
slice.Stop = dims.Length - slice.Start + 1; | |||
public static Shape Scalar | |||
=> new Shape(new long[0]); | |||
if (slice.Start.HasValue == false || slice.Length.HasValue == false) | |||
throw new ArgumentException("Slice must has Start and Length."); | |||
public long this[int n] => dims[n]; | |||
return new Shape(dims.Skip(slice.Start.Value) | |||
.Take(slice.Length.Value) | |||
.ToArray()); | |||
} | |||
} | |||
/// <summary> | |||
/// Returns the size this shape represents. | |||
/// </summary> | |||
public ulong size | |||
public long size | |||
{ | |||
get | |||
{ | |||
@@ -85,44 +119,133 @@ namespace Tensorflow | |||
computed *= val; | |||
} | |||
return (ulong)computed; | |||
return computed; | |||
} | |||
} | |||
public bool is_fully_defined() | |||
{ | |||
return ndim > -1 && dims != null && dims.Count(x => x < 1) == 0; | |||
} | |||
public bool is_compatible_with(TensorShape shape2) | |||
public bool is_compatible_with(Shape shape2) | |||
{ | |||
if (dims != null && shape2.dims != null) | |||
{ | |||
if (dims.Contains(-1) || shape2.dims.Contains(-1)) | |||
return true; | |||
if (size != (ulong)shape2.size) | |||
if (size != shape2.size) | |||
return false; | |||
} | |||
return true; | |||
} | |||
public Shape with_rank_at_least(int rank) | |||
{ | |||
if (ndim < rank) | |||
throw new ValueError($"Shape {this} must have rank at least {rank}"); | |||
else | |||
return this; | |||
} | |||
public Shape with_rank(int rank) | |||
{ | |||
return merge_with(unknown_shape(rank: rank)); | |||
} | |||
/// <summary> | |||
/// Returns an unknown Shape, optionally with a known rank. | |||
/// </summary> | |||
/// <param name="rank"></param> | |||
/// <returns></returns> | |||
public Shape unknown_shape(int rank = -1) | |||
{ | |||
if (rank == -1) | |||
return Shape.Null; | |||
else | |||
return new Shape(Enumerable.Repeat(-1L, rank).ToArray()); | |||
} | |||
public Shape concatenate(long[] other) | |||
{ | |||
return concatenate(new Shape(other)); | |||
} | |||
/// <summary> | |||
/// Returns the concatenation of the dimension in `self` and `other`. | |||
/// </summary> | |||
/// <param name="other"></param> | |||
/// <returns></returns> | |||
public Shape concatenate(Shape other) | |||
{ | |||
var otherShape = other; | |||
if (ndim < 0 || otherShape.ndim < 0) | |||
return Shape.Null; | |||
else | |||
{ | |||
var concatenate_dims = new long[ndim + otherShape.ndim]; | |||
for (int i = 0; i < ndim; i++) | |||
concatenate_dims[i] = dims[i]; | |||
for (int i = 0; i < otherShape.ndim; i++) | |||
concatenate_dims[ndim + i] = otherShape.dims[i]; | |||
return new Shape(concatenate_dims); | |||
} | |||
} | |||
/// <summary> | |||
/// Returns a `Shape` combining the information in `self` and `other`. | |||
/// </summary> | |||
/// <param name="other"></param> | |||
/// <returns></returns> | |||
public Shape merge_with(Shape other) | |||
{ | |||
if (dims == null) | |||
return other; | |||
var new_dims = new List<long>(); | |||
foreach (var i in Enumerable.Range(0, ndim)) | |||
{ | |||
var dim = new Dimension(dims[i]); | |||
var merged = dim.merge_with(new Dimension(other.dims[i])); | |||
new_dims.Add(merged.value); | |||
} | |||
return new Shape(new_dims.ToArray()); | |||
} | |||
public void assert_has_rank(int rank) | |||
{ | |||
if (rank != ndim) | |||
throw new ValueError(String.Format("Shape {0} must have rank {1}", ndim, rank)); | |||
} | |||
public override bool Equals(object obj) | |||
{ | |||
if(obj is Shape shape) | |||
switch (obj) | |||
{ | |||
if (shape.ndim != ndim) | |||
case Shape shape1: | |||
if (ndim == -1 && shape1.ndim == -1) | |||
return false; | |||
else if (ndim != shape1.ndim) | |||
return false; | |||
return Enumerable.SequenceEqual(shape1.dims, dims); | |||
case long[] shape2: | |||
if (ndim != shape2.Length) | |||
return false; | |||
return Enumerable.SequenceEqual(dims, shape2); | |||
default: | |||
return false; | |||
if (Enumerable.SequenceEqual(dims, shape.dims)) | |||
return true; | |||
} | |||
return base.Equals(obj); | |||
} | |||
public override string ToString() | |||
{ | |||
return "(" + string.Join(", ", _dims) + ")"; | |||
} | |||
=> ndim switch | |||
{ | |||
-1 => "<unknown>", | |||
0 => "()", | |||
1 => $"({dims[0]},)", | |||
_ => $"{string.Join(", ", _dims).Replace("-1", "None")}" | |||
}; | |||
} | |||
} |
@@ -261,7 +261,7 @@ namespace Tensorflow.Operations.ControlFlows | |||
public Tensor ZerosLikeForExit(Tensor val) | |||
{ | |||
Tensor result = null; | |||
var val_shape = val.TensorShape; | |||
var val_shape = val.shape; | |||
var forward_ctxt = val.op._get_control_flow_context(); | |||
var outer_forward_ctxt = forward_ctxt.outer_context; | |||
if (outer_forward_ctxt != null) | |||
@@ -278,7 +278,7 @@ namespace Tensorflow.Operations.ControlFlows | |||
{ | |||
// If the shape is known statically, just create a zero tensor | |||
// with the right shape. | |||
if (val_shape.is_fully_defined()) | |||
if (val_shape.IsFullyDefined) | |||
result = array_ops.zeros(val_shape.dims, val.dtype); | |||
else | |||
result = array_ops.zeros_like(val, optimize: false); | |||
@@ -299,8 +299,8 @@ namespace Tensorflow.Operations.ControlFlows | |||
// depend on its value at iteration i. So use zeros as the | |||
// gradients for all iterations > 0. | |||
var dtype = b_merge.op.inputs[0].dtype; | |||
var shape = b_merge.op.inputs[0].TensorShape; | |||
if (shape.is_fully_defined()) | |||
var shape = b_merge.op.inputs[0].shape; | |||
if (shape.IsFullyDefined) | |||
{ | |||
grad_state.grad_context.Enter(); | |||
// Create a zeros and use it for iterations > 0. | |||
@@ -258,7 +258,7 @@ namespace Tensorflow.Operations.ControlFlows | |||
throw new NotImplementedException("AddBackpropAccumulatedValue"); | |||
} | |||
pop = gen_data_flow_ops.stack_pop_v2(history_value, value.dtype.as_base_dtype()); | |||
pop.set_shape(value.TensorShape); | |||
pop.shape = value.shape; | |||
grad_context.Exit(); | |||
}); | |||
var parallel_iterations = grad_context.parallel_iterations; | |||
@@ -117,7 +117,7 @@ namespace Tensorflow.Operations | |||
internal LoopVar<TItem> BuildLoop<TItem>(Func<LoopVar<TItem>, Tensor> pred, | |||
Func<LoopVar<TItem>, LoopVar<TItem>> body, | |||
LoopVar<TItem> loop_vars, | |||
TensorShape[] shape_invariants, | |||
Shape[] shape_invariants, | |||
bool return_same_structure) where TItem : IFromMergeVars<TItem>, new() | |||
{ | |||
// Keep original_loop_vars to identify which are TensorArrays | |||
@@ -159,9 +159,9 @@ namespace Tensorflow.Operations | |||
throw new NotImplementedException("_convert_tensorarray_to_flow"); | |||
} | |||
private TensorShape _get_shape_invariant(Tensor var, int[] shape = null) | |||
private Shape _get_shape_invariant(Tensor var, int[] shape = null) | |||
{ | |||
return var.TensorShape; | |||
return var.shape; | |||
} | |||
/// <summary> | |||
@@ -178,7 +178,7 @@ namespace Tensorflow.Operations | |||
Func<LoopVar<TItem>, LoopVar<TItem>> body, | |||
LoopVar<TItem> original_loop_vars, | |||
Tensor[] loop_vars, | |||
TensorShape[] shape_invariants) where TItem : IFromMergeVars<TItem>, new() | |||
Shape[] shape_invariants) where TItem : IFromMergeVars<TItem>, new() | |||
{ | |||
var flat_loop_vars = nest.flatten2(original_loop_vars) | |||
.Select(x => (ITensorOrTensorArray)x) | |||
@@ -459,8 +459,8 @@ namespace Tensorflow.Operations | |||
// dynamically from the forward inference. Getting the shape right | |||
// for the zeros is only needed for the base case when the loop exits | |||
// without running any iterations. | |||
var shape = grad.TensorShape; | |||
if (shape.is_fully_defined()) | |||
var shape = grad.shape; | |||
if (shape.IsFullyDefined) | |||
{ | |||
if (outer_context != null) | |||
outer_context.Enter(); | |||
@@ -3,11 +3,11 @@ | |||
public class InitializerArgs | |||
{ | |||
public string Name { get; set; } | |||
public TensorShape Shape { get; set; } | |||
public Shape Shape { get; set; } | |||
public TF_DataType DType { get; set; } | |||
public bool VerifyShape { get; set; } | |||
public InitializerArgs(TensorShape shape, | |||
public InitializerArgs(Shape shape, | |||
TF_DataType dtype = TF_DataType.DtInvalid, | |||
bool verify_shape = false, | |||
string name = null) | |||
@@ -18,10 +18,10 @@ namespace Tensorflow.Operations.Initializers | |||
{ | |||
public class Zeros : IInitializer | |||
{ | |||
TensorShape shape; | |||
Shape shape; | |||
TF_DataType dtype; | |||
public Zeros(TensorShape shape = null, TF_DataType dtype = TF_DataType.TF_FLOAT) | |||
public Zeros(Shape shape = null, TF_DataType dtype = TF_DataType.TF_FLOAT) | |||
{ | |||
this.shape = shape; | |||
this.dtype = dtype; | |||
@@ -135,8 +135,8 @@ namespace Tensorflow | |||
if (weights > 0) | |||
{ | |||
var weights_tensor = ops.convert_to_tensor(weights); | |||
var labels_rank = labels.TensorShape.ndim; | |||
var weights_shape = weights_tensor.TensorShape; | |||
var labels_rank = labels.shape.ndim; | |||
var weights_shape = weights_tensor.shape; | |||
var weights_rank = weights_shape.ndim; | |||
if (labels_rank > -1 && weights_rank > -1) | |||
@@ -46,7 +46,7 @@ namespace Tensorflow | |||
_activation = tf.nn.tanh(); | |||
} | |||
protected override void build(TensorShape input_shape) | |||
protected override void build(Shape input_shape) | |||
{ | |||
var input_depth = input_shape.dims.Last(); | |||
var h_depth = _num_units; | |||
@@ -50,7 +50,7 @@ namespace Tensorflow | |||
_activation = activation; | |||
} | |||
protected override void build(TensorShape inputs_shape) | |||
protected override void build(Shape inputs_shape) | |||
{ | |||
var input_depth = inputs_shape.dims[inputs_shape.ndim - 1]; | |||
@@ -38,8 +38,8 @@ namespace Tensorflow.Operations | |||
public Tensor Apply(Tensors input, IVariableV1 filters) | |||
{ | |||
var filters_rank = filters.shape.rank; | |||
var inputs_rank = input.shape.rank; | |||
var filters_rank = filters.shape.ndim; | |||
var inputs_rank = input.shape.ndim; | |||
var num_spatial_dims = args.NumSpatialDims; | |||
if (args.Rank == 1) | |||
{ | |||
@@ -49,7 +49,7 @@ namespace Tensorflow | |||
_keras_style = false; | |||
} | |||
protected virtual void build(TensorShape inputs_shape) | |||
protected virtual void build(Shape inputs_shape) | |||
{ | |||
} | |||
@@ -42,7 +42,7 @@ namespace Tensorflow | |||
/// This operation results in an output matrix with `self.output_size` columns. | |||
/// If `self.state_size` is an integer, this operation also results in a new | |||
/// state matrix with `self.state_size` columns. If `self.state_size` is a | |||
/// (possibly nested tuple of) TensorShape object(s), then it should return a | |||
/// (possibly nested tuple of) Shape object(s), then it should return a | |||
/// matching structure of Tensors having shape `[batch_size].concatenate(s)` | |||
/// for each `s` in `self.batch_size`. | |||
/// </summary> | |||
@@ -70,9 +70,9 @@ namespace Tensorflow | |||
public List<IVariableV1> trainable_weights => throw new NotImplementedException(); | |||
public List<IVariableV1> non_trainable_weights => throw new NotImplementedException(); | |||
public TensorShape output_shape => throw new NotImplementedException(); | |||
public Shape output_shape => throw new NotImplementedException(); | |||
public TensorShape BatchInputShape => throw new NotImplementedException(); | |||
public Shape BatchInputShape => throw new NotImplementedException(); | |||
public TF_DataType DType => throw new NotImplementedException(); | |||
protected bool built = false; | |||
@@ -118,14 +118,14 @@ namespace Tensorflow.Operations | |||
VariableScope varscope = scope1; | |||
// Obtain the first sequence of the input | |||
var first_input = inputs[0]; | |||
if (first_input.TensorShape.rank != 1) | |||
if (first_input.shape.ndim != 1) | |||
{ | |||
var input_shape = first_input.TensorShape.with_rank_at_least(2); | |||
var input_shape = first_input.shape.with_rank_at_least(2); | |||
fixed_batch_size = input_shape.dims[0]; | |||
var flat_inputs = nest.flatten2(inputs); | |||
foreach (var flat_input in flat_inputs) | |||
{ | |||
input_shape = flat_input.TensorShape.with_rank_at_least(2); | |||
input_shape = flat_input.shape.with_rank_at_least(2); | |||
batch_size = tensor_shape.dimension_at_index(input_shape, 0); | |||
var input_size = input_shape[new Slice(1)]; | |||
fixed_batch_size.merge_with(batch_size); | |||
@@ -138,7 +138,7 @@ namespace Tensorflow.Operations | |||
} | |||
} | |||
else | |||
fixed_batch_size = first_input.TensorShape.with_rank_at_least(1).dims[0]; | |||
fixed_batch_size = first_input.shape.with_rank_at_least(1).dims[0]; | |||
if (tensor_shape.dimension_value(fixed_batch_size) >= 0) | |||
batch_size = tensor_shape.dimension_value(fixed_batch_size); | |||
@@ -243,7 +243,7 @@ namespace Tensorflow.Operations | |||
var input_shape = array_ops.shape(flat_input[0]); | |||
var time_steps = input_shape.slice(0); | |||
var batch_size = _best_effort_input_batch_size(flat_input); | |||
var inputs_got_shape = flat_input.Select(input_ => input_.TensorShape.with_rank_at_least(3)).ToArray(); | |||
var inputs_got_shape = flat_input.Select(input_ => input_.shape.with_rank_at_least(3)).ToArray(); | |||
var dims = inputs_got_shape[0].dims.Take(2).ToArray(); | |||
var (const_time_steps, const_batch_size) = (dims[0], dims[1]); | |||
@@ -292,7 +292,7 @@ namespace Tensorflow.Operations | |||
string base_name = null; | |||
tf_with(ops.name_scope("dynamic_rnn"), scope => base_name = scope); | |||
Func<string, TensorShape, TF_DataType, TensorArray> _create_ta = (name, element_shape, dtype_) => | |||
Func<string, Shape, TF_DataType, TensorArray> _create_ta = (name, element_shape, dtype_) => | |||
{ | |||
var ta = new TensorArray(dtype: dtype_, | |||
size: time_steps, | |||
@@ -309,7 +309,7 @@ namespace Tensorflow.Operations | |||
foreach (var (i, out_size) in enumerate(flat_output_size)) | |||
{ | |||
output_ta.Add(_create_ta($"output_{i}", | |||
new TensorShape(const_batch_size).concatenate( | |||
new Shape(const_batch_size).concatenate( | |||
_maybe_tensor_shape_from_tensor(out_size)), | |||
_infer_state_dtype(dtype, state))); | |||
} | |||
@@ -317,7 +317,7 @@ namespace Tensorflow.Operations | |||
foreach (var (i, flat_input_i) in enumerate(flat_input)) | |||
{ | |||
input_ta.Add(_create_ta($"input_{i}", | |||
new TensorShape(flat_input_i.dims.Skip(1).ToArray()), | |||
new Shape(flat_input_i.dims.Skip(1).ToArray()), | |||
flat_input_i.dtype)); | |||
} | |||
@@ -350,7 +350,7 @@ namespace Tensorflow.Operations | |||
input_t = input_ta.Select(ta => ta.read(time1)).ToArray(); | |||
// Restore some shape information | |||
foreach (var (input_, shape) in zip(input_t, inputs_got_shape)) | |||
input_.set_shape(shape[new Slice(1)]); | |||
input_.shape = shape[new Slice(1)]; | |||
} | |||
else | |||
{ | |||
@@ -397,17 +397,17 @@ namespace Tensorflow.Operations | |||
foreach (var (output, output_size) in zip(final_outputs, flat_output_size)) | |||
{ | |||
var shape = rnn_cell_impl._concat(new int[] { (int)const_time_steps, (int)const_batch_size }, output_size, @static: true); | |||
output.set_shape(shape); | |||
output.shape = shape; | |||
} | |||
return (final_outputs[0], final_state); | |||
} | |||
private static TensorShape _maybe_tensor_shape_from_tensor(Tensor shape) | |||
=> shape.TensorShape; | |||
private static Shape _maybe_tensor_shape_from_tensor(Tensor shape) | |||
=> shape.shape; | |||
private static TensorShape _maybe_tensor_shape_from_tensor(int shape) | |||
=> new TensorShape(shape); | |||
private static Shape _maybe_tensor_shape_from_tensor(int shape) | |||
=> new Shape(shape); | |||
private static TF_DataType _infer_state_dtype(TF_DataType explicit_dtype, Tensor state) | |||
{ | |||
@@ -424,7 +424,7 @@ namespace Tensorflow.Operations | |||
/// <returns></returns> | |||
public static Tensor _transpose_batch_time(Tensor x) | |||
{ | |||
var x_static_shape = x.TensorShape; | |||
var x_static_shape = x.shape; | |||
if (x_static_shape.ndim == 1) | |||
return x; | |||
@@ -436,12 +436,12 @@ namespace Tensorflow.Operations | |||
}; | |||
var x_t = array_ops.transpose(x, array_ops.concat(con1, 0)); | |||
var dims = new [] { x_static_shape.dims[1], x_static_shape.dims[0] } | |||
var dims = new long[] { x_static_shape.dims[1], x_static_shape.dims[0] } | |||
.ToList(); | |||
dims.AddRange(x_static_shape.dims.Skip(2)); | |||
var shape = new TensorShape(dims.ToArray()); | |||
var shape = new Shape(dims.ToArray()); | |||
x_t.set_shape(shape); | |||
x_t.shape = shape; | |||
return x_t; | |||
} | |||
@@ -455,7 +455,7 @@ namespace Tensorflow.Operations | |||
{ | |||
foreach (var input_ in flat_input) | |||
{ | |||
var shape = input_.TensorShape; | |||
var shape = input_.shape; | |||
if (shape.ndim < 0) | |||
continue; | |||
if (shape.ndim < 2) | |||
@@ -32,18 +32,18 @@ namespace Tensorflow.Operations | |||
else if (p.ndim != 1) | |||
throw new ValueError($"prefix tensor must be either a scalar or vector, but saw tensor: {p}"); | |||
var s_tensor_shape = new TensorShape(suffix); | |||
var s_tensor_shape = new Shape(suffix); | |||
var s_static = s_tensor_shape.ndim > -1 ? | |||
s_tensor_shape.dims : | |||
null; | |||
var s = s_tensor_shape.is_fully_defined() ? | |||
var s = s_tensor_shape.IsFullyDefined ? | |||
constant_op.constant(s_tensor_shape.dims, dtype: dtypes.int32) : | |||
null; | |||
if (@static) | |||
{ | |||
if (p_static is null) return null; | |||
var shape = new TensorShape(p_static).concatenate(s_static); | |||
var shape = new Shape(p_static).concatenate(s_static); | |||
throw new NotImplementedException("RNNCell _concat"); | |||
} | |||
else | |||
@@ -54,24 +54,24 @@ namespace Tensorflow.Operations | |||
} | |||
} | |||
public static TensorShape _concat(int[] prefix, int suffix, bool @static = false) | |||
public static Shape _concat(int[] prefix, int suffix, bool @static = false) | |||
{ | |||
var p = new TensorShape(prefix); | |||
var p = new Shape(prefix); | |||
var p_static = prefix; | |||
var p_tensor = p.is_fully_defined() ? constant_op.constant(p.as_list(), dtype: dtypes.int32) : null; | |||
var p_tensor = p.IsFullyDefined ? constant_op.constant(p, dtype: dtypes.int32) : null; | |||
var s_tensor_shape = new TensorShape(suffix); | |||
var s_tensor_shape = new Shape(suffix); | |||
var s_static = s_tensor_shape.ndim > -1 ? | |||
s_tensor_shape.dims : | |||
null; | |||
var s_tensor = s_tensor_shape.is_fully_defined() ? | |||
var s_tensor = s_tensor_shape.IsFullyDefined ? | |||
constant_op.constant(s_tensor_shape.dims, dtype: dtypes.int32) : | |||
null; | |||
if (@static) | |||
{ | |||
if (p_static is null) return null; | |||
var shape = new TensorShape(p_static).concatenate(s_static); | |||
var shape = new Shape(p_static).concatenate(s_static); | |||
return shape; | |||
} | |||
else | |||
@@ -345,7 +345,7 @@ namespace Tensorflow | |||
return ByteString.CopyFromUtf8(value ?? string.Empty); | |||
} | |||
public TensorShapeProto _MakeShape(TensorShape shape, AttrDef attr_def) | |||
public TensorShapeProto _MakeShape(Shape shape, AttrDef attr_def) | |||
{ | |||
return shape.as_proto(); | |||
} | |||
@@ -400,7 +400,7 @@ namespace Tensorflow | |||
if (value == null && attr_def.DefaultValue != null) | |||
attr_value.Shape = attr_def.DefaultValue.Shape; | |||
if (value is TensorShape val1) | |||
if (value is Shape val1) | |||
attr_value.Shape = val1.as_proto(); | |||
else if (value is long[] val2) | |||
attr_value.Shape = tensor_util.as_shape(val2); | |||
@@ -409,7 +409,7 @@ namespace Tensorflow | |||
break; | |||
case "list(shape)": | |||
attr_value.List.Shape.AddRange((value as TensorShape[]).Select(x => _MakeShape(x, attr_def))); | |||
attr_value.List.Shape.AddRange((value as Shape[]).Select(x => _MakeShape(x, attr_def))); | |||
break; | |||
default: | |||
throw new TypeError($"SetAttrValue: can't not convert attr_def.Type '{attr_def.Type}' to protos."); | |||
@@ -22,7 +22,7 @@ namespace Tensorflow.Queues | |||
{ | |||
public FIFOQueue(int capacity, | |||
TF_DataType[] dtypes, | |||
TensorShape[] shapes, | |||
Shape[] shapes, | |||
string[] names = null, | |||
string shared_name = null, | |||
string name = "fifo_queue") | |||
@@ -25,7 +25,7 @@ namespace Tensorflow.Queues | |||
{ | |||
public PaddingFIFOQueue(int capacity, | |||
TF_DataType[] dtypes, | |||
TensorShape[] shapes, | |||
Shape[] shapes, | |||
string[] names = null, | |||
string shared_name = null, | |||
string name = "padding_fifo_queue") | |||
@@ -24,7 +24,7 @@ namespace Tensorflow.Queues | |||
{ | |||
public PriorityQueue(int capacity, | |||
TF_DataType[] dtypes, | |||
TensorShape[] shapes, | |||
Shape[] shapes, | |||
string[] names = null, | |||
string shared_name = null, | |||
string name = "priority_queue") | |||
@@ -44,7 +44,7 @@ namespace Tensorflow.Queues | |||
_dtypes = dtypes1.ToArray(); | |||
var shapes1 = shapes.ToList(); | |||
shapes1.Insert(0, new TensorShape()); | |||
shapes1.Insert(0, Shape.Null); | |||
_shapes = shapes1.ToArray(); | |||
} | |||
@@ -23,12 +23,12 @@ namespace Tensorflow.Queues | |||
public class QueueBase | |||
{ | |||
protected TF_DataType[] _dtypes; | |||
protected TensorShape[] _shapes; | |||
protected Shape[] _shapes; | |||
protected string[] _names; | |||
protected Tensor _queue_ref; | |||
protected string _name; | |||
public QueueBase(TF_DataType[] dtypes, TensorShape[] shapes, string[] names) | |||
public QueueBase(TF_DataType[] dtypes, Shape[] shapes, string[] names) | |||
{ | |||
_dtypes = dtypes; | |||
_shapes = shapes; | |||
@@ -26,7 +26,7 @@ namespace Tensorflow.Queues | |||
public RandomShuffleQueue(int capacity, | |||
int min_after_dequeue, | |||
TF_DataType[] dtypes, | |||
TensorShape[] shapes, | |||
Shape[] shapes, | |||
string[] names = null, | |||
int? seed = null, | |||
string shared_name = null, | |||
@@ -37,7 +37,7 @@ namespace Tensorflow.Operations | |||
bool _infer_shape; | |||
public bool infer_shape => _infer_shape; | |||
public bool _dynamic_size; | |||
public List<TensorShape> _element_shape; | |||
public List<Shape> _element_shape; | |||
public List<Tensor> _colocate_with; | |||
@@ -47,7 +47,7 @@ namespace Tensorflow.Operations | |||
public _GraphTensorArray(TF_DataType dtype, Tensor size, bool? dynamic_size = null, | |||
bool? clear_after_read = null, string tensor_array_name = null, Tensor handle = null, Tensor flow = null, | |||
bool infer_shape = true, TensorShape element_shape = null, | |||
bool infer_shape = true, Shape element_shape = null, | |||
bool colocate_with_first_write_call = true, string name = null) | |||
{ | |||
clear_after_read = clear_after_read ?? true; | |||
@@ -66,12 +66,12 @@ namespace Tensorflow.Operations | |||
if (element_shape == null) | |||
{ | |||
_infer_shape = infer_shape; | |||
_element_shape = new List<TensorShape> { }; | |||
_element_shape = new List<Shape> { }; | |||
} | |||
else | |||
{ | |||
_infer_shape = true; | |||
_element_shape = new List<TensorShape> { element_shape }; | |||
_element_shape = new List<Shape> { element_shape }; | |||
} | |||
tf_with(ops.name_scope(name, "TensorArray", new { handle, size, flow }), scope => | |||
@@ -124,7 +124,7 @@ namespace Tensorflow.Operations | |||
value = ops.convert_to_tensor(value, preferred_dtype: _dtype, name: "value"); | |||
if (_infer_shape) | |||
{ | |||
var shape = new TensorShape(value.TensorShape.dims.Skip(1).ToArray()); | |||
var shape = new Shape(value.shape.dims.Skip(1).ToArray()); | |||
_merge_element_shape(shape); | |||
} | |||
@@ -149,7 +149,7 @@ namespace Tensorflow.Operations | |||
}); | |||
} | |||
public void _merge_element_shape(TensorShape shape) | |||
public void _merge_element_shape(Shape shape) | |||
{ | |||
_element_shape.Add(shape); | |||
} | |||
@@ -169,7 +169,7 @@ namespace Tensorflow.Operations | |||
name: name); | |||
if (_element_shape != null) | |||
value.set_shape(_element_shape[0].dims); | |||
value.shape = _element_shape[0].dims; | |||
return value; | |||
} | |||
@@ -207,7 +207,7 @@ namespace Tensorflow.Operations | |||
public Tensor gather(Tensor indices, string name = null) | |||
{ | |||
var element_shape = new TensorShape(); | |||
var element_shape = Shape.Null; | |||
if (_element_shape.Count > 0) | |||
element_shape = _element_shape[0]; | |||
@@ -71,7 +71,7 @@ namespace Tensorflow | |||
verify_shape: verify_shape, | |||
allow_broadcast: false); | |||
public static Tensor zeros(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) | |||
public static Tensor zeros(Shape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) | |||
{ | |||
dtype = dtype.as_base_dtype(); | |||
@@ -130,9 +130,9 @@ namespace Tensorflow | |||
var tensor_tensor = ops.convert_to_tensor(tensor, name: "tensor"); | |||
var mask_tensor = ops.convert_to_tensor(mask, name: "mask"); | |||
var shape_mask = mask_tensor.TensorShape; | |||
var shape_mask = mask_tensor.shape; | |||
var ndims_mask = shape_mask.ndim; | |||
var shape_tensor = tensor_tensor.TensorShape; | |||
var shape_tensor = tensor_tensor.shape; | |||
if (ndims_mask < 1) | |||
throw new ValueError("mask cannot be scalar."); | |||
@@ -146,9 +146,9 @@ namespace Tensorflow | |||
}, 0); | |||
tensor_tensor = reshape(tensor_tensor, shape1); | |||
var first_dim = shape_tensor.dims.Skip(axis).Take(ndims_mask).First(); | |||
var s1 = tensor_shape.as_shape(shape_tensor.dims.Take(axis).ToArray()); | |||
var s1 = new Shape(shape_tensor.dims.Take(axis).ToArray()); | |||
var s2 = s1.concatenate(new[] { first_dim }).concatenate(shape_tensor.dims.Skip(axis + ndims_mask).ToArray()); | |||
tensor_tensor.set_shape(s2); | |||
tensor_tensor.shape = s2; | |||
mask_tensor = reshape(mask_tensor, new[] { -1 }); | |||
return _apply_mask_1d(tensor_tensor, mask_tensor, axis); | |||
@@ -186,10 +186,10 @@ namespace Tensorflow | |||
private static Tensor _constant_if_small(int value, Tensor shape) | |||
{ | |||
return shape < 1000UL; | |||
return shape < 1000L; | |||
} | |||
private static Tensor _constant_if_small<T>(T value, TensorShape shape, TF_DataType dtype, string name) | |||
private static Tensor _constant_if_small<T>(T value, Shape shape, TF_DataType dtype, string name) | |||
{ | |||
if (shape.size < 1000) | |||
{ | |||
@@ -364,7 +364,7 @@ namespace Tensorflow | |||
tensor = ops.convert_to_tensor(tensor, name: "tensor"); | |||
// is_fully_defined return unexpected value. | |||
if (optimize && tensor.shape.is_fully_defined() && dtype != TF_DataType.TF_VARIANT) | |||
if (optimize && tensor.shape.IsFullyDefined && dtype != TF_DataType.TF_VARIANT) | |||
{ | |||
} | |||
@@ -384,7 +384,7 @@ namespace Tensorflow | |||
public static Tensor reshape(Tensor tensor, Tensor shape, string name = null) | |||
=> gen_array_ops.reshape(tensor, shape, name: name); | |||
public static Tensor reshape(Tensor tensor, TensorShape shape, string name = null) | |||
public static Tensor reshape(Tensor tensor, Shape shape, string name = null) | |||
=> gen_array_ops.reshape(tensor, shape, name: name); | |||
public static Tensor reshape(Tensor tensor, object[] shape, string name = null) | |||
@@ -427,7 +427,7 @@ namespace Tensorflow | |||
}); | |||
} | |||
public static Tensor ones(TensorShape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) | |||
public static Tensor ones(Shape shape, TF_DataType dtype = TF_DataType.TF_FLOAT, string name = null) | |||
=> tf_with(ops.name_scope(name, "ones", shape), scope => | |||
{ | |||
dtype = dtype.as_base_dtype(); | |||
@@ -502,7 +502,7 @@ namespace Tensorflow | |||
return ops.convert_to_tensor(values, name: name); | |||
} | |||
var value_shape = ops.convert_to_tensor(values[0], name: name).TensorShape; | |||
var value_shape = ops.convert_to_tensor(values[0], name: name).shape; | |||
return gen_array_ops.pack(values, axis: axis, name: name); | |||
} | |||
@@ -512,7 +512,7 @@ namespace Tensorflow | |||
if (num == null) | |||
{ | |||
value = ops.convert_to_tensor(value); | |||
var value_shape = value.TensorShape; | |||
var value_shape = value.shape; | |||
num = (int)value_shape.dims[axis]; | |||
} | |||
@@ -588,8 +588,8 @@ namespace Tensorflow | |||
if (!tf.Context.executing_eagerly()) | |||
{ | |||
var input_shape = input.TensorShape; | |||
if (optimize && input.ndim > -1 && input_shape.is_fully_defined()) | |||
var input_shape = input.shape; | |||
if (optimize && input.ndim > -1 && input_shape.IsFullyDefined) | |||
{ | |||
var nd = np.array(input.shape.dims).astype(out_type.as_system_dtype()); | |||
return constant_op.constant(nd, name: name); | |||
@@ -610,7 +610,7 @@ namespace Tensorflow | |||
var input_shape = input_tensor.shape; | |||
if (optimize) | |||
{ | |||
if (input_shape.is_fully_defined()) | |||
if (input_shape.IsFullyDefined) | |||
{ | |||
return constant_op.constant(input_shape.size, dtype: out_type, name: name); | |||
} | |||
@@ -633,7 +633,7 @@ namespace Tensorflow | |||
tensor = ops.convert_to_tensor(tensor, name: "tensor"); | |||
// is_fully_defined return unexpected value. | |||
if (optimize && tensor.shape.is_fully_defined() && dtype != TF_DataType.TF_VARIANT) | |||
if (optimize && tensor.shape.IsFullyDefined && dtype != TF_DataType.TF_VARIANT) | |||
{ | |||
} | |||
@@ -906,7 +906,7 @@ namespace Tensorflow | |||
return gen_array_ops.gather_v2(@params, indices, axis, name: name); | |||
} | |||
public static Tensor transpose<T1>(T1 a, TensorShape perm, string name = "transpose", bool conjugate = false) | |||
public static Tensor transpose<T1>(T1 a, Shape perm, string name = "transpose", bool conjugate = false) | |||
{ | |||
return tf_with(ops.name_scope(name, "transpose", new { a }), scope => | |||
{ | |||
@@ -1005,9 +1005,9 @@ namespace Tensorflow | |||
if (!tf.Context.executing_eagerly()) | |||
{ | |||
var paddings_constant = tensor_util.constant_value(paddings); | |||
var input_shape = result.op.inputs[0].TensorShape; | |||
var input_shape = result.op.inputs[0].shape; | |||
if (input_shape.ndim > -1 && | |||
!result.TensorShape.is_fully_defined() && | |||
!result.shape.IsFullyDefined && | |||
!(paddings_constant is null)) | |||
{ | |||
var new_shape = new List<int>(); | |||
@@ -1018,14 +1018,14 @@ namespace Tensorflow | |||
else | |||
new_shape.Add(np.sum(padding) + dim); | |||
} | |||
result.set_shape(new_shape.ToArray()); | |||
result.shape = new_shape.ToArray(); | |||
} | |||
} | |||
return result; | |||
} | |||
public static Tensor placeholder(TF_DataType dtype, TensorShape shape = null, string name = null) | |||
public static Tensor placeholder(TF_DataType dtype, Shape shape = null, string name = null) | |||
{ | |||
if (tf.Context.executing_eagerly()) | |||
throw new RuntimeError("tf.placeholder() is not compatible with eager execution."); | |||
@@ -29,9 +29,9 @@ namespace Tensorflow | |||
var t_min = math_ops.minimum(values, clip_value_max); | |||
// Assert that the shape is compatible with the initial shape, | |||
// to prevent unintentional broadcasting. | |||
_ = values.TensorShape.merge_with(t_min.shape); | |||
_ = values.shape.merge_with(t_min.shape); | |||
var t_max = math_ops.maximum(t_min, clip_value_min, name: name); | |||
_ = values.TensorShape.merge_with(t_max.shape); | |||
_ = values.shape.merge_with(t_max.shape); | |||
return t_max; | |||
}); | |||
@@ -38,9 +38,9 @@ namespace Tensorflow | |||
{ | |||
predictions = ops.convert_to_tensor(predictions); | |||
labels = ops.convert_to_tensor(labels); | |||
var predictions_shape = predictions.TensorShape; | |||
var predictions_shape = predictions.shape; | |||
var predictions_rank = predictions_shape.ndim; | |||
var labels_shape = labels.TensorShape; | |||
var labels_shape = labels.shape; | |||
var labels_rank = labels_shape.ndim; | |||
if (labels_rank > -1 && predictions_rank > -1) | |||
{ | |||
@@ -319,7 +319,7 @@ namespace Tensorflow | |||
return gen_array_ops.identity(data, name: name); | |||
} | |||
public static void _SetShapeInvariants(Tensor[] input_vars, Tensor[] enter_vars, TensorShape[] shapes = null) | |||
public static void _SetShapeInvariants(Tensor[] input_vars, Tensor[] enter_vars, Shape[] shapes = null) | |||
{ | |||
if (shapes == null) | |||
return; | |||
@@ -327,7 +327,7 @@ namespace Tensorflow | |||
var flat_shapes = nest.flatten2(shapes); | |||
foreach (var (inp, var, shape) in zip(input_vars, enter_vars, flat_shapes)) | |||
{ | |||
var.set_shape(shape); | |||
var.shape = shape; | |||
} | |||
} | |||
@@ -706,7 +706,7 @@ namespace Tensorflow | |||
/// <param name="loop_vars"></param> | |||
/// <param name="shape_invariants"></param> | |||
public static TItem while_loop<TItem>(Func<TItem, Tensor> cond, Func<TItem, TItem> body, TItem loop_vars, | |||
TensorShape[] shape_invariants = null, | |||
Shape[] shape_invariants = null, | |||
int parallel_iterations = 10, | |||
bool back_prop = true, | |||
bool swap_memory = false, | |||
@@ -803,7 +803,7 @@ namespace Tensorflow | |||
data, frame_name, is_constant, parallel_iterations, name: name); | |||
if (use_input_shape) | |||
result.set_shape(data.TensorShape); | |||
result.shape = data.shape; | |||
return result; | |||
} | |||
@@ -7,7 +7,7 @@ namespace Tensorflow | |||
{ | |||
public class dataset_ops | |||
{ | |||
public Tensor tensor_dataset(Tensor[] components, TensorShape[] output_shapes, string name = null) | |||
public Tensor tensor_dataset(Tensor[] components, Shape[] output_shapes, string name = null) | |||
=> tf.Context.ExecuteOp("TensorDataset", name, new ExecuteOpArgs() | |||
{ | |||
OpInputArgs = new object[] { components } | |||
@@ -20,29 +20,29 @@ namespace Tensorflow | |||
/// <param name="output_shapes"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor tensor_slice_dataset(Tensor[] components, TensorShape[] output_shapes, string name = null) | |||
public Tensor tensor_slice_dataset(Tensor[] components, Shape[] output_shapes, string name = null) | |||
=> tf.Context.ExecuteOp("TensorSliceDataset", name, new ExecuteOpArgs() | |||
{ | |||
OpInputArgs = new object[] { components } | |||
}.SetAttributes(new { output_shapes })); | |||
public Tensor range_dataset(Tensor start, Tensor stop, Tensor step, TF_DataType[] output_types, TensorShape[] output_shapes, string name = null) | |||
public Tensor range_dataset(Tensor start, Tensor stop, Tensor step, TF_DataType[] output_types, Shape[] output_shapes, string name = null) | |||
=> tf.Context.ExecuteOp("RangeDataset", name, new ExecuteOpArgs(start, stop, step) | |||
.SetAttributes(new { output_types, output_shapes })); | |||
public Tensor repeat_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = null) | |||
public Tensor repeat_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, Shape[] output_shapes, string name = null) | |||
=> tf.Context.ExecuteOp("RepeatDataset", name, new ExecuteOpArgs(input_dataset, count) | |||
.SetAttributes(new { output_types, output_shapes })); | |||
public Tensor shard_dataset(Tensor input_dataset, Tensor num_shards, Tensor index, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
bool require_non_empty = false, string name = null) | |||
=> tf.Context.ExecuteOp("ShardDataset", name, new ExecuteOpArgs(input_dataset, num_shards, index) | |||
.SetAttributes(new { require_non_empty, output_types, output_shapes })); | |||
public Tensor zip_dataset(Tensor[] input_datasets, | |||
TF_DataType[] output_types, | |||
TensorShape[] output_shapes, | |||
Shape[] output_shapes, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("ZipDataset", name, new ExecuteOpArgs() | |||
{ | |||
@@ -51,14 +51,14 @@ namespace Tensorflow | |||
public Tensor shuffle_dataset_v3(Tensor input_dataset, Tensor buffer_size, | |||
Tensor seed, Tensor seed2, Tensor seed_generator, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
bool reshuffle_each_iteration = true, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("ShuffleDatasetV3", name, new ExecuteOpArgs(input_dataset, buffer_size, seed, seed2, seed_generator) | |||
.SetAttributes(new { reshuffle_each_iteration, output_types, output_shapes })); | |||
public Tensor skip_dataset(Tensor input_dataset, Tensor count, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("SkipDataset", name, new ExecuteOpArgs(input_dataset, count) | |||
.SetAttributes(new { output_types, output_shapes })); | |||
@@ -67,13 +67,13 @@ namespace Tensorflow | |||
=> tf.Context.ExecuteOp("DummySeedGenerator", name, new ExecuteOpArgs()); | |||
public Tensor concatenate_dataset(Tensor input_dataset, Tensor another_dataset, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("ConcatenateDataset", name, new ExecuteOpArgs(input_dataset, another_dataset) | |||
.SetAttributes(new { output_types, output_shapes })); | |||
public Tensor cache_dataset_v2(Tensor input_dataset, Tensor filename, Tensor cache, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("CacheDatasetV2", name, new ExecuteOpArgs(input_dataset, filename, cache) | |||
.SetAttributes(new { output_types, output_shapes })); | |||
@@ -91,7 +91,7 @@ namespace Tensorflow | |||
/// <returns></returns> | |||
public Tensor batch_dataset_v2(Tensor input_dataset, Tensor buffer_size, | |||
Tensor drop_remainder, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
bool parallel_copy = false, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("BatchDatasetV2", name, | |||
@@ -118,7 +118,7 @@ namespace Tensorflow | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor prefetch_dataset(Tensor input_dataset, Tensor buffer_size, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
int? slack_period = 0, | |||
bool legacy_autotune = true, | |||
string name = null) | |||
@@ -141,7 +141,7 @@ namespace Tensorflow | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor take_dataset(Tensor input_dataset, Tensor count, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("TakeDataset", name, new ExecuteOpArgs(input_dataset, count) | |||
.SetAttributes(new { output_types, output_shapes })); | |||
@@ -157,7 +157,7 @@ namespace Tensorflow | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor optimize_dataset(Tensor input_dataset, Tensor optimizations, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
string[] optimization_configs = null, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("OptimizeDataset", name, new ExecuteOpArgs(input_dataset, optimizations) | |||
@@ -170,7 +170,7 @@ namespace Tensorflow | |||
public Tensor optimize_dataset_v2(Tensor input_dataset, Tensor optimizations_enabled, | |||
Tensor optimizations_disabled, Tensor optimizations_default, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
string[] optimization_configs = null, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("OptimizeDatasetV2", name, new ExecuteOpArgs(input_dataset, | |||
@@ -193,7 +193,7 @@ namespace Tensorflow | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor model_dataset(Tensor input_dataset, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
AutotuneAlgorithm algorithm, long cpu_budget, long ram_budget, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("ModelDataset", name, new ExecuteOpArgs(input_dataset) | |||
@@ -213,7 +213,7 @@ namespace Tensorflow | |||
/// <param name="output_shapes"></param> | |||
/// <param name="name"></param> | |||
/// <returns>A tuple of `Tensor` objects (handle, deleter).</returns> | |||
public (Tensor, Tensor) anonymous_iterator_v2(TF_DataType[] output_types, TensorShape[] output_shapes, string name = null) | |||
public (Tensor, Tensor) anonymous_iterator_v2(TF_DataType[] output_types, Shape[] output_shapes, string name = null) | |||
{ | |||
var results = tf.Context.ExecuteOp("AnonymousIteratorV2", name, | |||
new ExecuteOpArgs().SetAttributes(new { output_types, output_shapes })); | |||
@@ -237,7 +237,7 @@ namespace Tensorflow | |||
/// <param name="iterator"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor map_dataset(Tensor dataset, ConcreteFunction f, TF_DataType[] output_types, TensorShape[] output_shapes, | |||
public Tensor map_dataset(Tensor dataset, ConcreteFunction f, TF_DataType[] output_types, Shape[] output_shapes, | |||
bool use_inter_op_parallelism = true, bool preserve_cardinality = false, string name = null) | |||
=> tf.Context.ExecuteOp("MapDataset", name, new ExecuteOpArgs(dataset, new Tensor[0]) | |||
.SetAttributes(new | |||
@@ -258,7 +258,7 @@ namespace Tensorflow | |||
/// <param name="output_shapes"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor filter_dataset(Tensor dataset, ConcreteFunction predicate, TF_DataType[] output_types, TensorShape[] output_shapes, | |||
public Tensor filter_dataset(Tensor dataset, ConcreteFunction predicate, TF_DataType[] output_types, Shape[] output_shapes, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("FilterDataset", name, new ExecuteOpArgs(dataset, new Tensor[0]) | |||
.SetAttributes(new | |||
@@ -277,7 +277,7 @@ namespace Tensorflow | |||
/// <param name="output_shapes"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor flat_map_dataset(Tensor dataset, ConcreteFunction f, TF_DataType[] output_types, TensorShape[] output_shapes, | |||
public Tensor flat_map_dataset(Tensor dataset, ConcreteFunction f, TF_DataType[] output_types, Shape[] output_shapes, | |||
string name = null) | |||
=> tf.Context.ExecuteOp("FlatMapDataset", name, new ExecuteOpArgs(dataset, new Tensor[0]) | |||
.SetAttributes(new { f, output_types, output_shapes })); | |||
@@ -294,7 +294,7 @@ namespace Tensorflow | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor parallel_map_dataset_v2(Tensor dataset, Tensor num_parallel_calls, ConcreteFunction f, | |||
TF_DataType[] output_types, TensorShape[] output_shapes, | |||
TF_DataType[] output_types, Shape[] output_shapes, | |||
bool use_inter_op_parallelism = true, | |||
string deterministic = "default", | |||
bool preserve_cardinality = false, | |||
@@ -329,7 +329,7 @@ namespace Tensorflow | |||
/// <param name="output_shapes"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public Tensor[] iterator_get_next(Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = null) | |||
public Tensor[] iterator_get_next(Tensor iterator, TF_DataType[] output_types, Shape[] output_shapes, string name = null) | |||
=> tf.Context.ExecuteOp("IteratorGetNext", name, new ExecuteOpArgs(iterator) | |||
.SetAttributes(new { output_types, output_shapes })); | |||
} | |||
@@ -169,16 +169,16 @@ namespace Tensorflow | |||
var results_flat = bodyItem.Accs_ta.Select(r => r.stack()).ToArray(); | |||
var n_static = new Dimension(tensor_shape.dimension_value(elems_flat[0].TensorShape.with_rank_at_least(1).dims[0])); | |||
var n_static = new Dimension(tensor_shape.dimension_value(elems_flat[0].shape.with_rank_at_least(1).dims[0])); | |||
foreach (var elem in elems_flat.Skip(1)) | |||
{ | |||
n_static.merge_with(new Dimension(tensor_shape.dimension_value(elem.TensorShape.with_rank_at_least(1).dims[0]))); | |||
n_static.merge_with(new Dimension(tensor_shape.dimension_value(elem.shape.with_rank_at_least(1).dims[0]))); | |||
} | |||
foreach (Tensor r in results_flat) | |||
{ | |||
r.set_shape(new TensorShape(n_static).concatenate(r.dims.Skip(1).ToArray())); | |||
r.shape = new Shape(n_static).concatenate(r.dims.Skip(1).ToArray()); | |||
} | |||
// todo get working when the above caching_device is fixed | |||
@@ -482,11 +482,7 @@ namespace Tensorflow | |||
/// <param name="name"> A name for the operation (optional).</param> | |||
/// <returns> `Tensor`. Has the same type as `s0`.</returns> | |||
public static Tensor broadcast_args(Tensor s0, Tensor s1, string name = null) | |||
{ | |||
var _op = tf.OpDefLib._apply_op_helper("BroadcastArgs", name, args: new { s0, s1, name }); | |||
return _op.outputs[0]; | |||
} | |||
=> tf.Context.ExecuteOp("BroadcastArgs", name, new ExecuteOpArgs(s0, s1)); | |||
/// <summary> | |||
/// Broadcast an array for a compatible shape. | |||
@@ -41,7 +41,7 @@ namespace Tensorflow | |||
} | |||
public static (Tensor, Tensor) tensor_array_v3<T>(T size, TF_DataType dtype = TF_DataType.DtInvalid, | |||
TensorShape element_shape = null, bool dynamic_size = false, bool clear_after_read = true, | |||
Shape element_shape = null, bool dynamic_size = false, bool clear_after_read = true, | |||
bool identical_element_shapes = false, string tensor_array_name = "", string name = null) | |||
{ | |||
var _op = tf.OpDefLib._apply_op_helper("TensorArrayV3", name, new | |||
@@ -72,7 +72,7 @@ namespace Tensorflow | |||
return _op.output; | |||
} | |||
public static Tensor padding_fifo_queue_v2(TF_DataType[] component_types, TensorShape[] shapes, | |||
public static Tensor padding_fifo_queue_v2(TF_DataType[] component_types, Shape[] shapes, | |||
int capacity = -1, string container = "", string shared_name = "", | |||
string name = null) | |||
{ | |||
@@ -88,7 +88,7 @@ namespace Tensorflow | |||
return _op.output; | |||
} | |||
public static Tensor fifo_queue_v2(TF_DataType[] component_types, TensorShape[] shapes, | |||
public static Tensor fifo_queue_v2(TF_DataType[] component_types, Shape[] shapes, | |||
int capacity = -1, string container = "", string shared_name = "", | |||
string name = null) | |||
{ | |||
@@ -104,7 +104,7 @@ namespace Tensorflow | |||
return _op.output; | |||
} | |||
public static Tensor priority_queue_v2(TF_DataType[] component_types, TensorShape[] shapes, | |||
public static Tensor priority_queue_v2(TF_DataType[] component_types, Shape[] shapes, | |||
int capacity = -1, string container = "", string shared_name = "", | |||
string name = null) | |||
{ | |||
@@ -120,7 +120,7 @@ namespace Tensorflow | |||
return _op.output; | |||
} | |||
public static Tensor random_shuffle_queue_v2(TF_DataType[] component_types, TensorShape[] shapes, | |||
public static Tensor random_shuffle_queue_v2(TF_DataType[] component_types, Shape[] shapes, | |||
int capacity = -1, int min_after_dequeue = 0, int seed = 0, int seed2 = 0, | |||
string container = "", string shared_name = "", string name = null) | |||
{ | |||
@@ -259,7 +259,7 @@ namespace Tensorflow | |||
} | |||
public static Tensor tensor_array_gather_v3(Tensor handle, Tensor indices, Tensor flow_in, | |||
TF_DataType dtype, TensorShape element_shape = null, string name = null) | |||
TF_DataType dtype, Shape element_shape = null, string name = null) | |||
{ | |||
var _op = tf.OpDefLib._apply_op_helper("TensorArrayGatherV3", name, new | |||
{ | |||
@@ -397,8 +397,12 @@ namespace Tensorflow | |||
/// <param name="y"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public static Tensor equal<Tx, Ty>(Tx x, Ty y, string name = null) | |||
=> tf.Context.ExecuteOp("Equal", name, new ExecuteOpArgs(x, y)); | |||
public static Tensor equal<Tx, Ty>(Tx x, Ty y, bool incompatible_shape_error = true, string name = null) | |||
=> tf.Context.ExecuteOp("Equal", name, new ExecuteOpArgs(x, y) | |||
.SetAttributes(new | |||
{ | |||
incompatible_shape_error | |||
})); | |||
/// <summary> | |||
/// Returns the truth value of (x != y) element-wise. | |||
@@ -88,7 +88,7 @@ namespace Tensorflow.Operations | |||
/// | |||
/// Returns a <c>Tensor</c> of same shape and type as the elements of <c>inputs</c>. | |||
/// </remarks> | |||
public static Tensor accumulate_n_v2(Tensor[] inputs, TensorShape shape, string name = "AccumulateNV2") | |||
public static Tensor accumulate_n_v2(Tensor[] inputs, Shape shape, string name = "AccumulateNV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["inputs"] = inputs; | |||
@@ -754,7 +754,7 @@ namespace Tensorflow.Operations | |||
/// container. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor anonymous_iterator(TF_DataType[] output_types, TensorShape[] output_shapes, string name = "AnonymousIterator") | |||
public static Tensor anonymous_iterator(TF_DataType[] output_types, Shape[] output_shapes, string name = "AnonymousIterator") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["output_types"] = output_types; | |||
@@ -2559,7 +2559,7 @@ namespace Tensorflow.Operations | |||
/// incomplete element has some undefined components in its value tuple, | |||
/// and may be updated using BarrierInsertMany. | |||
/// </remarks> | |||
public static Tensor barrier(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "Barrier") | |||
public static Tensor barrier(TF_DataType[] component_types, Shape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "Barrier") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["component_types"] = component_types; | |||
@@ -2883,7 +2883,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor batch_dataset(Tensor input_dataset, Tensor batch_size, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BatchDataset") | |||
public static Tensor batch_dataset(Tensor input_dataset, Tensor batch_size, TF_DataType[] output_types, Shape[] output_shapes, string name = "BatchDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -2918,7 +2918,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor batch_dataset_v2(Tensor input_dataset, Tensor batch_size, Tensor drop_remainder, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BatchDatasetV2") | |||
public static Tensor batch_dataset_v2(Tensor input_dataset, Tensor batch_size, Tensor drop_remainder, TF_DataType[] output_types, Shape[] output_shapes, string name = "BatchDatasetV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -4367,7 +4367,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor bytes_produced_stats_dataset(Tensor input_dataset, Tensor tag, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "BytesProducedStatsDataset") | |||
public static Tensor bytes_produced_stats_dataset(Tensor input_dataset, Tensor tag, TF_DataType[] output_types, Shape[] output_shapes, string name = "BytesProducedStatsDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -4587,7 +4587,7 @@ namespace Tensorflow.Operations | |||
/// (e.g. cannot be opened, contains tensors of the wrong shape / size), an error | |||
/// will the returned when used. | |||
/// </remarks> | |||
public static Tensor cache_dataset(Tensor input_dataset, Tensor filename, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "CacheDataset") | |||
public static Tensor cache_dataset(Tensor input_dataset, Tensor filename, TF_DataType[] output_types, Shape[] output_shapes, string name = "CacheDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -4802,7 +4802,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor collective_bcast_recv(TF_DataType T, int group_size, int group_key, int instance_key, TensorShape shape, string name = "CollectiveBcastRecv") | |||
public static Tensor collective_bcast_recv(TF_DataType T, int group_size, int group_key, int instance_key, Shape shape, string name = "CollectiveBcastRecv") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["T"] = T; | |||
@@ -4837,7 +4837,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor collective_bcast_send(Tensor input, int group_size, int group_key, int instance_key, TensorShape shape, string name = "CollectiveBcastSend") | |||
public static Tensor collective_bcast_send(Tensor input, int group_size, int group_key, int instance_key, Shape shape, string name = "CollectiveBcastSend") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input"] = input; | |||
@@ -5187,7 +5187,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor concatenate_dataset(Tensor input_dataset, Tensor another_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ConcatenateDataset") | |||
public static Tensor concatenate_dataset(Tensor input_dataset, Tensor another_dataset, TF_DataType[] output_types, Shape[] output_shapes, string name = "ConcatenateDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -5232,7 +5232,7 @@ namespace Tensorflow.Operations | |||
/// resets the aggregate to 0, and increments the global_step recorded by | |||
/// the accumulator. | |||
/// </remarks> | |||
public static Tensor conditional_accumulator(TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "ConditionalAccumulator") | |||
public static Tensor conditional_accumulator(TF_DataType dtype, Shape shape, string container = null, string shared_name = null, string name = "ConditionalAccumulator") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -7271,7 +7271,7 @@ namespace Tensorflow.Operations | |||
/// The components of the single element of <c>input</c>. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor[] dataset_to_single_element(Tensor dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "DatasetToSingleElement") | |||
public static Tensor[] dataset_to_single_element(Tensor dataset, TF_DataType[] output_types, Shape[] output_shapes, string name = "DatasetToSingleElement") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dataset"] = dataset; | |||
@@ -8294,7 +8294,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor dense_to_sparse_batch_dataset(Tensor input_dataset, Tensor batch_size, Tensor row_shape, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "DenseToSparseBatchDataset") | |||
public static Tensor dense_to_sparse_batch_dataset(Tensor input_dataset, Tensor batch_size, Tensor row_shape, TF_DataType[] output_types, Shape[] output_shapes, string name = "DenseToSparseBatchDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -10059,7 +10059,7 @@ namespace Tensorflow.Operations | |||
/// Raises an error if the input tensor's shape does not match the specified shape. | |||
/// Returns the input tensor otherwise. | |||
/// </remarks> | |||
public static Tensor ensure_shape(Tensor input, TensorShape shape, string name = "EnsureShape") | |||
public static Tensor ensure_shape(Tensor input, Shape shape, string name = "EnsureShape") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input"] = input; | |||
@@ -10584,7 +10584,7 @@ namespace Tensorflow.Operations | |||
/// The handle to the queue. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor f_i_f_o_queue(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "FIFOQueue") | |||
public static Tensor f_i_f_o_queue(TF_DataType[] component_types, Shape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "FIFOQueue") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["component_types"] = component_types; | |||
@@ -10632,7 +10632,7 @@ namespace Tensorflow.Operations | |||
/// The handle to the queue. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor f_i_f_o_queue_v2(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "FIFOQueueV2") | |||
public static Tensor f_i_f_o_queue_v2(TF_DataType[] component_types, Shape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "FIFOQueueV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["component_types"] = component_types; | |||
@@ -10670,7 +10670,7 @@ namespace Tensorflow.Operations | |||
/// \"Fake\" output value. This should not be consumed by another op. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor fake_param(TF_DataType dtype, TensorShape shape, string name = "FakeParam") | |||
public static Tensor fake_param(TF_DataType dtype, Shape shape, string name = "FakeParam") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -11048,7 +11048,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor filter_by_last_component_dataset(Tensor input_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "FilterByLastComponentDataset") | |||
public static Tensor filter_by_last_component_dataset(Tensor input_dataset, TF_DataType[] output_types, Shape[] output_shapes, string name = "FilterByLastComponentDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -13428,7 +13428,7 @@ namespace Tensorflow.Operations | |||
/// <remarks> | |||
/// The current implementation memmaps the tensor from a file. | |||
/// </remarks> | |||
public static Tensor immutable_const(TF_DataType dtype, TensorShape shape, string memory_region_name, string name = "ImmutableConst") | |||
public static Tensor immutable_const(TF_DataType dtype, Shape shape, string memory_region_name, string name = "ImmutableConst") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -13547,7 +13547,7 @@ namespace Tensorflow.Operations | |||
/// A tensor that will be provided using the infeed mechanism. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor infeed_dequeue(TF_DataType dtype, TensorShape shape, string name = "InfeedDequeue") | |||
public static Tensor infeed_dequeue(TF_DataType dtype, Shape shape, string name = "InfeedDequeue") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -13577,7 +13577,7 @@ namespace Tensorflow.Operations | |||
/// <remarks> | |||
/// simultaneously as an XLA tuple. | |||
/// </remarks> | |||
public static Tensor[] infeed_dequeue_tuple(TF_DataType[] dtypes, TensorShape[] shapes, string name = "InfeedDequeueTuple") | |||
public static Tensor[] infeed_dequeue_tuple(TF_DataType[] dtypes, Shape[] shapes, string name = "InfeedDequeueTuple") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtypes"] = dtypes; | |||
@@ -13608,7 +13608,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// Returns the description of the operation | |||
/// </returns> | |||
public static Operation infeed_enqueue(Tensor input, TensorShape shape = null, int? device_ordinal = null, string name = "InfeedEnqueue") | |||
public static Operation infeed_enqueue(Tensor input, Shape shape = null, int? device_ordinal = null, string name = "InfeedEnqueue") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input"] = input; | |||
@@ -13641,7 +13641,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// Returns the description of the operation | |||
/// </returns> | |||
public static Operation infeed_enqueue_tuple(Tensor[] inputs, TensorShape[] shapes, int? device_ordinal = null, string name = "InfeedEnqueueTuple") | |||
public static Operation infeed_enqueue_tuple(Tensor[] inputs, Shape[] shapes, int? device_ordinal = null, string name = "InfeedEnqueueTuple") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["inputs"] = inputs; | |||
@@ -14163,7 +14163,7 @@ namespace Tensorflow.Operations | |||
/// or "IteratorGetNext" op. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor iterator(string shared_name, string container, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "Iterator") | |||
public static Tensor iterator(string shared_name, string container, TF_DataType[] output_types, Shape[] output_shapes, string name = "Iterator") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["shared_name"] = shared_name; | |||
@@ -14195,7 +14195,7 @@ namespace Tensorflow.Operations | |||
/// A handle to an iterator resource. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor iterator_from_string_handle(Tensor string_handle, TF_DataType[] output_types = null, TensorShape[] output_shapes = null, string name = "IteratorFromStringHandle") | |||
public static Tensor iterator_from_string_handle(Tensor string_handle, TF_DataType[] output_types = null, Shape[] output_shapes = null, string name = "IteratorFromStringHandle") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["string_handle"] = string_handle; | |||
@@ -14224,7 +14224,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor[] iterator_get_next(Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNext") | |||
public static Tensor[] iterator_get_next(Tensor iterator, TF_DataType[] output_types, Shape[] output_shapes, string name = "IteratorGetNext") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["iterator"] = iterator; | |||
@@ -14253,7 +14253,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor iterator_get_next_as_optional(Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNextAsOptional") | |||
public static Tensor iterator_get_next_as_optional(Tensor iterator, TF_DataType[] output_types, Shape[] output_shapes, string name = "IteratorGetNextAsOptional") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["iterator"] = iterator; | |||
@@ -14286,7 +14286,7 @@ namespace Tensorflow.Operations | |||
/// the calling thread is not a member of the thread pool used to execute parallel | |||
/// operations (e.g. in eager mode). | |||
/// </remarks> | |||
public static Tensor[] iterator_get_next_sync(Tensor iterator, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "IteratorGetNextSync") | |||
public static Tensor[] iterator_get_next_sync(Tensor iterator, TF_DataType[] output_types, Shape[] output_shapes, string name = "IteratorGetNextSync") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["iterator"] = iterator; | |||
@@ -14495,7 +14495,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor latency_stats_dataset(Tensor input_dataset, Tensor tag, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "LatencyStatsDataset") | |||
public static Tensor latency_stats_dataset(Tensor input_dataset, Tensor tag, TF_DataType[] output_types, Shape[] output_shapes, string name = "LatencyStatsDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -17568,7 +17568,7 @@ namespace Tensorflow.Operations | |||
/// values. Each value must be a scalar. Data can be inserted into the table using | |||
/// the insert operations. It does not support the initialization operation. | |||
/// </remarks> | |||
public static Tensor mutable_dense_hash_table(Tensor empty_key, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, int? initial_num_buckets = null, float? max_load_factor = null, string name = "MutableDenseHashTable") | |||
public static Tensor mutable_dense_hash_table(Tensor empty_key, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, Shape value_shape = null, int? initial_num_buckets = null, float? max_load_factor = null, string name = "MutableDenseHashTable") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["empty_key"] = empty_key; | |||
@@ -17636,7 +17636,7 @@ namespace Tensorflow.Operations | |||
/// values. Each value must be a scalar. Data can be inserted into the table using | |||
/// the insert operations. It does not support the initialization operation. | |||
/// </remarks> | |||
public static Tensor mutable_dense_hash_table_v2(Tensor empty_key, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, int? initial_num_buckets = null, float? max_load_factor = null, string name = "MutableDenseHashTableV2") | |||
public static Tensor mutable_dense_hash_table_v2(Tensor empty_key, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, Shape value_shape = null, int? initial_num_buckets = null, float? max_load_factor = null, string name = "MutableDenseHashTableV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["empty_key"] = empty_key; | |||
@@ -17742,7 +17742,7 @@ namespace Tensorflow.Operations | |||
/// values. Each value must be a vector. Data can be inserted into the table using | |||
/// the insert operations. It does not support the initialization operation. | |||
/// </remarks> | |||
public static Tensor mutable_hash_table_of_tensors(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, string name = "MutableHashTableOfTensors") | |||
public static Tensor mutable_hash_table_of_tensors(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, Shape value_shape = null, string name = "MutableHashTableOfTensors") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["key_dtype"] = key_dtype; | |||
@@ -17794,7 +17794,7 @@ namespace Tensorflow.Operations | |||
/// values. Each value must be a vector. Data can be inserted into the table using | |||
/// the insert operations. It does not support the initialization operation. | |||
/// </remarks> | |||
public static Tensor mutable_hash_table_of_tensors_v2(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, TensorShape value_shape = null, string name = "MutableHashTableOfTensorsV2") | |||
public static Tensor mutable_hash_table_of_tensors_v2(TF_DataType key_dtype, TF_DataType value_dtype, string container = null, string shared_name = null, bool? use_node_name_sharing = null, Shape value_shape = null, string name = "MutableHashTableOfTensorsV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["key_dtype"] = key_dtype; | |||
@@ -18607,7 +18607,7 @@ namespace Tensorflow.Operations | |||
/// <remarks> | |||
/// Creates a dataset by applying optimizations to <c>input_dataset</c>. | |||
/// </remarks> | |||
public static Tensor optimize_dataset(Tensor input_dataset, Tensor optimizations, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "OptimizeDataset") | |||
public static Tensor optimize_dataset(Tensor input_dataset, Tensor optimizations, TF_DataType[] output_types, Shape[] output_shapes, string name = "OptimizeDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -18654,7 +18654,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor[] optional_get_value(Tensor optional, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "OptionalGetValue") | |||
public static Tensor[] optional_get_value(Tensor optional, TF_DataType[] output_types, Shape[] output_shapes, string name = "OptionalGetValue") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["optional"] = optional; | |||
@@ -19037,7 +19037,7 @@ namespace Tensorflow.Operations | |||
/// <remarks> | |||
/// block indefinitely until data is available. | |||
/// </remarks> | |||
public static Tensor outfeed_dequeue(TF_DataType dtype, TensorShape shape, int? device_ordinal = null, string name = "OutfeedDequeue") | |||
public static Tensor outfeed_dequeue(TF_DataType dtype, Shape shape, int? device_ordinal = null, string name = "OutfeedDequeue") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -19075,7 +19075,7 @@ namespace Tensorflow.Operations | |||
/// tuple. This operations will block indefinitely until data is available. | |||
/// Output <c>i</c> corresponds to XLA tuple element <c>i</c>. | |||
/// </remarks> | |||
public static Tensor[] outfeed_dequeue_tuple(TF_DataType[] dtypes, TensorShape[] shapes, int? device_ordinal = null, string name = "OutfeedDequeueTuple") | |||
public static Tensor[] outfeed_dequeue_tuple(TF_DataType[] dtypes, Shape[] shapes, int? device_ordinal = null, string name = "OutfeedDequeueTuple") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtypes"] = dtypes; | |||
@@ -19303,7 +19303,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor padded_batch_dataset(Tensor input_dataset, Tensor batch_size, Tensor[] padded_shapes, Tensor[] padding_values, TensorShape[] output_shapes, string name = "PaddedBatchDataset") | |||
public static Tensor padded_batch_dataset(Tensor input_dataset, Tensor batch_size, Tensor[] padded_shapes, Tensor[] padding_values, Shape[] output_shapes, string name = "PaddedBatchDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -19347,7 +19347,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor padded_batch_dataset_v2(Tensor input_dataset, Tensor batch_size, Tensor[] padded_shapes, Tensor[] padding_values, Tensor drop_remainder, TensorShape[] output_shapes, string name = "PaddedBatchDatasetV2") | |||
public static Tensor padded_batch_dataset_v2(Tensor input_dataset, Tensor batch_size, Tensor[] padded_shapes, Tensor[] padding_values, Tensor drop_remainder, Shape[] output_shapes, string name = "PaddedBatchDatasetV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -19401,7 +19401,7 @@ namespace Tensorflow.Operations | |||
/// to 0 in the shape attr. In this case DequeueMany will pad up to the maximum | |||
/// size of any given element in the minibatch. See below for details. | |||
/// </remarks> | |||
public static Tensor padding_f_i_f_o_queue(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "PaddingFIFOQueue") | |||
public static Tensor padding_f_i_f_o_queue(TF_DataType[] component_types, Shape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "PaddingFIFOQueue") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["component_types"] = component_types; | |||
@@ -19458,7 +19458,7 @@ namespace Tensorflow.Operations | |||
/// to 0 in the shape attr. In this case DequeueMany will pad up to the maximum | |||
/// size of any given element in the minibatch. See below for details. | |||
/// </remarks> | |||
public static Tensor padding_f_i_f_o_queue_v2(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "PaddingFIFOQueueV2") | |||
public static Tensor padding_f_i_f_o_queue_v2(TF_DataType[] component_types, Shape[] shapes = null, int? capacity = null, string container = null, string shared_name = null, string name = "PaddingFIFOQueueV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["component_types"] = component_types; | |||
@@ -19511,7 +19511,7 @@ namespace Tensorflow.Operations | |||
/// will copy pieces of the input into the output as they become available, in | |||
/// some situations this can provide a performance benefit. | |||
/// </remarks> | |||
public static Tensor parallel_concat(Tensor[] values, TensorShape shape, string name = "ParallelConcat") | |||
public static Tensor parallel_concat(Tensor[] values, Shape shape, string name = "ParallelConcat") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["values"] = values; | |||
@@ -19729,7 +19729,7 @@ namespace Tensorflow.Operations | |||
/// dense_values : | |||
/// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. | |||
/// </returns> | |||
public static (Tensor[] sparse_indices, Tensor[] sparse_values, Tensor[] sparse_shapes, Tensor[] dense_values) parse_example(Tensor serialized, Tensor names, Tensor[] sparse_keys, Tensor[] dense_keys, Tensor[] dense_defaults, TF_DataType[] sparse_types, TensorShape[] dense_shapes, string name = "ParseExample") | |||
public static (Tensor[] sparse_indices, Tensor[] sparse_values, Tensor[] sparse_shapes, Tensor[] dense_values) parse_example(Tensor serialized, Tensor names, Tensor[] sparse_keys, Tensor[] dense_keys, Tensor[] dense_defaults, TF_DataType[] sparse_types, Shape[] dense_shapes, string name = "ParseExample") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["serialized"] = serialized; | |||
@@ -19801,7 +19801,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor parse_example_dataset(Tensor input_dataset, Tensor num_parallel_calls, Tensor[] dense_defaults, string[] sparse_keys, string[] dense_keys, TF_DataType[] sparse_types, TensorShape[] dense_shapes, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ParseExampleDataset") | |||
public static Tensor parse_example_dataset(Tensor input_dataset, Tensor num_parallel_calls, Tensor[] dense_defaults, string[] sparse_keys, string[] dense_keys, TF_DataType[] sparse_types, Shape[] dense_shapes, TF_DataType[] output_types, Shape[] output_shapes, string name = "ParseExampleDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -19923,7 +19923,7 @@ namespace Tensorflow.Operations | |||
/// feature_list_dense_lengths : | |||
/// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. | |||
/// </returns> | |||
public static (Tensor[] context_sparse_indices, Tensor[] context_sparse_values, Tensor[] context_sparse_shapes, Tensor[] context_dense_values, Tensor[] feature_list_sparse_indices, Tensor[] feature_list_sparse_values, Tensor[] feature_list_sparse_shapes, Tensor[] feature_list_dense_values, Tensor[] feature_list_dense_lengths) parse_sequence_example(Tensor serialized, Tensor debug_name, Tensor[] context_dense_defaults, string[] feature_list_dense_missing_assumed_empty, string[] context_sparse_keys, string[] context_dense_keys, string[] feature_list_sparse_keys, string[] feature_list_dense_keys, int? Ncontext_sparse = null, int? Ncontext_dense = null, int? Nfeature_list_sparse = null, int? Nfeature_list_dense = null, TF_DataType[] context_sparse_types = null, TF_DataType[] feature_list_dense_types = null, TensorShape[] context_dense_shapes = null, TF_DataType[] feature_list_sparse_types = null, TensorShape[] feature_list_dense_shapes = null, string name = "ParseSequenceExample") | |||
public static (Tensor[] context_sparse_indices, Tensor[] context_sparse_values, Tensor[] context_sparse_shapes, Tensor[] context_dense_values, Tensor[] feature_list_sparse_indices, Tensor[] feature_list_sparse_values, Tensor[] feature_list_sparse_shapes, Tensor[] feature_list_dense_values, Tensor[] feature_list_dense_lengths) parse_sequence_example(Tensor serialized, Tensor debug_name, Tensor[] context_dense_defaults, string[] feature_list_dense_missing_assumed_empty, string[] context_sparse_keys, string[] context_dense_keys, string[] feature_list_sparse_keys, string[] feature_list_dense_keys, int? Ncontext_sparse = null, int? Ncontext_dense = null, int? Nfeature_list_sparse = null, int? Nfeature_list_dense = null, TF_DataType[] context_sparse_types = null, TF_DataType[] feature_list_dense_types = null, Shape[] context_dense_shapes = null, TF_DataType[] feature_list_sparse_types = null, Shape[] feature_list_dense_shapes = null, string name = "ParseSequenceExample") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["serialized"] = serialized; | |||
@@ -20029,7 +20029,7 @@ namespace Tensorflow.Operations | |||
/// dense_values : | |||
/// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. | |||
/// </returns> | |||
public static (Tensor[] sparse_indices, Tensor[] sparse_values, Tensor[] sparse_shapes, Tensor[] dense_values) parse_single_example(Tensor serialized, Tensor[] dense_defaults, int num_sparse, string[] sparse_keys, string[] dense_keys, TF_DataType[] sparse_types, TensorShape[] dense_shapes, string name = "ParseSingleExample") | |||
public static (Tensor[] sparse_indices, Tensor[] sparse_values, Tensor[] sparse_shapes, Tensor[] dense_values) parse_single_example(Tensor serialized, Tensor[] dense_defaults, int num_sparse, string[] sparse_keys, string[] dense_keys, TF_DataType[] sparse_types, Shape[] dense_shapes, string name = "ParseSingleExample") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["serialized"] = serialized; | |||
@@ -20140,7 +20140,7 @@ namespace Tensorflow.Operations | |||
/// feature_list_dense_values : | |||
/// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. | |||
/// </returns> | |||
public static (Tensor[] context_sparse_indices, Tensor[] context_sparse_values, Tensor[] context_sparse_shapes, Tensor[] context_dense_values, Tensor[] feature_list_sparse_indices, Tensor[] feature_list_sparse_values, Tensor[] feature_list_sparse_shapes, Tensor[] feature_list_dense_values) parse_single_sequence_example(Tensor serialized, Tensor feature_list_dense_missing_assumed_empty, Tensor[] context_sparse_keys, Tensor[] context_dense_keys, Tensor[] feature_list_sparse_keys, Tensor[] feature_list_dense_keys, Tensor[] context_dense_defaults, Tensor debug_name, TF_DataType[] context_sparse_types = null, TF_DataType[] feature_list_dense_types = null, TensorShape[] context_dense_shapes = null, TF_DataType[] feature_list_sparse_types = null, TensorShape[] feature_list_dense_shapes = null, string name = "ParseSingleSequenceExample") | |||
public static (Tensor[] context_sparse_indices, Tensor[] context_sparse_values, Tensor[] context_sparse_shapes, Tensor[] context_dense_values, Tensor[] feature_list_sparse_indices, Tensor[] feature_list_sparse_values, Tensor[] feature_list_sparse_shapes, Tensor[] feature_list_dense_values) parse_single_sequence_example(Tensor serialized, Tensor feature_list_dense_missing_assumed_empty, Tensor[] context_sparse_keys, Tensor[] context_dense_keys, Tensor[] feature_list_sparse_keys, Tensor[] feature_list_dense_keys, Tensor[] context_dense_defaults, Tensor debug_name, TF_DataType[] context_sparse_types = null, TF_DataType[] feature_list_dense_types = null, Shape[] context_dense_shapes = null, TF_DataType[] feature_list_sparse_types = null, Shape[] feature_list_dense_shapes = null, string name = "ParseSingleSequenceExample") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["serialized"] = serialized; | |||
@@ -20224,7 +20224,7 @@ namespace Tensorflow.Operations | |||
/// intended as a way to represent a value that will always be fed, and to | |||
/// provide attrs that enable the fed value to be checked at runtime. | |||
/// </remarks> | |||
public static Tensor placeholder(TF_DataType dtype, TensorShape shape = null, string name = "Placeholder") | |||
public static Tensor placeholder(TF_DataType dtype, Shape shape = null, string name = "Placeholder") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -20258,7 +20258,7 @@ namespace Tensorflow.Operations | |||
/// intended as a way to represent a value that will always be fed, and to | |||
/// provide attrs that enable the fed value to be checked at runtime. | |||
/// </remarks> | |||
public static Tensor placeholder_v2(TF_DataType dtype, TensorShape shape, string name = "PlaceholderV2") | |||
public static Tensor placeholder_v2(TF_DataType dtype, Shape shape, string name = "PlaceholderV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -20284,7 +20284,7 @@ namespace Tensorflow.Operations | |||
/// A placeholder tensor that defaults to <c>input</c> if it is not fed. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor placeholder_with_default(Tensor input, TensorShape shape, string name = "PlaceholderWithDefault") | |||
public static Tensor placeholder_with_default(Tensor input, Shape shape, string name = "PlaceholderWithDefault") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input"] = input; | |||
@@ -20403,7 +20403,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor prefetch_dataset(Tensor input_dataset, Tensor buffer_size, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "PrefetchDataset") | |||
public static Tensor prefetch_dataset(Tensor input_dataset, Tensor buffer_size, TF_DataType[] output_types, Shape[] output_shapes, string name = "PrefetchDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -20532,7 +20532,7 @@ namespace Tensorflow.Operations | |||
/// and DequeueMany) on a PriorityQueue will all require (resp. output) one extra | |||
/// entry in their input (resp. output) lists. | |||
/// </remarks> | |||
public static Tensor priority_queue(TensorShape[] shapes, TF_DataType[] component_types = null, int? capacity = null, string container = null, string shared_name = null, string name = "PriorityQueue") | |||
public static Tensor priority_queue(Shape[] shapes, TF_DataType[] component_types = null, int? capacity = null, string container = null, string shared_name = null, string name = "PriorityQueue") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["shapes"] = shapes; | |||
@@ -20587,7 +20587,7 @@ namespace Tensorflow.Operations | |||
/// and DequeueMany) on a PriorityQueue will all require (resp. output) one extra | |||
/// entry in their input (resp. output) lists. | |||
/// </remarks> | |||
public static Tensor priority_queue_v2(TensorShape[] shapes, TF_DataType[] component_types = null, int? capacity = null, string container = null, string shared_name = null, string name = "PriorityQueueV2") | |||
public static Tensor priority_queue_v2(Shape[] shapes, TF_DataType[] component_types = null, int? capacity = null, string container = null, string shared_name = null, string name = "PriorityQueueV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["shapes"] = shapes; | |||
@@ -22781,7 +22781,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor random_dataset(Tensor seed, Tensor seed2, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RandomDataset") | |||
public static Tensor random_dataset(Tensor seed, Tensor seed2, TF_DataType[] output_types, Shape[] output_shapes, string name = "RandomDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["seed"] = seed; | |||
@@ -23035,7 +23035,7 @@ namespace Tensorflow.Operations | |||
/// The handle to the queue. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor random_shuffle_queue(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, int? min_after_dequeue = null, int? seed = null, int? seed2 = null, string container = null, string shared_name = null, string name = "RandomShuffleQueue") | |||
public static Tensor random_shuffle_queue(TF_DataType[] component_types, Shape[] shapes = null, int? capacity = null, int? min_after_dequeue = null, int? seed = null, int? seed2 = null, string container = null, string shared_name = null, string name = "RandomShuffleQueue") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["component_types"] = component_types; | |||
@@ -23101,7 +23101,7 @@ namespace Tensorflow.Operations | |||
/// The handle to the queue. | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor random_shuffle_queue_v2(TF_DataType[] component_types, TensorShape[] shapes = null, int? capacity = null, int? min_after_dequeue = null, int? seed = null, int? seed2 = null, string container = null, string shared_name = null, string name = "RandomShuffleQueueV2") | |||
public static Tensor random_shuffle_queue_v2(TF_DataType[] component_types, Shape[] shapes = null, int? capacity = null, int? min_after_dequeue = null, int? seed = null, int? seed2 = null, string container = null, string shared_name = null, string name = "RandomShuffleQueueV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["component_types"] = component_types; | |||
@@ -23322,7 +23322,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor range_dataset(Tensor start, Tensor stop, Tensor step, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RangeDataset") | |||
public static Tensor range_dataset(Tensor start, Tensor stop, Tensor step, TF_DataType[] output_types, Shape[] output_shapes, string name = "RangeDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["start"] = start; | |||
@@ -24458,7 +24458,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor repeat_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "RepeatDataset") | |||
public static Tensor repeat_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, Shape[] output_shapes, string name = "RepeatDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -29811,7 +29811,7 @@ namespace Tensorflow.Operations | |||
/// <remarks> | |||
/// pseudorandomly. | |||
/// </remarks> | |||
public static Tensor shuffle_and_repeat_dataset(Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ShuffleAndRepeatDataset") | |||
public static Tensor shuffle_and_repeat_dataset(Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, Tensor count, TF_DataType[] output_types, Shape[] output_shapes, string name = "ShuffleAndRepeatDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -29862,7 +29862,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor shuffle_dataset(Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, TF_DataType[] output_types, TensorShape[] output_shapes, bool? reshuffle_each_iteration = null, string name = "ShuffleDataset") | |||
public static Tensor shuffle_dataset(Tensor input_dataset, Tensor buffer_size, Tensor seed, Tensor seed2, TF_DataType[] output_types, Shape[] output_shapes, bool? reshuffle_each_iteration = null, string name = "ShuffleDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -30084,7 +30084,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor skip_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SkipDataset") | |||
public static Tensor skip_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, Shape[] output_shapes, string name = "SkipDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -30222,7 +30222,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor slide_dataset(Tensor input_dataset, Tensor window_size, Tensor window_shift, Tensor window_stride, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SlideDataset") | |||
public static Tensor slide_dataset(Tensor input_dataset, Tensor window_size, Tensor window_shift, Tensor window_stride, TF_DataType[] output_types, Shape[] output_shapes, string name = "SlideDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -31745,7 +31745,7 @@ namespace Tensorflow.Operations | |||
/// resets the aggregate to 0, and increments the global_step recorded by | |||
/// the accumulator. | |||
/// </remarks> | |||
public static Tensor sparse_conditional_accumulator(TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "SparseConditionalAccumulator") | |||
public static Tensor sparse_conditional_accumulator(TF_DataType dtype, Shape shape, string container = null, string shared_name = null, string name = "SparseConditionalAccumulator") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -33565,7 +33565,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor sql_dataset(Tensor driver_name, Tensor data_source_name, Tensor query, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "SqlDataset") | |||
public static Tensor sql_dataset(Tensor driver_name, Tensor data_source_name, Tensor query, TF_DataType[] output_types, Shape[] output_shapes, string name = "SqlDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["driver_name"] = driver_name; | |||
@@ -35743,7 +35743,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor take_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "TakeDataset") | |||
public static Tensor take_dataset(Tensor input_dataset, Tensor count, TF_DataType[] output_types, Shape[] output_shapes, string name = "TakeDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -35953,7 +35953,7 @@ namespace Tensorflow.Operations | |||
/// var = state_ops.assign_add(var, [[6.0, 7.0]]) | |||
/// final = state_ops._destroy_temporary_variable(var, var_name=var_name) | |||
/// </remarks> | |||
public static Tensor temporary_variable(TensorShape shape, TF_DataType dtype, string var_name = null, string name = "TemporaryVariable") | |||
public static Tensor temporary_variable(Shape shape, TF_DataType dtype, string var_name = null, string name = "TemporaryVariable") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["shape"] = shape; | |||
@@ -36028,7 +36028,7 @@ namespace Tensorflow.Operations | |||
/// lengths : | |||
/// The Operation can be fetched from any of the Tensorreturned in the tuple values, by fetching the Operation property. | |||
/// </returns> | |||
public static (Tensor value, Tensor lengths) tensor_array_concat_v2(Tensor handle, Tensor flow_in, TF_DataType dtype, TensorShape element_shape_except0 = null, string name = "TensorArrayConcatV2") | |||
public static (Tensor value, Tensor lengths) tensor_array_concat_v2(Tensor handle, Tensor flow_in, TF_DataType dtype, Shape element_shape_except0 = null, string name = "TensorArrayConcatV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["handle"] = handle; | |||
@@ -36089,7 +36089,7 @@ namespace Tensorflow.Operations | |||
/// | |||
/// All elements must have the same shape (excepting the first dimension). | |||
/// </remarks> | |||
public static (Tensor value, Tensor lengths) tensor_array_concat_v3(Tensor handle, Tensor flow_in, TF_DataType dtype, TensorShape element_shape_except0 = null, string name = "TensorArrayConcatV3") | |||
public static (Tensor value, Tensor lengths) tensor_array_concat_v3(Tensor handle, Tensor flow_in, TF_DataType dtype, Shape element_shape_except0 = null, string name = "TensorArrayConcatV3") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["handle"] = handle; | |||
@@ -36124,7 +36124,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor tensor_array_gather_v2(Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, TensorShape element_shape = null, string name = "TensorArrayGatherV2") | |||
public static Tensor tensor_array_gather_v2(Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, Shape element_shape = null, string name = "TensorArrayGatherV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["handle"] = handle; | |||
@@ -36169,7 +36169,7 @@ namespace Tensorflow.Operations | |||
/// <remarks> | |||
/// All elements selected by <c>indices</c> must have the same shape. | |||
/// </remarks> | |||
public static Tensor tensor_array_gather_v3(Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, TensorShape element_shape = null, string name = "TensorArrayGatherV3") | |||
public static Tensor tensor_array_gather_v3(Tensor handle, Tensor indices, Tensor flow_in, TF_DataType dtype, Shape element_shape = null, string name = "TensorArrayGatherV3") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["handle"] = handle; | |||
@@ -36613,7 +36613,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor tensor_array_v2(Tensor size, TF_DataType dtype, TensorShape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, string tensor_array_name = null, string name = "TensorArrayV2") | |||
public static Tensor tensor_array_v2(Tensor size, TF_DataType dtype, Shape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, string tensor_array_name = null, string name = "TensorArrayV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["size"] = size; | |||
@@ -36679,7 +36679,7 @@ namespace Tensorflow.Operations | |||
/// <remarks> | |||
/// Write data via Write and read via Read or Pack. | |||
/// </remarks> | |||
public static (Tensor handle, Tensor flow) tensor_array_v3(Tensor size, TF_DataType dtype, TensorShape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, bool? identical_element_shapes = null, string tensor_array_name = null, string name = "TensorArrayV3") | |||
public static (Tensor handle, Tensor flow) tensor_array_v3(Tensor size, TF_DataType dtype, Shape element_shape = null, bool? dynamic_size = null, bool? clear_after_read = null, bool? identical_element_shapes = null, string tensor_array_name = null, string name = "TensorArrayV3") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["size"] = size; | |||
@@ -36776,7 +36776,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor tensor_dataset(Tensor[] components, TensorShape[] output_shapes, string name = "TensorDataset") | |||
public static Tensor tensor_dataset(Tensor[] components, Shape[] output_shapes, string name = "TensorDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["components"] = components; | |||
@@ -37144,7 +37144,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor tensor_slice_dataset(Tensor[] components, TensorShape[] output_shapes, string name = "TensorSliceDataset") | |||
public static Tensor tensor_slice_dataset(Tensor[] components, Shape[] output_shapes, string name = "TensorSliceDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["components"] = components; | |||
@@ -37899,7 +37899,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor unbatch_dataset(Tensor input_dataset, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "UnbatchDataset") | |||
public static Tensor unbatch_dataset(Tensor input_dataset, TF_DataType[] output_types, Shape[] output_shapes, string name = "UnbatchDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_dataset"] = input_dataset; | |||
@@ -38656,7 +38656,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor var_handle_op(TF_DataType dtype, TensorShape shape, string container = null, string shared_name = null, string name = "VarHandleOp") | |||
public static Tensor var_handle_op(TF_DataType dtype, Shape shape, string container = null, string shared_name = null, string name = "VarHandleOp") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["dtype"] = dtype; | |||
@@ -38710,7 +38710,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor variable(TensorShape shape, TF_DataType dtype, string container = null, string shared_name = null, string name = "Variable") | |||
public static Tensor variable(Shape shape, TF_DataType dtype, string container = null, string shared_name = null, string name = "Variable") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["shape"] = shape; | |||
@@ -38787,7 +38787,7 @@ namespace Tensorflow.Operations | |||
/// TODO(zhifengc/mrry): Adds a pointer to a more detail document | |||
/// about sharing states in tensorflow. | |||
/// </remarks> | |||
public static Tensor variable_v2(TensorShape shape, TF_DataType dtype, string container = null, string shared_name = null, string name = "VariableV2") | |||
public static Tensor variable_v2(Shape shape, TF_DataType dtype, string container = null, string shared_name = null, string name = "VariableV2") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["shape"] = shape; | |||
@@ -39064,7 +39064,7 @@ namespace Tensorflow.Operations | |||
/// <returns> | |||
/// The Operation can be fetched from the resulting Tensor, by fetching the Operation property from the result. | |||
/// </returns> | |||
public static Tensor zip_dataset(Tensor[] input_datasets, TF_DataType[] output_types, TensorShape[] output_shapes, string name = "ZipDataset") | |||
public static Tensor zip_dataset(Tensor[] input_datasets, TF_DataType[] output_types, Shape[] output_shapes, string name = "ZipDataset") | |||
{ | |||
var dict = new Dictionary<string, object>(); | |||
dict["input_datasets"] = input_datasets; | |||
@@ -94,7 +94,7 @@ namespace Tensorflow | |||
/// <param name="shared_name"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public static Tensor var_handle_op(TF_DataType dtype, TensorShape shape, | |||
public static Tensor var_handle_op(TF_DataType dtype, Shape shape, | |||
string container = "", string shared_name = "", string name = null) | |||
{ | |||
if (tf.Context.executing_eagerly()) | |||
@@ -53,11 +53,11 @@ namespace Tensorflow | |||
internal static long[] _ImageDimensions(Tensor image, int rank) | |||
{ | |||
if (image.TensorShape.is_fully_defined()) | |||
return image.TensorShape.as_list(); | |||
if (image.shape.IsFullyDefined) | |||
return image.shape.dims; | |||
else | |||
{ | |||
var static_shape = image.TensorShape.with_rank(rank).as_list(); | |||
var static_shape = image.shape.with_rank(rank).dims; | |||
var dynamic_shape = array_ops.unstack(array_ops.shape(image), rank); | |||
long[] ss_storage = null; | |||
@@ -82,23 +82,23 @@ namespace Tensorflow | |||
internal static Operation[] _CheckAtLeast3DImage(Tensor image, bool require_static) | |||
{ | |||
TensorShape image_shape; | |||
Shape image_shape; | |||
try | |||
{ | |||
if (image.TensorShape.ndim == Unknown) | |||
if (image.shape.ndim == Unknown) | |||
{ | |||
image_shape = image.TensorShape.with_rank(3); | |||
image_shape = image.shape.with_rank(3); | |||
} | |||
else | |||
{ | |||
image_shape = image.TensorShape.with_rank_at_least(3); | |||
image_shape = image.shape.with_rank_at_least(3); | |||
} | |||
} | |||
catch (ValueError) | |||
{ | |||
throw new ValueError("'image' must be at least three-dimensional."); | |||
} | |||
if (require_static & !image_shape.is_fully_defined()) | |||
if (require_static & !image_shape.IsFullyDefined) | |||
{ | |||
throw new ValueError("\'image\' must be fully defined."); | |||
} | |||
@@ -110,11 +110,11 @@ namespace Tensorflow | |||
} | |||
} | |||
var image_shape_last_three_elements = new TensorShape(new[] { | |||
var image_shape_last_three_elements = new Shape(new[] { | |||
image_shape.dims[image_shape.dims.Length - 1], | |||
image_shape.dims[image_shape.dims.Length - 2], | |||
image_shape.dims[image_shape.dims.Length - 3]}); | |||
if (!image_shape_last_three_elements.is_fully_defined()) | |||
if (!image_shape_last_three_elements.IsFullyDefined) | |||
{ | |||
Tensor image_shape_ = array_ops.shape(image); | |||
var image_shape_return = tf.constant(new[] { | |||
@@ -142,15 +142,15 @@ namespace Tensorflow | |||
internal static Tensor fix_image_flip_shape(Tensor image, Tensor result) | |||
{ | |||
TensorShape image_shape = image.shape; | |||
Shape image_shape = image.shape; | |||
if (image_shape == image_shape.unknown_shape()) | |||
{ | |||
// c# defaults null types to 0 anyhow, so this should be a pretty equivalent port | |||
result.set_shape(new TensorShape(new long[] { 0, 0, 0 })); | |||
result.shape = new long[] { 0, 0, 0 }; | |||
} | |||
else | |||
{ | |||
result.set_shape(image_shape); | |||
result.shape = image_shape; | |||
} | |||
return result; | |||
} | |||
@@ -173,7 +173,7 @@ namespace Tensorflow | |||
{ | |||
image = ops.convert_to_tensor(image, name: "image"); | |||
image = _AssertAtLeast3DImage(image); | |||
TensorShape shape = image.shape; | |||
Shape shape = image.shape; | |||
if (shape.ndim == 3 || shape.ndim == Unknown) | |||
{ | |||
Tensor uniform_random = random_ops.random_uniform(new int[] { }, 0f, 1.0f, seed: seed); | |||
@@ -219,7 +219,7 @@ namespace Tensorflow | |||
{ | |||
image = ops.convert_to_tensor(image, name: "image"); | |||
image = _AssertAtLeast3DImage(image); | |||
TensorShape shape = image.shape; | |||
Shape shape = image.shape; | |||
if (shape.ndim == 3 || shape.ndim == Unknown) | |||
{ | |||
return fix_image_flip_shape(image, gen_array_ops.reverse(image, new { flip_index })); | |||
@@ -245,10 +245,10 @@ namespace Tensorflow | |||
// can't get k to convert to tensor without throwing error about it being an int--- | |||
// might rework later. for now, k2 == k as Tensor | |||
Tensor k2 = ops.convert_to_tensor(k, dtype: dtypes.int32, name: "k"); | |||
k2.TensorShape.assert_has_rank(0); | |||
k2.shape.assert_has_rank(0); | |||
k2 = gen_ops.mod(k2, tf.constant(4)); | |||
TensorShape shape = image.shape; | |||
Shape shape = image.shape; | |||
if (shape.ndim == 3 || shape.ndim == Unknown) | |||
{ | |||
return _rot90_3D(image, k, scope); | |||
@@ -284,7 +284,7 @@ namespace Tensorflow | |||
math_ops.equal(k, 3), _rot270()}; | |||
var result = control_flow_ops.case_v2(cases, callable_default: () => new Tensor[] { image }, exclusive: true, name: name_scope); | |||
result.set_shape(new long[] { -1, -1, image.TensorShape.dims[2] }); | |||
result.shape = new long[] { -1, -1, image.shape.dims[2] }; | |||
return result; | |||
} | |||
@@ -295,7 +295,7 @@ namespace Tensorflow | |||
{ | |||
image = ops.convert_to_tensor(image, name: "image"); | |||
image = _AssertAtLeast3DImage(image); | |||
TensorShape shape = image.shape; | |||
Shape shape = image.shape; | |||
if (shape.ndim == 3 || shape.ndim == Unknown) | |||
{ | |||
return array_ops.transpose(image, new[] { 1, 0, 2 }, name: name); | |||
@@ -322,14 +322,14 @@ namespace Tensorflow | |||
return image; | |||
_AssertAtLeast3DImage(image); | |||
var rank = image.TensorShape.ndim; | |||
var rank = image.shape.ndim; | |||
if (rank != 3 && rank != 4) | |||
throw new ValueError(String.Format(@"`image` should either be a Tensor with rank = 3 | |||
or rank = 4. Had rank = {0}", rank)); | |||
object[] _get_dim(Tensor tensor, int idx) | |||
{ | |||
var static_shape = tensor.TensorShape.dims[idx]; | |||
var static_shape = tensor.shape.dims[idx]; | |||
if (static_shape != (int)None) | |||
return new object[2] { static_shape, false }; | |||
return new object[2] { array_ops.shape(tensor)[idx], true }; | |||
@@ -445,7 +445,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
image = ops.convert_to_tensor(image, name: "image"); | |||
bool is_batch = true; | |||
TensorShape image_shape = image.shape; | |||
Shape image_shape = image.shape; | |||
if (image_shape.ndim == 3) | |||
{ | |||
is_batch = false; | |||
@@ -455,7 +455,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
{ | |||
is_batch = false; | |||
image = array_ops.expand_dims(image, 0); | |||
image.set_shape(new TensorShape(0, 0, 0, 0)); | |||
image.shape = new Shape(0, 0, 0, 0); | |||
} | |||
else if (image_shape.ndim != 4) | |||
{ | |||
@@ -494,7 +494,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
); | |||
var padded = array_ops.pad(image, paddings); | |||
TensorShape padded_shape_result() | |||
Shape padded_shape_result() | |||
{ | |||
long[] i_remnants = { }; | |||
foreach (var i in new[] { bhwd[0], target_height, target_width, bhwd[3] }) | |||
@@ -502,10 +502,10 @@ or rank = 4. Had rank = {0}", rank)); | |||
return null; | |||
else | |||
i_remnants[i_remnants.Length] = i; | |||
return new TensorShape(i_remnants); | |||
return new Shape(i_remnants); | |||
}; | |||
TensorShape padded_shape = padded_shape_result(); | |||
padded.set_shape(padded_shape); | |||
Shape padded_shape = padded_shape_result(); | |||
padded.shape = padded_shape; | |||
if (!is_batch) | |||
{ | |||
@@ -524,7 +524,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
image = ops.convert_to_tensor(image, name: "image"); | |||
bool is_batch = true; | |||
TensorShape image_shape = image.shape; | |||
Shape image_shape = image.shape; | |||
if (image_shape.ndim == 3) | |||
{ | |||
is_batch = false; | |||
@@ -534,7 +534,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
{ | |||
is_batch = false; | |||
image = array_ops.expand_dims(image, 0); | |||
image.set_shape(new TensorShape(new long[] { 0, 0, 0, 0 })); | |||
image.shape = new long[] { 0, 0, 0, 0 }; | |||
} | |||
else if (image_shape.ndim != 4) | |||
{ | |||
@@ -573,7 +573,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
image, array_ops.stack(new[] { 0, offset_height, offset_width, 0 }), | |||
array_ops.stack(new[] { -1, target_height, target_width, -1 })); | |||
TensorShape cropped_shape_result() | |||
Shape cropped_shape_result() | |||
{ | |||
long[] i_remnants = { }; | |||
foreach (var i in new[] { bhwd[0], target_height, target_width, bhwd[3] }) | |||
@@ -581,10 +581,10 @@ or rank = 4. Had rank = {0}", rank)); | |||
return null; | |||
else | |||
i_remnants[i_remnants.Length] = i; | |||
return new TensorShape(i_remnants); | |||
return new Shape(i_remnants); | |||
}; | |||
var cropped_shape = cropped_shape_result(); | |||
cropped.set_shape(cropped_shape); | |||
cropped.shape = cropped_shape; | |||
if (!is_batch) | |||
{ | |||
@@ -601,7 +601,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
return tf_with(ops.name_scope(null, "resize_image_with_crop_or_pad", new[] { image }), delegate | |||
{ | |||
image = ops.convert_to_tensor(image, name: "image"); | |||
TensorShape image_shape = image.shape; | |||
Shape image_shape = image.shape; | |||
bool is_batch = true; | |||
if (image_shape.ndim == 3) | |||
{ | |||
@@ -612,7 +612,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
{ | |||
is_batch = false; | |||
image = array_ops.expand_dims(image, 0); | |||
image.set_shape(new TensorShape(new int[] { 0, 0, 0, 0 })); | |||
image.shape = new long[] { 0, 0, 0, 0 }; | |||
} | |||
else if (image_shape.ndim != 4) | |||
{ | |||
@@ -684,7 +684,7 @@ or rank = 4. Had rank = {0}", rank)); | |||
Tensor resized = pad_to_bounding_box(cropped, offset_pad_height, offset_pad_width, | |||
(int)target_height, (int)target_width); | |||
if (resized.TensorShape.ndim == Unknown) | |||
if (resized.shape.ndim == Unknown) | |||
throw new ValueError("resized contains no shape."); | |||
var _rhrw_ = _ImageDimensions(resized, rank: 4); | |||
@@ -713,20 +713,20 @@ or rank = 4. Had rank = {0}", rank)); | |||
{ | |||
return tf_with(ops.name_scope(name, "resize", new[] { images, size }), delegate | |||
{ | |||
if (images.TensorShape.ndim == Unknown) | |||
if (images.shape.ndim == Unknown) | |||
throw new ValueError("\'images\' contains no shape."); | |||
bool is_batch = true; | |||
if (images.TensorShape.ndim == 3) | |||
if (images.shape.ndim == 3) | |||
{ | |||
is_batch = false; | |||
images = array_ops.expand_dims(images, 0); | |||
} | |||
else if (images.TensorShape.ndim != 4) | |||
else if (images.shape.ndim != 4) | |||
throw new ValueError("\'images\' must have either 3 or 4 dimensions."); | |||
var (height, width) = (images.dims[1], images.dims[2]); | |||
if (!size.TensorShape.is_compatible_with(new[] { 2 })) | |||
if (!size.shape.is_compatible_with(new[] { 2 })) | |||
throw new ValueError(@"\'size\' must be a 1-D Tensor of 2 elements: | |||
new_height, new_width"); | |||
@@ -782,7 +782,7 @@ new_height, new_width"); | |||
images = resizer_fn(images, size); | |||
images.set_shape(new TensorShape(new long[] { Unknown, new_height_const, new_width_const, Unknown })); | |||
images.shape = new Shape(Unknown, new_height_const, new_width_const, Unknown); | |||
if (!is_batch) | |||
images = array_ops.squeeze(images, axis: new int[] { 0 }); | |||
@@ -862,7 +862,7 @@ new_height, new_width"); | |||
return tf_with(ops.name_scope(null, "resize_image_with_pad", new[] { image }), delegate | |||
{ | |||
image = ops.convert_to_tensor(image, name: "tensor"); | |||
var image_shape = image.TensorShape; | |||
var image_shape = image.shape; | |||
bool is_batch = true; | |||
if (image_shape.ndim == 3) | |||
{ | |||
@@ -873,7 +873,7 @@ new_height, new_width"); | |||
{ | |||
is_batch = false; | |||
image = array_ops.expand_dims(image, 0); | |||
image.set_shape(new TensorShape(new[] { Unknown, Unknown, Unknown, Unknown })); | |||
image.shape = new Shape(Unknown, Unknown, Unknown, Unknown); | |||
} | |||
else if (image_shape.ndim != 4) | |||
{ | |||
@@ -928,7 +928,7 @@ new_height, new_width"); | |||
var padded = pad_to_bounding_box(resized, p_height, p_width, target_height, | |||
target_width); | |||
if (padded.TensorShape.ndim == Unknown) | |||
if (padded.shape.ndim == Unknown) | |||
throw new ValueError("padded contains no shape."); | |||
_ImageDimensions(padded, rank: 4); | |||
@@ -1175,7 +1175,7 @@ new_height, new_width"); | |||
return tf_with(ops.name_scope(name, "adjust_jpeg_quality", new[] { image }), delegate | |||
{ | |||
image = ops.convert_to_tensor(image, name: "image"); | |||
var channels = image.TensorShape.as_list()[image.TensorShape.dims.Length - 1]; | |||
var channels = image.shape[image.shape.dims.Length - 1]; | |||
var orig_dtype = image.dtype; | |||
// python code checks to ensure jpeq_quality is a tensor; unnecessary here since | |||
// it is passed as a tensor | |||
@@ -1327,7 +1327,7 @@ new_height, new_width"); | |||
{0.587f, -0.27455667f, -0.52273617f}, | |||
{0.114f, -0.32134392f, 0.31119955f}}; | |||
Tensor kernel = ops.convert_to_tensor(_rgb_to_yiq_kernel, dtype: images.dtype, name: "kernel"); | |||
var ndims = images.TensorShape.ndim; | |||
var ndims = images.shape.ndim; | |||
return math_ops.tensordot(images, kernel, axes: new int[] { ndims - 1, 0 }); | |||
} | |||
@@ -1338,7 +1338,7 @@ new_height, new_width"); | |||
{0.95598634f, -0.27201283f, -1.10674021f}, | |||
{0.6208248f, -0.64720424f, 1.70423049f}}; | |||
Tensor kernel = ops.convert_to_tensor(_yiq_to_rgb_kernel, dtype: images.dtype, name: "kernel"); | |||
var ndims = images.TensorShape.ndim; | |||
var ndims = images.shape.ndim; | |||
return math_ops.tensordot(images, kernel, axes: new int[] { ndims - 1, 0 }); | |||
} | |||
@@ -1349,7 +1349,7 @@ new_height, new_width"); | |||
{0.587f, -0.28886916f, -0.51496512f}, | |||
{0.114f, 0.43601035f, -0.10001026f}}; | |||
Tensor kernel = ops.convert_to_tensor(_rgb_to_yuv_kernel, dtype: images.dtype, name: "kernel"); | |||
var ndims = images.TensorShape.ndim; | |||
var ndims = images.shape.ndim; | |||
return math_ops.tensordot(images, kernel, axes: new int[] { ndims - 1, 0 }); | |||
} | |||
@@ -1360,15 +1360,15 @@ new_height, new_width"); | |||
{0f, -0.394642334f, 2.03206185f}, | |||
{1.13988303f, -0.58062185f, 0f}}; | |||
Tensor kernel = ops.convert_to_tensor(_yuv_to_rgb_kernel, dtype: images.dtype, name: "kernel"); | |||
var ndims = images.TensorShape.ndim; | |||
var ndims = images.shape.ndim; | |||
return math_ops.tensordot(images, kernel, axes: new int[] { ndims - 1, 0 }); | |||
} | |||
internal static (Tensor, Tensor, Operation[]) _verify_compatible_image_shapes(Tensor img1, Tensor img2) | |||
{ | |||
TensorShape shape1 = img1.TensorShape.with_rank_at_least(3); | |||
TensorShape shape2 = img2.TensorShape.with_rank_at_least(3); | |||
shape1 = new TensorShape(shape1.dims.Skip(shape1.dims.Length - 3).Take(shape1.dims.Length - (shape1.dims.Length - 3)).ToArray()); | |||
Shape shape1 = img1.shape.with_rank_at_least(3); | |||
Shape shape2 = img2.shape.with_rank_at_least(3); | |||
shape1 = new Shape(shape1.dims.Skip(shape1.dims.Length - 3).Take(shape1.dims.Length - (shape1.dims.Length - 3)).ToArray()); | |||
tensor_shape.assert_is_compatible_with(self: new Tensor(shape1.dims), other: new Tensor(shape2.dims.Skip(shape2.dims.Length - 3).Take(shape2.dims.Length - (shape2.dims.Length - 3)).ToArray())); | |||
if (shape1.ndim != -1 && shape2.ndim != -1) | |||
@@ -1653,7 +1653,7 @@ new_height, new_width"); | |||
public static (Tensor, Tensor) image_gradients(Tensor image) | |||
{ | |||
if (image.TensorShape.ndim != 4) | |||
if (image.shape.ndim != 4) | |||
throw new ValueError(String.Format(@"image_gradients expects a 4D tensor [batch_size, h, w, d], not {0}.", image.shape)); | |||
var image_shape = array_ops.shape(image); | |||
@@ -1674,7 +1674,7 @@ new_height, new_width"); | |||
public static Tensor sobel_edges(Tensor image) | |||
{ | |||
var static_image_shape = image.TensorShape; | |||
var static_image_shape = image.shape; | |||
var image_shape = array_ops.shape(image); | |||
var kernels = new Tensor(new int[,] {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}, | |||
{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}); | |||
@@ -1695,7 +1695,7 @@ new_height, new_width"); | |||
var shape = array_ops.concat(new Tensor[] { image_shape, ops.convert_to_tensor(num_kernels) }, 0); | |||
output = array_ops.reshape(output, shape: shape); | |||
output.set_shape(static_image_shape.concatenate(new int[] { num_kernels })); | |||
output.shape = static_image_shape.concatenate(new int[] { num_kernels }); | |||
return output; | |||
} | |||
@@ -1930,7 +1930,7 @@ new_height, new_width"); | |||
return tf_with(ops.name_scope(name, "non_max_suppression_padded"), delegate | |||
{ | |||
if (!pad_to_max_output_size) | |||
if (boxes.TensorShape.rank != -1 && boxes.TensorShape.rank > 2) | |||
if (boxes.shape.ndim != -1 && boxes.shape.ndim > 2) | |||
throw new ValueError(String.Format( | |||
"'pad_to_max_output_size' (value {0}) must be true for 'batched input'", pad_to_max_output_size)); | |||
if (name == null) | |||
@@ -1943,11 +1943,11 @@ new_height, new_width"); | |||
// 0, slice(None, num_valid, None) | |||
// which is what I tried to replicate below, but i don't think that Unknown is the exact | |||
// equivalent to None, and don't know about the slice function bit. | |||
idx = idx[0, slice(Unknown, num_valid.TensorShape.ndim, Unknown).ToArray()[0]]; | |||
idx = idx[0, slice(Unknown, num_valid.shape.ndim, Unknown).ToArray()[0]]; | |||
else | |||
{ | |||
var batch_dims = array_ops.concat(new Tensor[] { | |||
new Tensor(array_ops.shape(boxes).dims.Take(boxes.TensorShape.dims.Length - 2).ToArray()), | |||
new Tensor(array_ops.shape(boxes).dims.Take(boxes.shape.dims.Length - 2).ToArray()), | |||
array_ops.expand_dims(max_output_size, 0) | |||
}, 0); | |||
idx = array_ops.reshape(idx, batch_dims); | |||
@@ -1984,8 +1984,8 @@ new_height, new_width"); | |||
return (sorted_scores, sorted_boxes, sorted_scores_indices); | |||
} | |||
var batch_dims = array_ops.shape(boxes).dims.Take(boxes.TensorShape.dims.Length - 2).ToArray(); | |||
var num_boxes = array_ops.shape(boxes).dims[boxes.TensorShape.dims.Length - 2]; | |||
var batch_dims = array_ops.shape(boxes).dims.Take(boxes.shape.dims.Length - 2).ToArray(); | |||
var num_boxes = array_ops.shape(boxes).dims[boxes.shape.dims.Length - 2]; | |||
boxes = array_ops.reshape(boxes, new[] { -1, num_boxes, 4 }); | |||
scores = array_ops.reshape(scores, new[] { -1, num_boxes }); | |||
var batch_size = array_ops.shape(boxes).dims[0]; | |||
@@ -2059,14 +2059,14 @@ new_height, new_width"); | |||
body: (Tensor[] args) => suppression_loop_body(args), | |||
loop_vars: new object[] { | |||
boxes, iou_threshold, | |||
array_ops.zeros(new TensorShape(batch_size), dtypes.int32), | |||
array_ops.zeros(new Shape(batch_size), dtypes.int32), | |||
constant_op.constant(0) | |||
}, | |||
shape_invariants: new TensorShape[] { | |||
new TensorShape(new int[] {Unknown, Unknown, 4}), | |||
new TensorShape(new int[] {}), | |||
new TensorShape(new int[] {Unknown}), | |||
new TensorShape(new int[] {}) | |||
shape_invariants: new Shape[] { | |||
new Shape(new int[] {Unknown, Unknown, 4}), | |||
new Shape(new int[] {}), | |||
new Shape(new int[] {Unknown}), | |||
new Shape(new int[] {}) | |||
} | |||
); | |||
*/ | |||
@@ -7,7 +7,7 @@ namespace Tensorflow | |||
{ | |||
public Tensor eye(int num_rows, | |||
int num_columns = -1, | |||
TensorShape batch_shape = null, | |||
Shape batch_shape = null, | |||
TF_DataType dtype = TF_DataType.TF_DOUBLE, | |||
string name = null) | |||
{ | |||
@@ -19,7 +19,7 @@ namespace Tensorflow | |||
bool is_square = num_columns == num_rows; | |||
var diag_size = Math.Min(num_rows, num_columns); | |||
if (batch_shape == null) | |||
batch_shape = new TensorShape(new int[0]); | |||
batch_shape = new Shape(new int[0]); | |||
var diag_shape = batch_shape.dims.concat(new long[] { diag_size }); | |||
long[] shape = null; | |||
@@ -123,16 +123,16 @@ namespace Tensorflow | |||
maximum_iterations: tf.constant(n)); | |||
var results_flat = r_a.Accs_ta.Select(r => r.stack()).ToArray(); | |||
var n_static = new Dimension(tensor_shape.dimension_value(elems_flat[0].TensorShape.with_rank_at_least(1).dims[0])); | |||
var n_static = new Dimension(tensor_shape.dimension_value(elems_flat[0].shape.with_rank_at_least(1).dims[0])); | |||
foreach (var elem in elems_flat.Skip(1)) | |||
{ | |||
n_static.merge_with(new Dimension(tensor_shape.dimension_value(elem.TensorShape.with_rank_at_least(1).dims[0]))); | |||
n_static.merge_with(new Dimension(tensor_shape.dimension_value(elem.shape.with_rank_at_least(1).dims[0]))); | |||
} | |||
foreach (Tensor r in results_flat) | |||
{ | |||
r.set_shape(new TensorShape(n_static).concatenate(r.dims.Skip(1).ToArray())); | |||
r.shape = new Shape(n_static).concatenate(r.dims.Skip(1).ToArray()); | |||
} | |||
// todo get working when the above caching_device is fixed | |||
@@ -422,25 +422,33 @@ namespace Tensorflow | |||
public static Tensor lgamma(Tensor x, string name = null) | |||
=> gen_math_ops.lgamma(x, name: name); | |||
public static Tensor linspace(Tensor start, Tensor stop, Tensor num, string name = null, int axis = 0) | |||
public static Tensor linspace(Tensor start, Tensor stop, int num = 50, string name = null, int axis = 0) | |||
{ | |||
return tf_with(ops.name_scope(name, "linspace", new { start, stop }), scope => | |||
{ | |||
var num_int_tensor = array_ops.constant(num); | |||
var num_tensor = array_ops.constant(num, dtype: start.dtype); | |||
var broadcast_shape = array_ops.broadcast_dynamic_shape(array_ops.shape(start), array_ops.shape(stop)); | |||
start = gen_array_ops.broadcast_to(start, broadcast_shape); | |||
stop = gen_array_ops.broadcast_to(stop, broadcast_shape); | |||
var expanded_start = array_ops.expand_dims(start, axis: axis); | |||
var expanded_stop = array_ops.expand_dims(stop, axis: axis); | |||
var shape = array_ops.shape(expanded_start); | |||
var ndims = array_ops.shape(shape)[0]; | |||
var axis_tensor = array_ops.where_v2(constant_op.constant(axis >= 0), x: axis, y: ndims + axis); | |||
// The purpose is to avoid having negative values when repeating. | |||
var num_fill = gen_math_ops.maximum(num - 2, 0); | |||
var n_steps = gen_math_ops.maximum(num - 1, 1); | |||
var num_fill = gen_math_ops.maximum(num_int_tensor - 2, 0); | |||
var n_steps = gen_math_ops.maximum(num_int_tensor - 1, 1); | |||
var delta = (expanded_stop - expanded_start) / cast(n_steps, expanded_stop.dtype); | |||
var range_end = array_ops.where_v2(num >= 0, n_steps, -1); | |||
var range_end = array_ops.where_v2(num_int_tensor >= 0, n_steps, -1); | |||
var desired_range = cast(range(1, range_end, dtype: dtypes.int64), delta.dtype); | |||
var mask = gen_math_ops.equal(axis, range(ndims)); | |||
var mask = gen_math_ops.equal(axis_tensor, range(ndims)); | |||
var desired_range_shape = array_ops.where_v2(mask, num_fill, 1); | |||
desired_range = array_ops.reshape(desired_range, desired_range_shape); | |||
var res = expanded_start + delta * desired_range; | |||
@@ -450,7 +458,7 @@ namespace Tensorflow | |||
var all_tensors = new[] { expanded_start, res, expanded_stop }; | |||
var concatenated = array_ops.concat(all_tensors, axis: axis); | |||
var begin = array_ops.zeros_like(shape); | |||
var size = array_ops.where_v2(mask, num, shape); | |||
var size = array_ops.where_v2(mask, num_int_tensor, shape); | |||
return array_ops.slice(concatenated, begin, size); | |||
}); | |||
@@ -745,7 +753,7 @@ namespace Tensorflow | |||
return tf.Context.ExecuteOp("Pow", name, new ExecuteOpArgs(x_tensor, y_tensor)); | |||
}); | |||
public static Tensor range(object start, object limit = null, object delta = null, TF_DataType dtype = TF_DataType.DtInvalid, string name = "range") | |||
public static Tensor range(object start, object limit = null, object delta = null, TF_DataType? dtype = null, string name = "range") | |||
{ | |||
if (limit == null) | |||
{ | |||
@@ -753,36 +761,14 @@ namespace Tensorflow | |||
start = 0; | |||
} | |||
if (dtype == TF_DataType.DtInvalid) | |||
{ | |||
if (limit is Tensor tensor) | |||
dtype = tensor.dtype; | |||
else | |||
dtype = limit.GetType().as_tf_dtype(); | |||
} | |||
if (delta == null) | |||
{ | |||
if (dtype == TF_DataType.TF_INT32) | |||
delta = 1; | |||
else if (dtype == TF_DataType.TF_INT64) | |||
delta = 1L; | |||
else if (dtype == TF_DataType.TF_FLOAT) | |||
delta = 1.0f; | |||
else if (dtype == TF_DataType.TF_DOUBLE) | |||
delta = 1.0d; | |||
else | |||
delta = 1; | |||
} | |||
var dtype1 = dtype ?? limit.GetDataType(); | |||
return tf_with(ops.name_scope(name, "Range", new { start, limit, delta }), scope => | |||
{ | |||
name = scope; | |||
var start1 = ops.convert_to_tensor(start, name: "start", dtype: dtype); | |||
var limit1 = ops.convert_to_tensor(limit, name: "limit", dtype: dtype); | |||
var delta1 = ops.convert_to_tensor(delta, name: "delta", dtype: dtype); | |||
var start1 = ops.convert_to_tensor(start, name: "start", dtype: dtype1); | |||
var limit1 = ops.convert_to_tensor(limit, name: "limit", dtype: dtype1); | |||
var delta1 = ops.convert_to_tensor(delta ?? 1, name: "delta", dtype: dtype1); | |||
return gen_math_ops.range(start1, limit1, delta1, name); | |||
}); | |||
} | |||
@@ -860,7 +846,7 @@ namespace Tensorflow | |||
Tensor maxlength = null, | |||
TF_DataType dtype = TF_DataType.TF_INT32, | |||
string name = null, | |||
TensorShape axis = null, | |||
Shape axis = null, | |||
bool binary_output = false) | |||
=> tf_with(ops.name_scope(name, "bincount"), scope => | |||
{ | |||
@@ -906,9 +892,9 @@ namespace Tensorflow | |||
{ | |||
Tensor _tensordot_reshape(Tensor a, int[] axes, bool flipped = false) | |||
{ | |||
if (a.TensorShape.is_fully_defined() && isinstance(axes, (typeof(List<object>), typeof(Tuple)))) | |||
if (a.shape.IsFullyDefined && isinstance(axes, (typeof(List<object>), typeof(Tuple)))) | |||
{ | |||
var shape_a = a.TensorShape.as_list(); | |||
var shape_a = a.shape.dims; | |||
// axes | |||
int iter = 0; | |||
@@ -950,11 +936,11 @@ namespace Tensorflow | |||
+ ops.convert_to_tensor(list(axes)); | |||
// new_shape | |||
TensorShape new_shape; | |||
Shape new_shape; | |||
if (flipped) | |||
new_shape = new TensorShape(new int[] { prod_axes, prod_free }); | |||
new_shape = new Shape(new int[] { prod_axes, prod_free }); | |||
else | |||
new_shape = new TensorShape(new int[] { prod_free, prod_axes }); | |||
new_shape = new Shape(new int[] { prod_free, prod_axes }); | |||
} | |||
throw new NotImplementedException("_tensordot_reshape"); | |||
@@ -25,11 +25,11 @@ namespace Tensorflow | |||
public static Tensor conv2d_transpose(Tensor value = null, | |||
IVariableV1 filter = null, | |||
Tensor output_shape = null, | |||
TensorShape strides = null, | |||
Shape strides = null, | |||
string padding = "SAME", | |||
string data_format = "NHWC", | |||
string name = null, | |||
TensorShape dilations = null) | |||
Shape dilations = null) | |||
{ | |||
if (dilations == null) | |||
dilations = (1, 1, 1, 1); | |||
@@ -186,7 +186,7 @@ namespace Tensorflow | |||
{ | |||
return tf_with(ops.name_scope("count_nonzero", "count_nonzero", new { input_tensor }), scope => | |||
{ | |||
var zero = array_ops.zeros(new Shape(), dtype: input_tensor.dtype); | |||
var zero = array_ops.zeros(Shape.Null, dtype: input_tensor.dtype); | |||
var nonzero_count = math_ops.reduce_sum( | |||
math_ops.cast(gen_math_ops.not_equal(input_tensor, zero), dtype: dtype), name: "nonzero_count"); | |||
return nonzero_count; | |||
@@ -200,7 +200,7 @@ namespace Tensorflow | |||
name = scope; | |||
logits = ops.convert_to_tensor(logits, name: "logits"); | |||
labels = ops.convert_to_tensor(labels, name: "labels"); | |||
labels.TensorShape.merge_with(logits.TensorShape); | |||
labels.shape.merge_with(logits.shape); | |||
var zeros = array_ops.zeros_like(logits, dtype: logits.dtype); | |||
var cond = (logits >= zeros); | |||
@@ -96,7 +96,7 @@ namespace Tensorflow | |||
var keep_mask = random_tensor >= rate; | |||
ret = x * scale * math_ops.cast(keep_mask, x.dtype); | |||
if (!tf.executing_eagerly()) | |||
ret.set_shape(x.TensorShape); | |||
ret.shape = x.shape; | |||
return ret; | |||
}); | |||
} | |||
@@ -203,14 +203,14 @@ namespace Tensorflow | |||
var precise_logits = logits.dtype == TF_DataType.TF_HALF ? math_ops.cast(logits, dtypes.float32) : logits; | |||
// Store label shape for result later. | |||
var labels_static_shape = labels.TensorShape; | |||
var labels_static_shape = labels.shape; | |||
var labels_shape = array_ops.shape(labels); | |||
/*bool static_shapes_fully_defined = ( | |||
labels_static_shape.is_fully_defined() && | |||
logits.get_shape()[:-1].is_fully_defined());*/ | |||
// Check if no reshapes are required. | |||
if (logits.TensorShape.ndim == 2) | |||
if (logits.shape.ndim == 2) | |||
{ | |||
var (cost, _) = gen_nn_ops.sparse_softmax_cross_entropy_with_logits( | |||
precise_logits, labels, name: name); | |||
@@ -236,7 +236,7 @@ namespace Tensorflow | |||
name = scope; | |||
var precise_logits = logits; | |||
var input_rank = array_ops.rank(precise_logits); | |||
var shape = logits.TensorShape; | |||
var shape = logits.shape; | |||
if (axis != -1) | |||
throw new NotImplementedException("softmax_cross_entropy_with_logits_v2_helper axis != -1"); | |||
@@ -282,7 +282,7 @@ namespace Tensorflow | |||
// Set output shape if known. | |||
if (!tf.Context.executing_eagerly()) | |||
{ | |||
var shape = logits.TensorShape; | |||
var shape = logits.shape; | |||
if (shape != null && shape.ndim > 0) | |||
{ | |||
var product = 1L; | |||
@@ -30,7 +30,7 @@ namespace Tensorflow | |||
/// <param name="seed"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public static Tensor random_normal(TensorShape shape, | |||
public static Tensor random_normal(Shape shape, | |||
float mean = 0.0f, | |||
float stddev = 1.0f, | |||
TF_DataType dtype = TF_DataType.TF_FLOAT, | |||
@@ -48,7 +48,7 @@ namespace Tensorflow | |||
/// <param name="name"></param> | |||
/// <param name="graph_mode"></param> | |||
/// <returns></returns> | |||
public static Tensor eager_safe_variable_handle(Tensor initial_value, TensorShape shape, | |||
public static Tensor eager_safe_variable_handle(Tensor initial_value, Shape shape, | |||
string shared_name, string name, bool graph_mode) | |||
{ | |||
var dtype = initial_value.dtype.as_base_dtype(); | |||
@@ -66,7 +66,7 @@ namespace Tensorflow | |||
/// <param name="graph_mode"></param> | |||
/// <param name="initial_value"></param> | |||
/// <returns></returns> | |||
public static Tensor variable_handle_from_shape_and_dtype(TensorShape shape, TF_DataType dtype, | |||
public static Tensor variable_handle_from_shape_and_dtype(Shape shape, TF_DataType dtype, | |||
string shared_name, string name, bool graph_mode, Tensor initial_value = null) | |||
{ | |||
var container = ops.get_default_graph().Container; | |||
@@ -161,7 +161,7 @@ namespace Tensorflow | |||
var data = new HandleData(); | |||
data.ShapeAndType.Add(new HandleShapeAndType | |||
{ | |||
Shape = handle.TensorShape.as_proto(), | |||
Shape = handle.shape.as_shape_proto(), | |||
Dtype = handle.dtype.as_datatype_enum() | |||
}); | |||
return data; | |||
@@ -96,9 +96,9 @@ namespace Tensorflow | |||
} | |||
}.SetAttributes(new { maxsplit })); | |||
var (indices, values, shape) = (result[0], result[1], result[2]); | |||
indices.set_shape(new TensorShape(-1, 2)); | |||
values.set_shape(new TensorShape(-1)); | |||
shape.set_shape(new TensorShape(2)); | |||
indices.shape = new Shape(-1, 2); | |||
values.shape = new Shape(-1); | |||
shape.shape = new Shape(2); | |||
var sparse_result = new SparseTensor(indices, values, shape); | |||
return RaggedTensor.from_value_rowids(sparse_result.values, | |||
@@ -29,10 +29,10 @@ namespace Tensorflow | |||
weights, dtype: values.dtype.as_base_dtype(), name: "weights"); | |||
// Try static check for exact match. | |||
var weights_shape = weights.TensorShape; | |||
var values_shape = values.TensorShape; | |||
if (weights_shape.is_fully_defined() && | |||
values_shape.is_fully_defined()) | |||
var weights_shape = weights.shape; | |||
var values_shape = values.shape; | |||
if (weights_shape.IsFullyDefined && | |||
values_shape.IsFullyDefined) | |||
return weights; | |||
return math_ops.multiply( | |||
@@ -34,13 +34,13 @@ namespace Tensorflow | |||
Tensor _row_splits => _row_partition.row_splits; | |||
public TF_DataType dtype => _values.dtype; | |||
public TensorShape shape | |||
public Shape shape | |||
{ | |||
get | |||
{ | |||
var nrows = _row_partition.static_nrows; | |||
var ncols = _row_partition.static_uniform_row_length; | |||
return new TensorShape(nrows, ncols); | |||
return new Shape(nrows, ncols); | |||
} | |||
} | |||
@@ -55,12 +55,12 @@ namespace Tensorflow | |||
void _init() | |||
{ | |||
var indices_shape = indices.TensorShape.with_rank(2); | |||
var values_shape = values.TensorShape.with_rank(1); | |||
var dense_shape_shape = dense_shape.TensorShape.with_rank(1); | |||
var indices_shape = indices.shape.with_rank(2); | |||
var values_shape = values.shape.with_rank(1); | |||
var dense_shape_shape = dense_shape.shape.with_rank(1); | |||
indices_shape["0"].merge_with(values_shape[0]); | |||
indices_shape["1"].merge_with(dense_shape_shape[0]); | |||
indices_shape["0"].merge_with(new Shape(values_shape[0])); | |||
indices_shape["1"].merge_with(new Shape(dense_shape_shape[0])); | |||
} | |||
public static implicit operator Tensor(SparseTensor indexedSlices) | |||
@@ -76,7 +76,7 @@ namespace Tensorflow | |||
public Tensor(ulong value) => InitTensor(new[] { value }, Shape.Scalar); | |||
public Tensor(float value) => InitTensor(new[] { value }, Shape.Scalar); | |||
public Tensor(double value) => InitTensor(new[] { value }, Shape.Scalar); | |||
public Tensor(string value) => InitTensor(new[] { value }, TensorShape.Scalar); | |||
public Tensor(string value) => InitTensor(new[] { value }, Shape.Scalar); | |||
#endregion | |||
#region 1d array | |||
@@ -116,7 +116,7 @@ namespace Tensorflow | |||
protected unsafe void InitTensor(byte[] bytes, TF_DataType dtype) | |||
{ | |||
if (dtype == TF_DataType.TF_STRING) | |||
_handle = StringTensor(new byte[][] { bytes }, TensorShape.Scalar); | |||
_handle = StringTensor(new byte[][] { bytes }, Shape.Scalar); | |||
else | |||
throw new NotImplementedException(""); | |||
isCreatedInGraphMode = !tf.executing_eagerly(); | |||
@@ -138,10 +138,10 @@ namespace Tensorflow | |||
if (tensor == null) | |||
throw new ArgumentNullException(nameof(tensor)); | |||
if (tensor.TensorShape.ndim != 0) | |||
if (tensor.shape.ndim != 0) | |||
throw new ArgumentException("Tensor must have 0 dimensions in order to convert to scalar"); | |||
if (tensor.TensorShape.size != 1) | |||
if (tensor.shape.size != 1) | |||
throw new ArgumentException("Tensor must have size 1 in order to convert to scalar"); | |||
} | |||
@@ -10,7 +10,7 @@ namespace Tensorflow | |||
{ | |||
const int TF_TSRING_SIZE = 24; | |||
public IntPtr StringTensor(string[] strings, TensorShape shape) | |||
public IntPtr StringTensor(string[] strings, Shape shape) | |||
{ | |||
// convert string array to byte[][] | |||
var buffer = new byte[strings.Length][]; | |||
@@ -20,7 +20,7 @@ namespace Tensorflow | |||
return StringTensor(buffer, shape); | |||
} | |||
public IntPtr StringTensor(byte[][] buffer, TensorShape shape) | |||
public IntPtr StringTensor(byte[][] buffer, Shape shape) | |||
{ | |||
var handle = c_api.TF_AllocateTensor(TF_DataType.TF_STRING, | |||
shape.ndim == 0 ? null : shape.dims, | |||
@@ -63,7 +63,7 @@ namespace Tensorflow | |||
// [offset1, offset2,...,offsetn, s1size, s1bytes, s2size, s2bytes,...,snsize,snbytes] | |||
// | |||
long size = 1; | |||
foreach (var s in TensorShape.dims) | |||
foreach (var s in shape.dims) | |||
size *= s; | |||
var buffer = new byte[size][]; | |||
@@ -111,7 +111,10 @@ namespace Tensorflow | |||
{ | |||
get | |||
{ | |||
var dims = new long[rank < 0 ? 0 : rank]; | |||
if (rank < 0) | |||
return Shape.Null; | |||
var dims = new Shape(new long[rank]); | |||
if (_handle == IntPtr.Zero) | |||
{ | |||
@@ -128,6 +131,13 @@ namespace Tensorflow | |||
set | |||
{ | |||
if (this is EagerTensor) | |||
{ | |||
if(!shape.is_compatible_with(value)) | |||
throw new ValueError($"Tensor's shape is not compatible."); | |||
return; | |||
} | |||
if (value == null) | |||
c_api.TF_GraphSetTensorShape(graph, _as_tf_output(), null, -1, tf.Status.Handle); | |||
else | |||
@@ -142,22 +152,12 @@ namespace Tensorflow | |||
return rank < 0 ? null : shape.dims.Select(x => (int)x).ToArray(); | |||
} | |||
public TensorShape TensorShape => rank < 0 ? new TensorShape() : shape; | |||
/// <summary> | |||
/// Keras History: (Layer, (node_index, tensor_index)) | |||
/// </summary> | |||
public KerasHistory KerasHistory { get; set; } | |||
public Tensor KerasMask { get; set; } | |||
/// <summary> | |||
/// Updates the shape of this tensor. | |||
/// </summary> | |||
public virtual void set_shape(TensorShape shape) | |||
{ | |||
this.shape = shape.rank >= 0 ? shape : null; | |||
} | |||
/// <summary> | |||
/// Updates the shape of this tensor. | |||
/// </summary> | |||
@@ -250,11 +250,11 @@ namespace Tensorflow | |||
switch (rank) | |||
{ | |||
case -1: | |||
return $"tf.Tensor '{name}' shape={TensorShape} dtype={dtype.as_numpy_name()}"; | |||
return $"tf.Tensor '{name}' shape={shape} dtype={dtype.as_numpy_name()}"; | |||
case 0: | |||
return $"tf.Tensor '{name}' shape={TensorShape} dtype={dtype.as_numpy_name()}"; | |||
return $"tf.Tensor '{name}' shape={shape} dtype={dtype.as_numpy_name()}"; | |||
default: | |||
return $"tf.Tensor '{name}' shape={TensorShape} dtype={dtype.as_numpy_name()}"; | |||
return $"tf.Tensor '{name}' shape={shape} dtype={dtype.as_numpy_name()}"; | |||
} | |||
} | |||
@@ -263,7 +263,7 @@ namespace Tensorflow | |||
if (dtype == TF_DataType.TF_STRING) | |||
{ | |||
long size = 1; | |||
foreach (var s in TensorShape.dims) | |||
foreach (var s in shape.dims) | |||
size *= s; | |||
var tstr = TensorDataPointer; | |||
@@ -37,7 +37,7 @@ namespace Tensorflow | |||
public TensorArray(TF_DataType dtype, Tensor size = default, bool? clear_after_read = null, bool? dynamic_size = null, | |||
string tensor_array_name = null, Tensor handle = null, Tensor flow = null, | |||
bool infer_shape = true, TensorShape element_shape = null, | |||
bool infer_shape = true, Shape element_shape = null, | |||
bool colocate_with_first_write_call = true, string name = null) | |||
{ | |||
_implementation = new _GraphTensorArray(dtype, | |||
@@ -1,47 +0,0 @@ | |||
using System.Linq; | |||
using Tensorflow.NumPy; | |||
namespace Tensorflow | |||
{ | |||
public partial class TensorShape | |||
{ | |||
public void Deconstruct(out long h, out long w) | |||
{ | |||
h = dims[0]; | |||
w = dims[1]; | |||
} | |||
public static implicit operator TensorShape(Shape shape) => new TensorShape((long[])shape.dims.Clone()); | |||
public static implicit operator Shape(TensorShape shape) => shape == null ? null : new Shape((long[])shape.dims.Clone()); | |||
public static implicit operator int[](TensorShape shape) => shape == null ? null : shape.dims.Select(x => (int)x).ToArray(); //we clone to avoid any changes | |||
public static implicit operator TensorShape(int[] dims) => dims == null ? null : new TensorShape(dims); | |||
public static implicit operator long[](TensorShape shape) => shape == null ? null : (long[])shape.dims.Clone(); //we clone to avoid any changes | |||
public static implicit operator TensorShape(long[] dims) => dims == null ? null : new TensorShape(dims); | |||
public static explicit operator long(TensorShape shape) => shape.size; | |||
public static implicit operator TensorShape(long dim) => new TensorShape(dim); | |||
public static explicit operator (long, long)(TensorShape shape) => shape.dims.Length == 2 ? (shape.dims[0], shape.dims[1]) : (0, 0); | |||
public static implicit operator TensorShape((long, long) dims) => new TensorShape(dims.Item1, dims.Item2); | |||
public static explicit operator (long, long, long)(TensorShape shape) => shape.dims.Length == 3 ? (shape.dims[0], shape.dims[1], shape.dims[2]) : (0, 0, 0); | |||
public static implicit operator TensorShape((long, long, long) dims) => new TensorShape(dims.Item1, dims.Item2, dims.Item3); | |||
public static explicit operator (long, long, long, long)(TensorShape shape) => shape.dims.Length == 4 ? (shape.dims[0], shape.dims[1], shape.dims[2], shape.dims[3]) : (0, 0, 0, 0); | |||
public static implicit operator TensorShape((long, long, long, long) dims) => new TensorShape(dims.Item1, dims.Item2, dims.Item3, dims.Item4); | |||
public static explicit operator (long, long, long, long, long)(TensorShape shape) => shape.dims.Length == 5 ? (shape.dims[0], shape.dims[1], shape.dims[2], shape.dims[3], shape.dims[4]) : (0, 0, 0, 0, 0); | |||
public static implicit operator TensorShape((long, long, long, long, long) dims) => new TensorShape(dims.Item1, dims.Item2, dims.Item3, dims.Item4, dims.Item5); | |||
public static explicit operator (long, long, long, long, long, long)(TensorShape shape) => shape.dims.Length == 6 ? (shape.dims[0], shape.dims[1], shape.dims[2], shape.dims[3], shape.dims[4], shape.dims[5]) : (0, 0, 0, 0, 0, 0); | |||
public static implicit operator TensorShape((long, long, long, long, long, long) dims) => new TensorShape(dims.Item1, dims.Item2, dims.Item3, dims.Item4, dims.Item5, dims.Item6); | |||
public static explicit operator (long, long, long, long, long, long, long)(TensorShape shape) => shape.dims.Length == 7 ? (shape.dims[0], shape.dims[1], shape.dims[2], shape.dims[3], shape.dims[4], shape.dims[5], shape.dims[6]) : (0, 0, 0, 0, 0, 0, 0); | |||
public static implicit operator TensorShape((long, long, long, long, long, long, long) dims) => new TensorShape(dims.Item1, dims.Item2, dims.Item3, dims.Item4, dims.Item5, dims.Item6, dims.Item7); | |||
public static explicit operator (long, long, long, long, long, long, long, long)(TensorShape shape) => shape.dims.Length == 8 ? (shape.dims[0], shape.dims[1], shape.dims[2], shape.dims[3], shape.dims[4], shape.dims[5], shape.dims[6], shape.dims[7]) : (0, 0, 0, 0, 0, 0, 0, 0); | |||
public static implicit operator TensorShape((long, long, long, long, long, long, long, long) dims) => new TensorShape(dims.Item1, dims.Item2, dims.Item3, dims.Item4, dims.Item5, dims.Item6, dims.Item7, dims.Item8); | |||
} | |||
} |
@@ -1,37 +0,0 @@ | |||
using System; | |||
using System.Linq; | |||
namespace Tensorflow | |||
{ | |||
public partial class TensorShape | |||
{ | |||
public override bool Equals(Object obj) | |||
{ | |||
switch (obj) | |||
{ | |||
case TensorShape shape1: | |||
if (rank == -1 && shape1.rank == -1) | |||
return false; | |||
else if (rank != shape1.rank) | |||
return false; | |||
return Enumerable.SequenceEqual(shape1.dims, dims); | |||
case long[] shape2: | |||
if (rank != shape2.Length) | |||
return false; | |||
return Enumerable.SequenceEqual(dims, shape2); | |||
default: | |||
return false; | |||
} | |||
} | |||
/*public static bool operator ==(TensorShape shape1, TensorShape shape2) | |||
{ | |||
return false; | |||
} | |||
public static bool operator !=(TensorShape shape1, TensorShape shape2) | |||
{ | |||
return false; | |||
}*/ | |||
} | |||
} |
@@ -1,306 +0,0 @@ | |||
using Tensorflow.NumPy; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Diagnostics.CodeAnalysis; | |||
using System.Linq; | |||
using System.Runtime.CompilerServices; | |||
using static Tensorflow.Binding; | |||
namespace Tensorflow | |||
{ | |||
/// <summary> | |||
/// Represents the shape of a `Tensor`. | |||
/// </summary> | |||
/// <remarks>https://www.tensorflow.org/api_docs/python/tf/TensorShape</remarks> | |||
public partial class TensorShape | |||
{ | |||
private readonly Shape shape; | |||
/// <summary> | |||
/// Returns a list of Dimensions, or None if the shape is unspecified. | |||
/// </summary> | |||
public long[] dims => shape.dims; | |||
/// <summary> | |||
/// Returns the rank of this shape. | |||
/// </summary> | |||
public int ndim => rank; | |||
private int _rank; | |||
/// <summary> | |||
/// Returns the rank of this shape. | |||
/// </summary> | |||
public int rank => _rank > -1 ? shape.ndim : -1; | |||
/// <summary> | |||
/// Returns the size this shape represents. | |||
/// </summary> | |||
public long size | |||
{ | |||
get | |||
{ | |||
var dims = shape.dims; | |||
var computed = 1L; | |||
for (int i = 0; i < dims.Length; i++) | |||
{ | |||
var val = dims[i]; | |||
if (val <= 0) | |||
continue; | |||
computed *= val; | |||
} | |||
return computed; | |||
} | |||
} | |||
public TensorShape() | |||
{ | |||
_rank = -1; | |||
shape = new Shape(); | |||
} | |||
public static TensorShape Scalar | |||
=> new TensorShape(new long[0]); | |||
public TensorShape(TensorShapeProto proto) | |||
{ | |||
if (proto.UnknownRank) return; | |||
switch (proto.Dim.Count) | |||
{ | |||
case 0: shape = new Shape(new long[0]); | |||
break; | |||
default: | |||
var protodims = proto.Dim; | |||
var len = protodims.Count; | |||
var dims = new long[len]; | |||
for (int i = 0; i < len; i++) | |||
dims[i] = protodims[i].Size; | |||
shape = new Shape(dims); | |||
break; | |||
} | |||
} | |||
public TensorShape(params int[] dims) | |||
{ | |||
switch (dims.Length) | |||
{ | |||
case 0: | |||
shape = new Shape(new long[0]); | |||
break; | |||
default: | |||
shape = new Shape(dims.Select(x => Convert.ToInt64(x)).ToArray()); | |||
break; | |||
} | |||
} | |||
public TensorShape(params long[] dims) | |||
{ | |||
switch (dims.Length) | |||
{ | |||
case 0: shape = new Shape(new long[0]); | |||
break; | |||
default: shape = new Shape(dims); | |||
break; | |||
} | |||
} | |||
public TensorShape(long[][] dims) | |||
{ | |||
if (dims.Length == 1) | |||
{ | |||
switch (dims[0].Length) | |||
{ | |||
case 0: shape = new Shape(new long[0]); | |||
break; | |||
default: shape = new Shape(dims[0]); | |||
break; | |||
} | |||
} | |||
else | |||
{ | |||
throw new NotImplementedException("TensorShape int[][] dims"); | |||
} | |||
} | |||
/// <summary> | |||
/// | |||
/// </summary> | |||
/// <param name="slice"></param> | |||
/// <returns></returns> | |||
/// <exception cref="ArgumentException">When <see cref="Slice"/> is not an Index.</exception> | |||
[SuppressMessage("ReSharper", "PossibleInvalidOperationException")] | |||
public TensorShape this[Slice slice] | |||
{ | |||
get | |||
{ | |||
if (!slice.Stop.HasValue) | |||
slice.Stop = dims.Length - slice.Start + 1; | |||
if (slice.Start.HasValue == false || slice.Length.HasValue == false) | |||
throw new ArgumentException("Slice must has Start and Length."); | |||
return new TensorShape(dims.Skip(slice.Start.Value) | |||
.Take(slice.Length.Value) | |||
.ToArray()); | |||
} | |||
} | |||
public long this[int index] => index < 0 ? dims[ndim + index] : dims[index]; | |||
/// <summary> | |||
/// Returns True iff `self` is fully defined in every dimension. | |||
/// </summary> | |||
/// <returns></returns> | |||
public bool is_fully_defined() | |||
{ | |||
return rank > -1 && dims != null && dims.Count(x => x < 1) == 0; | |||
} | |||
public bool is_compatible_with(TensorShape shape2) | |||
{ | |||
if (dims != null && shape2.dims != null) | |||
{ | |||
if (dims.Contains(-1) || shape2.dims.Contains(-1)) | |||
return true; | |||
if (shape.size != (ulong)shape2.size) | |||
return false; | |||
} | |||
return true; | |||
} | |||
public void assert_has_rank(int rank) | |||
{ | |||
if (rank != ndim) | |||
throw new ValueError(String.Format("Shape {0} must have rank {1}", ndim, rank)); | |||
} | |||
[SuppressMessage("ReSharper", "ParameterHidesMember")] | |||
public TensorShape with_rank_at_least(int rank) | |||
{ | |||
if (ndim < rank) | |||
throw new ValueError($"Shape {this} must have rank at least {rank}"); | |||
else | |||
return this; | |||
} | |||
public TensorShape with_rank(int rank) | |||
{ | |||
return merge_with(unknown_shape(rank: rank)); | |||
} | |||
/// <summary> | |||
/// Returns an unknown TensorShape, optionally with a known rank. | |||
/// </summary> | |||
/// <param name="rank"></param> | |||
/// <returns></returns> | |||
public TensorShape unknown_shape(int rank = -1) | |||
{ | |||
if (rank == -1) | |||
return new TensorShape(-1); | |||
else | |||
return new TensorShape(Enumerable.Repeat(-1L, rank).ToArray()); | |||
} | |||
/// <summary> | |||
/// Returns the concatenation of the dimension in `self` and `other`. | |||
/// </summary> | |||
/// <param name="other"></param> | |||
/// <returns></returns> | |||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |||
public TensorShape concatenate(long[] other) | |||
{ | |||
return concatenate(new TensorShape(other)); | |||
} | |||
/// <summary> | |||
/// Returns the concatenation of the dimension in `self` and `other`. | |||
/// </summary> | |||
/// <param name="other"></param> | |||
/// <returns></returns> | |||
public TensorShape concatenate(TensorShape other) | |||
{ | |||
var otherShape = other; | |||
if (ndim < 0 || otherShape.ndim < 0) | |||
return new TensorShape(); | |||
else | |||
{ | |||
var concatenate_dims = new long[ndim + otherShape.ndim]; | |||
for (int i = 0; i < ndim; i++) | |||
concatenate_dims[i] = dims[i]; | |||
for (int i = 0; i < otherShape.ndim; i++) | |||
concatenate_dims[ndim + i] = otherShape.dims[i]; | |||
return new TensorShape(concatenate_dims); | |||
} | |||
} | |||
/// <summary> | |||
/// Returns a `TensorShape` combining the information in `self` and `other`. | |||
/// </summary> | |||
/// <param name="other"></param> | |||
/// <returns></returns> | |||
public TensorShape merge_with(TensorShape other) | |||
{ | |||
if (dims == null) | |||
return other; | |||
var new_dims = new List<long>(); | |||
foreach (var i in range(ndim)) | |||
{ | |||
var dim = new Dimension(dims[i]); | |||
var merged = dim.merge_with(new Dimension(other.dims[i])); | |||
new_dims.Add(merged.value); | |||
} | |||
return new TensorShape(new_dims.ToArray()); | |||
} | |||
/// <summary> | |||
/// Returns a cloned array from <see cref="dims"/>. | |||
/// </summary> | |||
public long[] as_list() | |||
{ | |||
if (shape.IsEmpty) | |||
throw new ValueError("as_list() is not defined on an unknown TensorShape."); | |||
return (long[])dims.Clone(); | |||
} | |||
public long[] as_list_long() | |||
{ | |||
if (shape.IsEmpty) | |||
throw new ValueError("as_list() is not defined on an unknown TensorShape."); | |||
return dims.Select(x => Convert.ToInt64(x)).ToArray(); | |||
} | |||
public long num_elements() | |||
{ | |||
if (is_fully_defined()) | |||
{ | |||
var size = 1L; | |||
foreach (var dim in dims) | |||
size *= dim; | |||
return size; | |||
} | |||
return -1; | |||
} | |||
public override string ToString() | |||
{ | |||
switch (rank) | |||
{ | |||
case -1: | |||
return $"<unknown>"; | |||
case 0: | |||
return $"()"; | |||
default: | |||
return $"{string.Join(",", shape).Replace("-1", "None")}"; | |||
} | |||
} | |||
} | |||
} |
@@ -18,7 +18,7 @@ namespace Tensorflow | |||
List<Tensor> items = new List<Tensor>(); | |||
public TF_DataType dtype => items.First().dtype; | |||
public TensorShape shape => items.First().TensorShape; | |||
public Shape shape => items.First().shape; | |||
public int rank => items.First().rank; | |||
public Graph graph => items.First().graph; | |||
public bool IsCreatedInGraphMode => items.First().IsCreatedInGraphMode; | |||