Skip to content

fix: revise np.amin, np.amax and add np.argmin #1155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public partial class np
public static NDArray argmax(NDArray a, Axis? axis = null)
=> new NDArray(math_ops.argmax(a, axis ?? 0));

[AutoNumPy]
public static NDArray argmin(NDArray a, Axis? axis = null)
=> new NDArray(math_ops.argmin(a, axis ?? 0));

[AutoNumPy]
public static NDArray argsort(NDArray a, Axis? axis = null)
=> new NDArray(sort_ops.argsort(a, axis: axis ?? -1));
Expand Down
4 changes: 2 additions & 2 deletions src/TensorFlowNET.Core/NumPy/NumPy.Statistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace Tensorflow.NumPy
public partial class np
{
[AutoNumPy]
public static NDArray amin(NDArray x, int axis = 0) => new NDArray(tf.arg_min(x, axis));
public static NDArray amin(NDArray x, int axis = 0) => new NDArray(tf.min(x, axis));

[AutoNumPy]
public static NDArray amax(NDArray x, int axis = 0) => new NDArray(tf.math.argmax(x, axis));
public static NDArray amax(NDArray x, int axis = 0) => new NDArray(tf.max(x, axis));

[AutoNumPy]
public static NDArray average(NDArray a, int axis = -1, NDArray? weights = null, bool returned = false)
Expand Down
3 changes: 3 additions & 0 deletions src/TensorFlowNET.Core/Operations/math_ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public static Tensor add_n(Tensor[] inputs, 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 argmin(Tensor input, Axis dimension, TF_DataType output_type = TF_DataType.TF_INT64, string name = null)
=> gen_math_ops.arg_min(input, dimension, output_type: output_type, name: name);

public static Tensor round(Tensor x, string name = null)
{
x = ops.convert_to_tensor(x, name: "x");
Expand Down