Skip to content

Commit 83151d2

Browse files
committed
logical_and
1 parent f32314e commit 83151d2

File tree

11 files changed

+89
-23
lines changed

11 files changed

+89
-23
lines changed

src/TensorFlowNET.Core/APIs/tf.math.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,7 @@ public Tensor less_equal<Tx, Ty>(Tx x, Ty y, string name = null)
245245
public Tensor log1p(Tensor x, string name = null)
246246
=> gen_math_ops.log1p(x, name);
247247

248-
public Tensor logical_and(Tensor x, Tensor y, string name = null)
249-
=> gen_math_ops.logical_and(x, y, name);
250-
251-
public Tensor logical_and(bool x, bool y, string name = null)
248+
public Tensor logical_and<T>(T x, T y, string name = null)
252249
=> gen_math_ops.logical_and(x, y, name);
253250

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

src/TensorFlowNET.Core/NumPy/Axis.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public record Axis(params int[] axis)
3030
public static implicit operator int[]?(Axis axis)
3131
=> axis?.axis;
3232

33+
public static implicit operator int(Axis axis)
34+
=> axis.axis[0];
35+
3336
public static implicit operator Axis(int axis)
3437
=> new Axis(axis);
3538

src/TensorFlowNET.Core/NumPy/NDArray.Operators.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ public partial class NDArray
1212
public static NDArray operator -(NDArray lhs, NDArray rhs) => lhs.Tensor - rhs.Tensor;
1313
public static NDArray operator *(NDArray lhs, NDArray rhs) => lhs.Tensor * rhs.Tensor;
1414
public static NDArray operator /(NDArray lhs, NDArray rhs) => lhs.Tensor / rhs.Tensor;
15+
public static NDArray operator >(NDArray lhs, NDArray rhs) => lhs.Tensor > rhs.Tensor;
16+
public static NDArray operator <(NDArray lhs, NDArray rhs) => lhs.Tensor < rhs.Tensor;
1517
}
1618
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Numerics;
5+
using System.Text;
6+
using static Tensorflow.Binding;
7+
8+
namespace Tensorflow.NumPy
9+
{
10+
public partial class np
11+
{
12+
public static NDArray logical_or(NDArray x1, NDArray x2)
13+
=> tf.logical_or(x1, x2);
14+
15+
public static NDArray logical_and(NDArray x1, NDArray x2)
16+
=> tf.logical_and(x1, x2);
17+
}
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Numerics;
5+
using System.Text;
6+
7+
namespace Tensorflow.NumPy
8+
{
9+
public partial class np
10+
{
11+
public static NDArray argmax(NDArray a, Axis axis = null)
12+
=> new NDArray(math_ops.argmax(a, axis));
13+
14+
public static NDArray argsort(NDArray a, Axis axis = null)
15+
=> new NDArray(math_ops.argmax(a, axis ?? -1));
16+
17+
public static NDArray unique(NDArray a)
18+
=> throw new NotImplementedException("");
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Numerics;
5+
using System.Text;
6+
using static Tensorflow.Binding;
7+
8+
namespace Tensorflow.NumPy
9+
{
10+
public partial class np
11+
{
12+
public static NDArray amin(NDArray x, int axis = 0)
13+
=> tf.arg_min(x, axis);
14+
15+
public static NDArray amax(NDArray x, int axis = 0)
16+
=> tf.arg_max(x, axis);
17+
}
18+
}

src/TensorFlowNET.Core/NumPy/Numpy.Manipulation.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace Tensorflow.NumPy
88
{
99
public partial class np
1010
{
11+
public static NDArray reshape(NDArray x1, Shape newshape)
12+
=> x1.reshape(newshape);
13+
1114
public static NDArray squeeze(NDArray x1, Axis? axis = null)
1215
=> new NDArray(array_ops.squeeze(x1, axis));
1316
}

src/TensorFlowNET.Core/NumPy/Numpy.Math.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,29 @@ namespace Tensorflow.NumPy
99
{
1010
public partial class np
1111
{
12+
public static NDArray exp(NDArray x)
13+
=> tf.exp(x);
14+
1215
public static NDArray log(NDArray x)
1316
=> tf.log(x);
1417

18+
public static NDArray multiply(NDArray x1, NDArray x2)
19+
=> tf.multiply(x1, x2);
20+
21+
public static NDArray maximum(NDArray x1, NDArray x2)
22+
=> tf.maximum(x1, x2);
23+
24+
public static NDArray minimum(NDArray x1, NDArray x2)
25+
=> tf.minimum(x1, x2);
26+
1527
public static NDArray prod(NDArray array, Axis? axis = null, Type? dtype = null, bool keepdims = false)
1628
=> tf.reduce_prod(array, axis: axis);
1729

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

21-
public static NDArray multiply(NDArray x1, NDArray x2)
22-
=> tf.multiply(x1, x2);
33+
public static NDArray sqrt(NDArray x)
34+
=> tf.sqrt(x);
2335

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

src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public static NDArray load(string file)
4646
public static (NDArray, NDArray) meshgrid<T>(T x, T y, bool copy = true, bool sparse = false)
4747
=> tf.numpy.meshgrid(new[] { x, y }, copy: copy, sparse: sparse);
4848

49+
public static NDArray ndarray(Shape shape, TF_DataType dtype = TF_DataType.TF_DOUBLE)
50+
=> new NDArray(tf.zeros(shape, dtype: dtype));
51+
4952
public static NDArray ones(Shape shape, TF_DataType dtype = TF_DataType.TF_DOUBLE)
5053
=> new NDArray(tf.ones(shape, dtype: dtype));
5154

src/TensorFlowNET.Core/Operations/gen_math_ops.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static Tensor add_n(Tensor[] inputs, string name = null)
5050
/// <param name="output_type"></param>
5151
/// <param name="name"></param>
5252
/// <returns></returns>
53-
public static Tensor arg_max(Tensor input, int dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null)
53+
public static Tensor arg_max(Tensor input, Axis dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null)
5454
=> tf.Context.ExecuteOp("ArgMax", name, new ExecuteOpArgs(input, dimension)
5555
.SetAttributes(new { output_type }));
5656

@@ -308,10 +308,7 @@ public static Tensor less_equal<Tx, Ty>(Tx x, Ty y, string name = null)
308308
public static Tensor log1p(Tensor x, string name = null)
309309
=> tf.Context.ExecuteOp("Log1p", name, new ExecuteOpArgs(x));
310310

311-
public static Tensor logical_and(Tensor x, Tensor y, string name = null)
312-
=> tf.Context.ExecuteOp("LogicalAnd", name, new ExecuteOpArgs(x, y));
313-
314-
public static Tensor logical_and(bool x, bool y, string name = null)
311+
public static Tensor logical_and<T>(T x, T y, string name = null)
315312
=> tf.Context.ExecuteOp("LogicalAnd", name, new ExecuteOpArgs(x, y));
316313

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

0 commit comments

Comments
 (0)