Example #1
0
def _mix_layouts(parent_layouts, parameters, p_mutate_param=0.05):
    layout = Layout(
        input_size=parent_layouts[0].input_size,
        output_size=parent_layouts[0].output_size,
        output_activation=parent_layouts[0].output_activation,
        block=parent_layouts[0].block,
        block_input=parent_layouts[0].block_input)
    if parameters.is_layout_search():
        rows = random_list_element([len(p.rows) for p in parent_layouts])
        for row_idx in range(rows):
            parent_rows = [p.rows[row_idx] for p in parent_layouts if row_idx < len(p.rows)]
            layout.rows.append(_mix_row(layout, row_idx, parent_rows, parameters))
        _setup_block_inputs(layout, parameters)
        if parameters.is_parameters_search():
            _mutate_layer_parameters(
                layout,
                parameters,
                p_mutate_param=p_mutate_param)
    else:
        layout.rows = random_list_element([
            parent_layouts[0].rows,
            parent_layouts[1].rows])
    return layout
Example #2
0
def _random_layout(layout, experiment_parameters):
    layout = Layout(
        layout.input_size,
        layout.output_size,
        layout.output_activation,
        layout.block)
    if experiment_parameters.is_layout_search():
        rows = random_initial_param_value(experiment_parameters.get_layout_parameter('rows'))
        for row_idx in range(rows):
            layout.rows.append(
                _random_layout_row(
                    layout,
                    row_idx,
                    experiment_parameters))
    else:
        layout.rows = [
            Row(blocks=[
                _instantiate_layout_block(
                    layout,
                    0,
                    experiment_parameters)])]
    if experiment_parameters.is_parameters_search():
        _set_layout_random_parameters(layout, experiment_parameters)
    return layout