Exemple #1
0
def fit(learning_rate: float, input_val: Sequence, expected_output: Sequence,
        network: Network) -> Sequence:
    restricted_output = network \
        .last() \
        .zip(expected_output) \
        .map(lambda t: activation.restricted_output(t[0].activation_f, t[1]))
    return utilities.lazy_realization(
        errors_with_fit_net(learning_rate, input_val, restricted_output,
                            network)[1])
Exemple #2
0
def init(keys_with_flags: Sequence, dataset: Sequence) -> Preprocessor:
    dataset_head = dataset.head()
    dataset_tail = dataset.tail()
    init_preprocessor = keys_with_flags \
        .map(lambda x: init_f(x[0], x[1], dataset_head))
    return utilities.lazy_realization(
        dataset_tail \
            .fold_left(init_preprocessor,
                       lambda acc, x: updated(x, acc))
    )
Exemple #3
0
def init(layer_sizes: Sequence, activation_f: Callable[[int], Activation],
         weight_init_f: Callable[[int], float]) -> Network:
    return utilities.lazy_realization(
        layer_sizes \
            .zip(layer_sizes.tail()) \
            .zip_with_index() \
            .map(lambda t:
                 layer.init(
                     t[0][0],
                     t[0][1],
                     activation_f(t[1]),
                     lambda: lambda: weight_init_f(t[1])))
    )
Exemple #4
0
def of_json(s: str) -> Network:
    return utilities.lazy_realization(deserialized(json.loads(s)))
Exemple #5
0
def of_json(s: str) -> Preprocessor:
    return utilities.lazy_realization(f_sharp_deserialized(json.loads(s)))
Exemple #6
0
def fit(learning_rate: float, input_val: Sequence, expected_output: Sequence,
        network: Network) -> Sequence:
    return utilities.lazy_realization(
        errors_with_fit_net(learning_rate, input_val, expected_output,
                            network)[1])