def CarND(input_shape, crop_shape):
model = Sequential()
# Crop
# model.add(Cropping2D(((80,20),(1,1)), input_shape=input_shape, name="Crop"))
model.add(Cropping2D(crop_shape, input_shape=input_shape, name="Crop"))
# Resize
model.add(AveragePooling2D(pool_size=(1,4), name="Resize", trainable=False))
# Normalize input.
model.add(BatchNormalization(axis=1, name="Normalize"))
# Reduce dimensions through trainable convolution, activation, and
# pooling layers.
model.add(Convolution2D(24, 3, 3, subsample=(2,2), name="Convolution2D1", activation="relu"))
model.add(MaxPooling2D(name="MaxPool1"))
model.add(Convolution2D(36, 3, 3, subsample=(1,1), name="Convolution2D2", activation="relu"))
model.add(MaxPooling2D(name="MaxPool2"))
model.add(Convolution2D(48, 3, 3, subsample=(1,1), name="Convolution2D3", activation="relu"))
model.add(MaxPooling2D(name="MaxPool3"))
# Dropout for regularization
model.add(Dropout(0.1, name="Dropout"))
# Flatten input in a non-trainable layer before feeding into
# fully-connected layers.
model.add(Flatten(name="Flatten"))
# Model steering through trainable layers comprising dense units
# as ell as dropout units for regularization.
model.add(Dense(100, activation="relu", name="FC2"))
model.add(Dense(50, activation="relu", name="FC3"))
model.add(Dense(10, activation="relu", name="FC4"))
# Generate output (steering angles) with a single non-trainable
# node.
model.add(Dense(1, name="Readout", trainable=False))
return model
# #+RESULTS:
# Here is a summary of the actual model, as generated directly by
# =model.summary= in Keras.
评论列表
文章目录