2

I used the MNIST dataset for training a neural network, where the training data is returned as a tuple with two entries. The first entry contains the actual training images. This is a numpy ndarray with 50,000 entries. Each entry is, in turn, a numpy ndarray with 784 values, representing the 28 * 28 = 784 pixels in a single MNIST image.

I would like to create a new training set, however I do not know how to create an ndarray from other ndarrays. For instance, if I have the following two ndarrays:

a = np.ndarray((3,1), buffer=np.array([0.9,1.0,1.0]), dtype=float)

b = np.ndarray((3,1), buffer=np.array([0.8,1.0,1.0]), dtype=float)

how to make a third one containing these two?

I tried the following but it creates only one entry.

c = np.ndarray((1,6,1), buffer=np.array(([a],[b])), dtype=float)

I would need it to be two entries.

2
  • 2
    Does np.vstack([a, b]) do the job? Commented Nov 9, 2015 at 14:16
  • np.vstack also creates one entry. c = np.array((a, b)) however seems to work. Thanks! Commented Nov 9, 2015 at 14:24

1 Answer 1

3

Thanks, in the meanwhile I figured out it is simply:

c = np.array((a, b))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.