Hi, first of all thank you for your work.
I'm trying to use your framework to optimize hiperparameters in my Convolutional Neural Network in order to implement an image classifier.
I have checked my data construction function and the training data returned have the right shape (216, 360, 3) but for some reason the model receive an input with shape (300, 50, 3).
I really don't know what to do, here is my code:
def dataAdv1():
dfAll = pd.read_csv('filePath')
labels = pd.read_csv('filePath')
df = pd.read_csv('filePath')
#this function returns a list of all the images
imageList = createImageList(df, dfAll)
imageTmp = imageList
# this function is used to get the list of labels
labels_list = clearAdvancingLabel(labels)
labelTmp = labels_list
#this function divide the data into train, validation and test set
x_train, y_train, x_valid, y_valid, x_test, y_test = splitTrainValidationTest(imageTmp, labelTmp)
y_train = y_train.ravel()
y_valid = y_valid.ravel()
y_test = y_test.ravel()
return x_train, y_train, x_test, y_test, x_valid, y_valid
def create_modelAdvancing(x_train, y_train, x_test, y_test, x_valid, y_valid):
model = Sequential()
model.add(Conv2D({{choice([4, 16, 32, 64])}}, (3, 3), input_shape=(216, 360, 3)))
model.add(Activation({{choice(['relu', 'tanh'])}}))
model.add(MaxPooling2D(pool_size=(2, 2)))
num_layers = {{choice(['one', 'two', 'three', 'four'])}}
if num_layers =='two':
model.add(Conv2D({{choice([4, 16, 32, 64])}}, (3, 3)))
model.add(Activation({{choice(['relu', 'tanh'])}}))
model.add(MaxPooling2D(pool_size=(2, 2)))
elif num_layers == 'three':
model.add(Conv2D({{choice([4, 16, 32, 64])}}, (3, 3)))
model.add(Activation({{choice(['relu', 'tanh'])}}))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D({{choice([4, 16, 32, 64])}}, (3, 3)))
model.add(Activation({{choice(['relu', 'tanh'])}}))
model.add(MaxPooling2D(pool_size=(2, 2)))
elif num_layers == 'four':
model.add(Conv2D({{choice([4, 16, 32, 64])}}, (3, 3)))
model.add(Activation({{choice(['relu', 'tanh'])}}))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D({{choice([4, 16, 32, 64])}}, (3, 3)))
model.add(Activation({{choice(['relu', 'tanh'])}}))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D({{choice([4, 16, 32, 64])}}, (3, 3)))
model.add(Activation({{choice(['relu', 'tanh'])}}))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())
model.add(Dense({{choice([4, 16, 32, 64])}}))
model.add(Activation({{choice(['relu', 'tanh'])}}))
model.add(Dropout({{uniform(0, 1)}}))
model.add(Dense(1))
model.add(Activation({{choice(['softmax', 'sigmoid'])}}))
chooseOptimizer = {{choice(['adam', 'sgd', 'rmsprop'])}}
model.compile(loss='binary_crossentropy', optimizer=chooseOptimizer, metrics=['accuracy'])
model.fit(x_train, y_train,
batch_size={{choice([4, 16, 32, 64])}},
epochs={{choice([10, 30, 50])}},
verbose=2,
validation_data=(x_valid, y_valid))
score, acc = model.evaluate(x_test, y_test, verbose=0)
print('Test accuracy:', acc)
return {'loss': -acc, 'status': STATUS_OK, 'model': model.to_yaml()}
# Create Spark context
conf = SparkConf().setAppName('Elephas_Hyperparameter_Optimization').setMaster('local[*]')
sc = SparkContext(conf=conf)
# Define hyper-parameter model and run optimization
hyperparam_model = HyperParamModel(sc)
hyperparam_model.minimize(model=create_modelAdvancing, data=dataAdv1, max_evals=5)
Hi, first of all thank you for your work.
I'm trying to use your framework to optimize hiperparameters in my Convolutional Neural Network in order to implement an image classifier.
I'm obtaining the following error:
ValueError: Error when checking input: expected conv2d_1_input to have shape (216, 360, 3) but got array with shape (300, 500, 3)
I have checked my data construction function and the training data returned have the right shape (216, 360, 3) but for some reason the model receive an input with shape (300, 50, 3).
I really don't know what to do, here is my code:
Thank you in advance for your help