Browse Source

logical_and

tags/v0.60-tf.numpy
Oceania2018 4 years ago
parent
commit
83151d2b36
11 changed files with 89 additions and 23 deletions
  1. +1
    -4
      src/TensorFlowNET.Core/APIs/tf.math.cs
  2. +3
    -0
      src/TensorFlowNET.Core/NumPy/Axis.cs
  3. +2
    -0
      src/TensorFlowNET.Core/NumPy/NDArray.Operators.cs
  4. +18
    -0
      src/TensorFlowNET.Core/NumPy/NumPy.Logical.cs
  5. +20
    -0
      src/TensorFlowNET.Core/NumPy/NumPy.Sorting.Searching.Counting.cs
  6. +18
    -0
      src/TensorFlowNET.Core/NumPy/NumPy.Statistics.cs
  7. +3
    -0
      src/TensorFlowNET.Core/NumPy/Numpy.Manipulation.cs
  8. +14
    -2
      src/TensorFlowNET.Core/NumPy/Numpy.Math.cs
  9. +3
    -0
      src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs
  10. +2
    -5
      src/TensorFlowNET.Core/Operations/gen_math_ops.cs
  11. +5
    -12
      src/TensorFlowNET.Core/Operations/math_ops.cs

+ 1
- 4
src/TensorFlowNET.Core/APIs/tf.math.cs View File

@@ -245,10 +245,7 @@ namespace Tensorflow
public Tensor log1p(Tensor x, string name = null)
=> gen_math_ops.log1p(x, name);

public Tensor logical_and(Tensor x, Tensor y, string name = null)
=> gen_math_ops.logical_and(x, y, name);

public Tensor logical_and(bool x, bool y, string name = null)
public Tensor logical_and<T>(T x, T y, string name = null)
=> gen_math_ops.logical_and(x, y, name);

public Tensor logical_not(Tensor x, string name = null)


+ 3
- 0
src/TensorFlowNET.Core/NumPy/Axis.cs View File

@@ -30,6 +30,9 @@ namespace Tensorflow
public static implicit operator int[]?(Axis axis)
=> axis?.axis;

public static implicit operator int(Axis axis)
=> axis.axis[0];

public static implicit operator Axis(int axis)
=> new Axis(axis);



+ 2
- 0
src/TensorFlowNET.Core/NumPy/NDArray.Operators.cs View File

@@ -12,5 +12,7 @@ namespace Tensorflow.NumPy
public static NDArray operator -(NDArray lhs, NDArray rhs) => lhs.Tensor - rhs.Tensor;
public static NDArray operator *(NDArray lhs, NDArray rhs) => lhs.Tensor * rhs.Tensor;
public static NDArray operator /(NDArray lhs, NDArray rhs) => lhs.Tensor / rhs.Tensor;
public static NDArray operator >(NDArray lhs, NDArray rhs) => lhs.Tensor > rhs.Tensor;
public static NDArray operator <(NDArray lhs, NDArray rhs) => lhs.Tensor < rhs.Tensor;
}
}

+ 18
- 0
src/TensorFlowNET.Core/NumPy/NumPy.Logical.cs View File

@@ -0,0 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using static Tensorflow.Binding;

namespace Tensorflow.NumPy
{
public partial class np
{
public static NDArray logical_or(NDArray x1, NDArray x2)
=> tf.logical_or(x1, x2);

public static NDArray logical_and(NDArray x1, NDArray x2)
=> tf.logical_and(x1, x2);
}
}

+ 20
- 0
src/TensorFlowNET.Core/NumPy/NumPy.Sorting.Searching.Counting.cs View File

@@ -0,0 +1,20 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Text;

namespace Tensorflow.NumPy
{
public partial class np
{
public static NDArray argmax(NDArray a, Axis axis = null)
=> new NDArray(math_ops.argmax(a, axis));

public static NDArray argsort(NDArray a, Axis axis = null)
=> new NDArray(math_ops.argmax(a, axis ?? -1));

public static NDArray unique(NDArray a)
=> throw new NotImplementedException("");
}
}

+ 18
- 0
src/TensorFlowNET.Core/NumPy/NumPy.Statistics.cs View File

@@ -0,0 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using static Tensorflow.Binding;

namespace Tensorflow.NumPy
{
public partial class np
{
public static NDArray amin(NDArray x, int axis = 0)
=> tf.arg_min(x, axis);

public static NDArray amax(NDArray x, int axis = 0)
=> tf.arg_max(x, axis);
}
}

+ 3
- 0
src/TensorFlowNET.Core/NumPy/Numpy.Manipulation.cs View File

@@ -8,6 +8,9 @@ namespace Tensorflow.NumPy
{
public partial class np
{
public static NDArray reshape(NDArray x1, Shape newshape)
=> x1.reshape(newshape);

public static NDArray squeeze(NDArray x1, Axis? axis = null)
=> new NDArray(array_ops.squeeze(x1, axis));
}


+ 14
- 2
src/TensorFlowNET.Core/NumPy/Numpy.Math.cs View File

@@ -9,17 +9,29 @@ namespace Tensorflow.NumPy
{
public partial class np
{
public static NDArray exp(NDArray x)
=> tf.exp(x);

public static NDArray log(NDArray x)
=> tf.log(x);

public static NDArray multiply(NDArray x1, NDArray x2)
=> tf.multiply(x1, x2);

public static NDArray maximum(NDArray x1, NDArray x2)
=> tf.maximum(x1, x2);

public static NDArray minimum(NDArray x1, NDArray x2)
=> tf.minimum(x1, x2);

public static NDArray prod(NDArray array, Axis? axis = null, Type? dtype = null, bool keepdims = false)
=> tf.reduce_prod(array, axis: axis);

public static NDArray prod<T>(params T[] array) where T : unmanaged
=> tf.reduce_prod(ops.convert_to_tensor(array));

public static NDArray multiply(NDArray x1, NDArray x2)
=> tf.multiply(x1, x2);
public static NDArray sqrt(NDArray x)
=> tf.sqrt(x);

public static NDArray sum(NDArray x1, Axis? axis = null)
=> tf.math.sum(x1, axis);


+ 3
- 0
src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs View File

@@ -46,6 +46,9 @@ namespace Tensorflow.NumPy
public static (NDArray, NDArray) meshgrid<T>(T x, T y, bool copy = true, bool sparse = false)
=> tf.numpy.meshgrid(new[] { x, y }, copy: copy, sparse: sparse);

public static NDArray ndarray(Shape shape, TF_DataType dtype = TF_DataType.TF_DOUBLE)
=> new NDArray(tf.zeros(shape, dtype: dtype));

public static NDArray ones(Shape shape, TF_DataType dtype = TF_DataType.TF_DOUBLE)
=> new NDArray(tf.ones(shape, dtype: dtype));



+ 2
- 5
src/TensorFlowNET.Core/Operations/gen_math_ops.cs View File

@@ -50,7 +50,7 @@ namespace Tensorflow
/// <param name="output_type"></param>
/// <param name="name"></param>
/// <returns></returns>
public static Tensor arg_max(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null)
public static Tensor arg_max(Tensor input, Axis dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null)
=> tf.Context.ExecuteOp("ArgMax", name, new ExecuteOpArgs(input, dimension)
.SetAttributes(new { output_type }));

@@ -308,10 +308,7 @@ namespace Tensorflow
public static Tensor log1p(Tensor x, string name = null)
=> tf.Context.ExecuteOp("Log1p", name, new ExecuteOpArgs(x));

public static Tensor logical_and(Tensor x, Tensor y, string name = null)
=> tf.Context.ExecuteOp("LogicalAnd", name, new ExecuteOpArgs(x, y));

public static Tensor logical_and(bool x, bool y, string name = null)
public static Tensor logical_and<T>(T x, T y, string name = null)
=> tf.Context.ExecuteOp("LogicalAnd", name, new ExecuteOpArgs(x, y));

public static Tensor logical_not(Tensor x, string name = null)


+ 5
- 12
src/TensorFlowNET.Core/Operations/math_ops.cs View File

@@ -71,7 +71,7 @@ namespace Tensorflow
return gen_math_ops.add_n(inputs, name: name);
}

public static Tensor argmax(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null)
public static Tensor argmax(Tensor input, Axis dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null)
=> gen_math_ops.arg_max(input, dimension, output_type: output_type, name: name);

public static Tensor round(Tensor x, string name = null)
@@ -545,7 +545,7 @@ namespace Tensorflow
/// dimensions.Must be in the range `[-rank(input_tensor), rank(input_tensor))`.</param>
/// <param name="keepdims"></param>
/// <returns> The reduced tensor.</returns>
public static Tensor reduce_logsumexp(Tensor input_tensor, Axis? axis = null, bool keepdims = false, string name = null)
public static Tensor reduce_logsumexp(Tensor input_tensor, Axis axis = null, bool keepdims = false, string name = null)
{
return tf_with(ops.name_scope(name, "ReduceLogSumExp", new { input_tensor }), scope =>
{
@@ -565,7 +565,7 @@ namespace Tensorflow
});
}

public static Tensor reduce_any(Tensor input_tensor, Axis? axis = null, bool keepdims = false, string name = null)
public static Tensor reduce_any(Tensor input_tensor, Axis axis = null, bool keepdims = false, string name = null)
{
var r = _ReductionDims(input_tensor, axis);
var max = (axis != null) ? gen_math_ops._any(input_tensor, axis, keepdims, name) :
@@ -573,7 +573,7 @@ namespace Tensorflow
return _may_reduce_to_scalar(keepdims, axis, max);
}

public static Tensor reduce_max(Tensor input_tensor, Axis? axis = null, bool keepdims = false, string name = null)
public static Tensor reduce_max(Tensor input_tensor, Axis axis = null, bool keepdims = false, string name = null)
{
var r = _ReductionDims(input_tensor, axis);
var max = (axis != null) ? gen_math_ops._max(input_tensor, axis, keepdims, name) :
@@ -581,14 +581,7 @@ namespace Tensorflow
return _may_reduce_to_scalar(keepdims, axis, max);
}

public static Tensor reduce_max(Tensor input_tensor, int axis, bool keepdims = false, string name = null)
{
var r = _ReductionDims(input_tensor, axis);
var max = gen_math_ops._max(input_tensor, r, keepdims, name);
return _may_reduce_to_scalar(keepdims, axis, max);
}

public static Tensor reduce_min(Tensor input_tensor, Axis? axis = null, bool keepdims = false, string name = null)
public static Tensor reduce_min(Tensor input_tensor, Axis axis = null, bool keepdims = false, string name = null)
{
var r = _ReductionDims(input_tensor, axis);
var min = gen_math_ops._min(input_tensor, r, keepdims, name);


Loading…
Cancel
Save