python 3.x - Keras Error using Lambda -


i've started out keras week , have been going through documentation figure out why i'm getting error. figured faster if got help, , feels detail i'm not seeing.

error when checking model input: expected lambda_input_1 have 4 dimensions,  got array shape (0, 1) 

here entire code on if helps see i'm doing wrong.

import csv import cv2 import numpy np  lines = [] open('../data2/driving_log.csv') csvfile:         reader = csv.reader(csvfile)         line in reader:                 lines.append(line)         row in reader:             steering_center = float(row[3])                 # create adjusted steering measurements side camera images             correction = 0.2 # parameter tune             steering_left = steering_center + correction             steering_right = steering_center - correction                  # read in images center, left , right cameras             directory = "..." # fill in path training img directory             img_center = process_image(np.asarray(image.open(path + row[0])))             img_left = process_image(np.asarray(image.open(path + row[1])))             img_right = process_image(np.asarray(image.open(path + row[2])))                 # add images , angles data set             car_images.extend(img_center, img_left, img_right)             steering_angles.extend(steering_center, steering_left, steering_right)  images = [] measurements =[] line in lines:         source_path = line[0]         filename = source_path.split('/')[-1]         current_path = '../data2/img/' + filename         image = cv2.imread(current_path)         measurement = float(line[3])         measurements.append(measurement)  augmented_images, augmented_measuremnets = [], [] image, measurement in zip(image, measurements):         augmented_images.append(image)         augmented_measuremnets.append(measurement)         augmented_images.append(cv2.flip(image,1))         augmented_measuremnets.append(measurement*-1)  x_train = np.array(images) y_train = np.array(measurements)  keras.models import sequential keras.layers import flatten, dense, lambda, cropping2d keras.layers.convolutional import convolution2d keras.layers.pooling import maxpooling2d  model = sequential() model.add(lambda(lambda x: x / 255.0 - 0.5, input_shape=(160,320,3))) model.add(cropping2d(cropping=((70,25), (0,0)))) model.add(convolution2d(24,5,5, subsample=(2,2), activation="relu")) model.add(convolution2d(36,5,5, subsample=(2,2), activation="relu")) model.add(convolution2d(48,5,5, subsample=(2,2), activation="relu")) model.add(convolution2d(64,3,3, activation="relu")) model.add(convolution2d(64,3,3, activation="relu")) model.add(flatten()) model.add(dense(120)) model.add(dense(84)) model.add(dense(1))  model.compile(loss='mse', optimizer='adam') model.fit(x_train, y_train, validation_split=0.2, shuffle=true, nb_epoch=5)   model.save('model.h5') exit() 

i'm trying figure out if need resize input data set model.fit(...) function work properly. worked before without issues until added cropping , more data.

thanks, direction help, if gets me closer understanding dimensional error.

file "nvidia.py", line 64, in <module>         model.fit(x_train, y_train, validation_split=0.2, shuffle=true, nb_epoch=5)       file "/home/carnd/anaconda3/envs/carnd-term1/lib/python3.5/site-packages/keras/models.py", line 672, in fit         initial_epoch=initial_epoch)       file "/home/carnd/anaconda3/envs/carnd-term1/lib/python3.5/site-packages/keras/engine/training.py", line 1117, in fit         batch_size=batch_size)       file "/home/carnd/anaconda3/envs/carnd-term1/lib/python3.5/site-packages/keras/engine/training.py", line 1030, in _standardize_user_data         exception_prefix='model input')       file "/home/carnd/anaconda3/envs/carnd-term1/lib/python3.5/site-packages/keras/engine/training.py", line 112, in standardize_input_data         str(array.shape))     valueerror: error when checking model input: expected lambda_input_1 have 4 dimensions, got array shape (0, 1) 

you forgot insert image images. x_train empty.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -