예제 #1
0
def create_from_file(filename):
    """
    Constructs a backpropagation neural network from a configuration file.
    """
    ann = libfann.fann_create_from_file(filename)
    if libfann.fann_is_NULL(ann):
        raise IOError, "Could not load ann from file '%s'" + filename
    return fann_class(ann)
예제 #2
0
def create(connRate, layers):
    """
    Constructs a backpropagation neural network, from an connection rate,
    a learning rate, and number of neurons in each layer.

    The connection rate controls how many connections there will be in the
    network. If the connection rate is set to 1, the network will be fully
    connected, but if it is set to 0.5 only half of the connections will be set.

    There will be a bias neuron in each layer (except the output layer),
    and this bias neuron will be connected to all neurons in the next layer.
    When running the network, the bias nodes always emits 1
    """
    ann = libfann.fann_create_sparse_array(connRate,len(layers), layers)
    if libfann.fann_is_NULL(ann):
        return None # probably won't happen
    return fann_class(ann)