eumap.mapper.build_ann

build_ann(input_shape, output_shape, n_layers=3, n_neurons=32, activation='relu', dropout_rate=0.0, learning_rate=0.0001, output_activation='softmax', loss='categorical_crossentropy')[source]

Helper function to create a pretty standard Artificial Neural Network-ANN using tensorflow. It’s based in a Sequential model, which connects multiple hidden layers (Dense=>Dropout=>BatchNormalization) and uses a Nadam optimizer. Developed to be used together with KerasClassifier.

Parameters
  • input_shape – The input data shape.

  • output_shape – The output data shape.

  • n_layers – Number of hidden layers.

  • n_neurons – Number of neurons for the hidden layers.

  • activation – Activation function for the input and hidden layers.

  • dropout_rate – Dropout rate for the BatchNormalization.

  • learning_rate – Learning rate for the optimized.

  • output_activation – Activation function for the output layer.

  • loss – Loss function used for the Optimizer.

Returns

The ANN model

Return type

Sequential

Examples

>>> from eumap.mapper import build_ann
>>> from tensorflow.keras.wrappers.scikit_learn import KerasClassifier
>>>
>>> ann = KerasClassifier(build_ann, input_shape=(-1, 180), output_shape=33,
>>>                       epochs=3, batch_size=64, shuffle=True, verbose=1)