/*****************************************************************************
Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
using NumSharp;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Tensorflow
{
public partial class tensorflow
{
///
/// A convenient alias for None, useful for indexing arrays.
///
public Slice newaxis = Slice.NewAxis;
///
/// BatchToSpace for N-D tensors of type T.
///
///
///
///
///
///
///
public Tensor batch_to_space_nd(T input, int[] block_shape, int[,] crops, string name = null)
=> gen_array_ops.batch_to_space_nd(input, block_shape, crops, name: name);
///
/// Apply boolean mask to tensor.
///
///
///
/// N-D tensor.
/// K-D boolean tensor, K <= N and K must be known statically.
///
/// A 0-D int Tensor representing the axis in tensor to mask from.
/// (N-K+1)-dimensional tensor populated by entries in tensor corresponding to True values in mask.
public Tensor boolean_mask(T1 tensor, T2 mask, string name = "boolean_mask", int axis = 0)
=> array_ops.boolean_mask(tensor, mask, name: name, axis: axis);
public Tensor check_numerics(Tensor tensor, string message, string name = null)
=> gen_array_ops.check_numerics(tensor, message, name: name);
///
/// Concatenates tensors along one dimension.
///
/// A list of `Tensor` objects or a single `Tensor`.
///
///
/// A `Tensor` resulting from concatenation of the input tensors.
public Tensor concat(IList values, int axis, string name = "concat")
{
if (values.Count == 1)
throw new NotImplementedException("tf.concat length is 1");
return gen_array_ops.concat_v2(values.ToArray(), axis, name: name);
}
///
/// Inserts a dimension of 1 into a tensor's shape.
///
///
///
///
///
///
/// A `Tensor` with the same data as `input`, but its shape has an additional
/// dimension of size 1 added.
///
public Tensor expand_dims(Tensor input, int axis = -1, string name = null, int dim = -1)
=> array_ops.expand_dims(input, axis, name, dim);
///
/// Creates a tensor filled with a scalar value.
///
///
///
///
///
public Tensor fill(Tensor dims, T value, string name = null)
=> gen_array_ops.fill(dims, value, name: name);
///
/// Return a tensor with the same shape and contents as input.
///
///
///
///
public static Tensor identity(Tensor input, string name = null)
=> array_ops.identity(input, name: name);
///
/// Gather slices from params axis axis according to indices.
///
///
///
///
///
///
public Tensor gather(Tensor @params, Tensor indices, string name = null, int axis = 0)
=> array_ops.gather(@params, indices, name: name, axis: axis);
///
/// Return the elements, either from `x` or `y`, depending on the `condition`.
///
///
public Tensor where(Tensor condition, Tx x, Ty y, string name = null)
=> array_ops.where(condition, x, y, name);
///
/// Transposes `a`. Permutes the dimensions according to `perm`.
///
///
///
///
///
///
public Tensor transpose(T1 a, int[] perm = null, string name = "transpose", bool conjugate = false)
=> array_ops.transpose(a, perm, name, conjugate);
///
/// Reverses specific dimensions of a tensor.
///
///
///
///
///
public static Tensor reverse(Tensor tensor, int[] axis, string name = null)
=> gen_array_ops.reverse(tensor, axis, name: name);
public static Tensor reverse(Tensor tensor, Tensor axis, string name = null)
=> gen_array_ops.reverse(tensor, axis, name: name);
///
/// Returns the rank of a tensor.
///
///
///
/// Returns a 0-D `int32` `Tensor` representing the rank of `input`.
public Tensor rank(Tensor input, string name = null)
=> array_ops.rank(input, name: name);
///
/// Extracts a slice from a tensor.
///
/// A `Tensor`.
/// An `int32` or `int64` `Tensor`.
/// An `int32` or `int64` `Tensor`.
/// A name for the operation (optional).
/// A `Tensor` the same type as `input`.
public Tensor slice(Tensor input, Tb[] begin, Ts[] size, string name = null)
=> array_ops.slice(input, begin, size, name: name);
public Tensor squeeze(Tensor input, int[] axis = null, string name = null, int squeeze_dims = -1)
=> gen_array_ops.squeeze(input, axis, name);
///
/// Stacks a list of rank-`R` tensors into one rank-`(R+1)` tensor.
///
///
///
///
///
public Tensor stack(object values, int axis = 0, string name = "stack")
=> array_ops.stack(values, axis, name: name);
///
/// Creates a tensor with all elements set to 1.
///
///
///
/// A name for the operation (optional).
///
/// if true, attempt to statically determine the shape of 'tensor' and
/// encode it as a constant.
///
/// A `Tensor` with all elements set to 1.
public Tensor ones_like(Tensor tensor, TF_DataType dtype = TF_DataType.DtInvalid, string name = null, bool optimize = true)
=> array_ops.ones_like(tensor, dtype: dtype, name: name, optimize: optimize);
public Tensor one_hot(Tensor indices, int depth,
Tensor on_value = null,
Tensor off_value = null,
TF_DataType dtype = TF_DataType.DtInvalid,
int axis = -1,
string name = null) => array_ops.one_hot(indices, depth, dtype: dtype, axis: axis, name: name);
///
/// Pads a tensor
///
///
///
///
///
///
///
public Tensor pad(Tensor tensor, Tensor paddings, string mode = "CONSTANT", string name = null, int constant_values = 0)
=> array_ops.pad(tensor, paddings, mode: mode, name: name, constant_values: constant_values);
///
/// A placeholder op that passes through `input` when its output is not fed.
///
///
/// A `Tensor`. The default value to produce when output is not fed.
///
/// A `tf.TensorShape` or list of `int`s. The (possibly partial) shape of
/// the tensor.
///
/// A name for the operation (optional).
/// A `Tensor`. Has the same type as `input`.
public Tensor placeholder_with_default(T input, int[] shape, string name = null)
=> gen_array_ops.placeholder_with_default(input, shape, name: name);
///
/// Returns the shape of a tensor.
///
///
///
///
///
public Tensor shape(Tensor input, string name = null, TF_DataType out_type = TF_DataType.TF_INT32)
=> array_ops.shape_internal(input, name, optimize: true, out_type: out_type);
///
/// Stacks a list of rank-`R` tensors into one rank-`(R+1)` tensor.
///
///
///
///
/// A stacked `Tensor` with the same type as `values`.
public Tensor stack(Tensor[] values, int axis = 0, string name = "stack")
=> array_ops.stack(values, axis: axis, name: name);
///
/// Unpacks the given dimension of a rank-`R` tensor into rank-`(R-1)` tensors.
///
///
///
///
///
///
public Tensor[] unstack(Tensor value, int? num = null, int axis = 0, string name = "unstack")
=> array_ops.unstack(value, num: num, axis: axis, name: name);
///
/// Creates a tensor with all elements set to zero.
///
///
///
///
///
/// A `Tensor` with all elements set to zero.
public Tensor zeros_like(Tensor tensor, TF_DataType dtype = TF_DataType.DtInvalid, string name = null, bool optimize = true)
=> array_ops.zeros_like(tensor, dtype: dtype, name: name, optimize: optimize);
}
}