Browse Source

np.randint

tags/v0.60-tf.numpy
Oceania2018 4 years ago
parent
commit
9c5692b592
3 changed files with 14 additions and 5 deletions
  1. +1
    -1
      src/TensorFlowNET.Core/APIs/tf.random.cs
  2. +11
    -1
      src/TensorFlowNET.Core/NumPy/Implementation/RandomizedImpl.cs
  3. +2
    -3
      src/TensorFlowNET.Core/Operations/random_ops.cs

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

@@ -71,7 +71,7 @@ namespace Tensorflow
string name = null)
{
if (dtype.is_integer())
return random_ops.random_uniform_int(shape, (int)minval, (int)maxval, dtype, seed, name);
return random_ops.random_uniform_int(shape, (int)minval, (int)maxval, seed, name);
else
return random_ops.random_uniform(shape, minval, maxval, dtype, seed, name);
}


+ 11
- 1
src/TensorFlowNET.Core/NumPy/Implementation/RandomizedImpl.cs View File

@@ -23,8 +23,18 @@ namespace Tensorflow.NumPy
public NDArray rand(params int[] shape)
=> throw new NotImplementedException("");

[AutoNumPy]
public NDArray randint(int low, int? high = null, Shape size = null, TF_DataType dtype = TF_DataType.TF_INT32)
=> throw new NotImplementedException("");
{
if(high == null)
{
high = low;
low = 0;
}
size = size ?? Shape.Scalar;
var tensor = random_ops.random_uniform_int(shape: size, minval: low, maxval: (int)high);
return new NDArray(tensor);
}

public NDArray normal(float loc = 0.0f, float scale = 1.0f, Shape size = null)
=> throw new NotImplementedException("");


+ 2
- 3
src/TensorFlowNET.Core/Operations/random_ops.cs View File

@@ -94,7 +94,6 @@ namespace Tensorflow
public static Tensor random_uniform_int(int[] shape,
int minval = 0,
int maxval = 1,
TF_DataType dtype = TF_DataType.TF_FLOAT,
int? seed = null,
string name = null)
{
@@ -103,8 +102,8 @@ namespace Tensorflow
name = scope;
var (seed1, seed2) = random_seed.get_seed(seed);
var tensorShape = tensor_util.shape_tensor(shape);
var minTensor = ops.convert_to_tensor(minval, dtype: dtype, name: "min");
var maxTensor = ops.convert_to_tensor(maxval, dtype: dtype, name: "max");
var minTensor = ops.convert_to_tensor(minval, name: "min");
var maxTensor = ops.convert_to_tensor(maxval, name: "max");
return gen_random_ops.random_uniform_int(tensorShape, minTensor, maxTensor, seed: seed1, seed2: seed2);
});
}


Loading…
Cancel
Save