3

In keras fit function

model.fit(X_train, y_train, nb_epoch=20, batch_size=16)

How should I input the data when i have more columns?

I want to input image, and detect object of class 1 on it. So the output is (x, y, width, height)

The input image should be 416 x 416 x 3 and output matrix should be 13x13x4 so i want to detect up to 169 objects.

Should the

X_train

variable be loaded set of images ( so it will be 4 dimensional array of N x 416 x 416 x 3 )

and

y_train

be 2D array of N x 4 , where 4 represents ( x ,y , width, height ) ?

If so what do i have to pass in validation_data arguments?

I am really confused.

3
  • I am not sure what level of depth you are, but the link below should get you started - blog.keras.io/… Commented Mar 21, 2018 at 10:48
  • I honestly don't understand your use case. What are you trying to classify? Objects? Or are you trying to define the (x,y)-coordinates? Or maybe the height or the width? However in Keras you can input the Array of [N x 416 x 416 x 3]. The validation set is used to get the actual loss and accuracy between every step/epoch. It is used so that the algorithm doesn't need to take some samples from your training set. Commented Mar 21, 2018 at 10:52
  • I am trying do detect object on the image ( so basicly its x and y coordinates and width height so i can draw rectangle over it ). If i understood it correctly the y_train should be labels, in my case it should be x y width and height cooridantes? Commented Mar 21, 2018 at 10:54

1 Answer 1

1

The test (validation) data should have the same shape as the training data: the X must be "feedable" into the network and y must be "comparable" to the output of the network, no matter if it's for training or testing. So if

X_train.shape == (N, 416, 416, 3)
y_train.shape == (N, 169, 4)

... then the test data

X_test.shape == (M, 416, 416, 3)
y_test.shape == (M, 169, 4)

Here I assume you want to detect 169 objects at once per training instance. This number depends on the data you have, traditional datasets contain much fewer objects per image. Up to 10 objects would result in (N, 10, 4) output shape.

There's a nice tutorial on object detection with keras (here's the code), which can serve as an example.

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.