Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to input data into KERAS python?

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.

like image 600
Darlyn Avatar asked May 03 '26 19:05

Darlyn


1 Answers

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.

like image 197
Maxim Avatar answered May 06 '26 09:05

Maxim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!