Browse Source

tf.ones_like, tf.not_equal, tf.floordiv, tf.zeros_like, tf.truediv, tf.add_n, tf.reduced_all, tf.dynamic_stitch

tags/v0.12
Oceania2018 6 years ago
parent
commit
acb55057bc
3 changed files with 108 additions and 0 deletions
  1. +25
    -0
      src/TensorFlowNET.Core/APIs/tf.array.cs
  2. +33
    -0
      src/TensorFlowNET.Core/APIs/tf.data_flow.cs
  3. +50
    -0
      src/TensorFlowNET.Core/APIs/tf.math.cs

+ 25
- 0
src/TensorFlowNET.Core/APIs/tf.array.cs View File

@@ -128,6 +128,20 @@ namespace Tensorflow
public Tensor stack(object values, int axis = 0, string name = "stack")
=> array_ops.stack(values, axis, name: name);

/// <summary>
/// Creates a tensor with all elements set to 1.
/// </summary>
/// <param name="tensor"></param>
/// <param name="dtype"></param>
/// <param name="name">A name for the operation (optional).</param>
/// <param name="optimize">
/// if true, attempt to statically determine the shape of 'tensor' and
/// encode it as a constant.
/// </param>
/// <returns>A `Tensor` with all elements set to 1.</returns>
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,
@@ -191,5 +205,16 @@ namespace Tensorflow
/// <returns></returns>
public Tensor[] unstack(Tensor value, int? num = null, int axis = 0, string name = "unstack")
=> array_ops.unstack(value, num: num, axis: axis, name: name);

/// <summary>
/// Creates a tensor with all elements set to zero.
/// </summary>
/// <param name="tensor"></param>
/// <param name="dtype"></param>
/// <param name="name"></param>
/// <param name="optimize"></param>
/// <returns>A `Tensor` with all elements set to zero.</returns>
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);
}
}

+ 33
- 0
src/TensorFlowNET.Core/APIs/tf.data_flow.cs View File

@@ -0,0 +1,33 @@
/*****************************************************************************
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 System;

namespace Tensorflow
{
public partial class tensorflow
{
/// <summary>
/// Interleave the values from the data tensors into a single tensor.
/// </summary>
/// <param name="indices"></param>
/// <param name="data"></param>
/// <param name="name"></param>
/// <returns></returns>
public static Tensor dynamic_stitch(Tensor[] indices, Tensor[] data, string name = null)
=> gen_data_flow_ops.dynamic_stitch(indices, data, name: name);
}
}

+ 50
- 0
src/TensorFlowNET.Core/APIs/tf.math.cs View File

@@ -44,6 +44,15 @@ namespace Tensorflow
public Tensor add<Tx, Ty>(Tx a, Ty b, string name = null)
=> gen_math_ops.add(a, b, name: name);

/// <summary>
/// Adds all input tensors element-wise.
/// </summary>
/// <param name="inputs"></param>
/// <param name="name"></param>
/// <returns>A `Tensor` of same shape and type as the elements of `inputs`.</returns>
public Tensor add_n(Tensor[] inputs, string name = null)
=> math_ops.add_n(inputs, name: name);

/// <summary>
/// Computes atan of x element-wise.
/// </summary>
@@ -331,6 +340,16 @@ namespace Tensorflow
public Tensor negative(Tensor x, string name = null)
=> gen_math_ops.neg(x, name);

/// <summary>
/// Returns the truth value of (x != y) element-wise.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="name"></param>
/// <returns>A `Tensor` of type bool with the same size as that of x or y.</returns>
public Tensor not_equal<Tx, Ty>(Tx x, Ty y, string name = null)
=> math_ops.not_equal(x, y, name: name);

/// <summary>
/// Divides x / y elementwise (using Python 2 division operator semantics).
/// </summary>
@@ -347,9 +366,40 @@ namespace Tensorflow
public Tensor pow<T1, T2>(T1 x, T2 y)
=> gen_math_ops.pow(x, y);

/// <summary>
/// Divides `x / y` elementwise, rounding toward the most negative integer.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="name"></param>
/// <returns>`x / y` rounded down.</returns>
public Tensor floordiv(Tensor x, Tensor y, string name = null)
=> math_ops.floordiv(x, y, name: name);

/// <summary>
/// Divides x / y elementwise (using Python 3 division operator semantics).
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="name"></param>
/// <returns>`x / y` evaluated in floating point.</returns>
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")
=> math_ops.range(start, limit: limit, delta: delta, dtype: dtype, name: name);

/// <summary>
/// Computes the "logical and" of elements across dimensions of a tensor.
/// </summary>
/// <param name="input_tensor"></param>
/// <param name="axis"></param>
/// <param name="keepdims"></param>
/// <param name="name"></param>
/// <returns>The reduced tensor.</returns>
public Tensor reduce_all(Tensor input_tensor, int[] axis = null, bool keepdims = false, string name = null)
=> math_ops.reduce_all(input_tensor, axis: axis, keepdims: keepdims, name: name);

/// <summary>
/// Computes the sum of elements across dimensions of a tensor.
/// </summary>


Loading…
Cancel
Save