1

I would like to create two random arrays in NumPy for a fixed, given shape. np.random.randn(A,B,C) creates a random array of float64, if i am not mistaken, how do i create one filled with float32?

If i am mistaken, then my question still pertains, just the other way around.

1
  • mat = np.random.randn(1, 3, 4).astype(np.float32) for example Commented May 3, 2019 at 16:24

2 Answers 2

4

You can convert your array after initialization as follow :

mat = np.random.randn(A,B,C)
mat = mat.astype(np.float32)
Sign up to request clarification or add additional context in comments.

Comments

1

You can pass dtype as follows:

np.array(np.random.randn(1,2,3), dtype=np.float32)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.