def get_weights_for_layer(layer):
    """
    Extracts the weights and biases of a layer.
    :param layer: The layer that the weights and biases will be extracted from.
    :return: A triple consisting of
             a) the weights,
             b) the flattened weights (weights as a list of values),
             c) the biases.
    """
    layer_weights = layer.get_weights()[0]
    layer_weights_flat = layer_weights.reshape(layer_weights.size)
    layer_bias = layer.get_weights()[1]

    return layer_weights, layer_weights_flat, layer_bias