ivy icon indicating copy to clipboard operation
ivy copied to clipboard

Tensorflow random.normal

Open Smotto opened this issue 2 years ago • 4 comments

Close #5704

Not too sure about shapes being generated in the tests. I know that the input should be a 1-D Integer Tensor or a Python array, but I'm not sure what's the best way to approach that. Thanks!

Smotto avatar Oct 15 '22 12:10 Smotto

Hello @Smotto!, Look into helpers.dtype_and_values parameters you can specify the max_dim_size. https://github.com/unifyai/ivy/blob/769015d50fc735f85038a890712f4f259ca28094/ivy_tests/test_ivy/helpers/hypothesis_helpers/array_helpers.py#L83

CatB1t avatar Oct 22 '22 10:10 CatB1t

@CatB1t It seems that I did generate the shapes correctly already. I'm getting an AttributeError: 'tuple' object has no attribute 'shape' along with IvyBackendExceptions when running my implemented tests. Either the backend doesn't support tuples being converted to shapes, or there's something that I'm not quite grasping.

Smotto avatar Oct 22 '22 11:10 Smotto

@Smotto Is this the case for all backends? or only one?

CatB1t avatar Oct 29 '22 13:10 CatB1t

@CatB1t It's multiple it seems. I've tested it with generating shapes of min and max dim sizes of 1

in ivy/function_wrapper ---> with '''args = ((1,),), kwargs = {}''' ---> Probably has to do with an exception of not being able to take a 2D tuple

In ivy/functional/backends/torch/general ---> AttributeError: 'tuple' object has no attribute 'shape' ---> Seems like this shouldn't be touched at all. In ivy_tests/test_iv/helpers/testing_helpers.py ---> another error due to torch/general

In ivy/exceptions ---> IvyBackendException ---> 'tuple' object has no attribute 'shape'

In ivy/functional/backends/tensorflow/general ---> AttributeError: 'tuple' object has no attribute 'shape' In ivy_tests/test_iv/helpers/testing_helpers.py -> another error due to tensorflow/general

In ivy/functional/backends/jax/general ---> Another attribute error.

There's more of the same error, but I believe that using Ivy.shape() on a tuple isn't generating correctly. Maybe I got confused on Tensorflow shapes specifically.

So I used the same test just 'shape' instead of 'Ivy.shape(shape)', and 2 more back end errors occur. ivy/functional/ivy/random.py ivy.assertions.check_all_or_any_fn( low, high, fn=lambda x: isinstance(x, (int, float)), type="all", message="low and high bounds must be numerics when shape is specified", )

ivy/functional/backends/numpy/random def random_normal( *, mean: Union[float, np.ndarray] = 0.0, std: Union[float, np.ndarray] = 1.0, shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None, device: str, dtype: np.dtype, seed: Optional[int] = None, out: Optional[np.ndarray] = None, ) -> np.ndarray: _check_valid_scale(std)

  shape = _check_bounds_and_get_shape(mean, std, shape)

Smotto avatar Oct 29 '22 23:10 Smotto

Hello @Smotto, I'm not able to quite follow up, but can you give a minimal example of what's the issue exactly is?

CatB1t avatar Nov 06 '22 05:11 CatB1t

This PR has been labelled as stale because it has been inactive for more than 7 days. If you would like to continue working on this PR, then please add another comment or this PR will be closed in 7 days.

ivy-seed avatar Nov 14 '22 06:11 ivy-seed

This PR has been closed because it has been marked as stale for more than 7 days with no activity.

ivy-seed avatar Nov 21 '22 06:11 ivy-seed