Getting {ValueError} 'a' must be 1-dimensoinal for list of lists from np.random.choice
In case of an array I would do the following:
xor = np.array([[0,0,0],
[0,1,1],
[1,0,1],
[1,1,0]])
rnd_indices = np.random.choice(len(xor), size=200)
xor_data = xor[rnd_indices]
If you want a random list from xor
, you should probably be doing this.
xor[np.random.choice(len(xor),1)]
You can use the random
package instead:
import random
input_x = [random.choice(xor) for _ in range(200)]