Ejemplo n.º 1
0
def exp_a(name):
    # conv, conv
    global source
    source_dict_copy = deepcopy(source_dict)
    source_dict_copy.update(dict(logger=logging.getLogger(name)))
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(experiment_name=name, source=source))
    NUM_FILTERS = 16
    target_seq_length = (source.output_shape_after_processing()[1] *
                         source.output_shape_after_processing()[2])
    net_dict_copy['layers_config'] = [
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)  # (batch, features, time)
        },
        {
            'type': PadLayer,
            'width': 4
        },
        {
            'type': Conv1DLayer,  # convolve over the time axis
            'num_filters': NUM_FILTERS,
            'filter_size': 4,
            'stride': 1,
            'nonlinearity': None,
            'border_mode': 'valid'
        },
        {
            'type': Conv1DLayer,  # convolve over the time axis
            'num_filters': NUM_FILTERS,
            'filter_size': 4,
            'stride': 1,
            'nonlinearity': None,
            'border_mode': 'valid'
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1),  # back to (batch, time, features)
            'label': 'dimshuffle3'
        },
        {
            'type': DenseLayer,
            'num_units': 512 * 2,
            'nonlinearity': rectify,
            'label': 'dense0'
        },
        {
            'type': DenseLayer,
            'num_units': 512,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': target_seq_length,
            'nonlinearity': None
        }
    ]
    net = Net(**net_dict_copy)
    return net
Ejemplo n.º 2
0
def exp_e(name):
    global source
    source_dict_copy = deepcopy(source_dict)
    source_dict_copy['random_window'] = 0
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(experiment_name=name, source=source))
    N = 512 * 8
    output_shape = source.output_shape_after_processing()
    net_dict_copy['layers_config'] = [{
        'type': DenseLayer,
        'num_units': N * 2,
        'nonlinearity': rectify
    }, {
        'type': DenseLayer,
        'num_units': N,
        'nonlinearity': rectify
    }, {
        'type': DenseLayer,
        'num_units': N // 2,
        'nonlinearity': rectify
    }, {
        'type': DenseLayer,
        'num_units': N // 4,
        'nonlinearity': rectify
    }, {
        'type':
        DenseLayer,
        'num_units':
        output_shape[1] * output_shape[2],
        'nonlinearity':
        sigmoid
    }]
    net = Net(**net_dict_copy)
    return net
Ejemplo n.º 3
0
def exp_a(name):
    global source
    source_dict_copy = deepcopy(source_dict)
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(
        experiment_name=name,
        source=source
    ))
    N = 512
    output_shape = source.output_shape_after_processing()
    net_dict_copy['layers_config'] = [
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)  # (batch, features, time)
        },
        {
            'type': Conv1DLayer, # convolve over the time axis
            'num_filters': 32,
            'filter_length': 4,
            'stride': 1,
            'nonlinearity': rectify,
            'border_mode': 'same'
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1) # back to (batch, time, features)
        },
        {
            'type': DenseLayer,
            'num_units': N * 2,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': N,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': N // 2,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': output_shape[1] * output_shape[2],
            'nonlinearity': sigmoid
        }
    ]
    net = Net(**net_dict_copy)
    return net
Ejemplo n.º 4
0
def exp_a(name):
    global source
    source_dict_copy = deepcopy(source_dict)
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(
        experiment_name=name,
        source=source
    ))
    output_shape = source.output_shape_after_processing()
    net_dict_copy['layers_config'] = [
        {
            'type': BLSTMLayer,
            'num_units': 40,
            'gradient_steps': GRADIENT_STEPS,
            'peepholes': False,
            'nonlinearity_cell': rectify,
            'nonlinearity_out': rectify
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)
        },
        {
            'type': Conv1DLayer,
            'num_filters': 20,
            'filter_length': 4,
            'stride': 4,
            'nonlinearity': rectify
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)
        },
        {
            'type': BLSTMLayer,
            'num_units': 80,
            'gradient_steps': GRADIENT_STEPS,
            'peepholes': False,
            'nonlinearity_cell': rectify,
            'nonlinearity_out': rectify
        },
        {
            'type': DenseLayer,
            'num_units': source.n_outputs,
            'nonlinearity': T.nnet.softplus
        }
    ]
    net = Net(**net_dict_copy)
    return net
Ejemplo n.º 5
0
def exp_a(name):
    global source
    source_dict_copy = deepcopy(source_dict)
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(experiment_name=name, source=source))
    N = 512
    output_shape = source.output_shape_after_processing()
    net_dict_copy['layers_config'] = [
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)  # (batch, features, time)
        },
        {
            'type': Conv1DLayer,  # convolve over the time axis
            'num_filters': 32,
            'filter_length': 4,
            'stride': 1,
            'nonlinearity': rectify,
            'border_mode': 'same'
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)  # back to (batch, time, features)
        },
        {
            'type': DenseLayer,
            'num_units': N * 2,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': N,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': N // 2,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': output_shape[1] * output_shape[2],
            'nonlinearity': sigmoid
        }
    ]
    net = Net(**net_dict_copy)
    return net
Ejemplo n.º 6
0
def exp_a(name):
    global source
    source_dict_copy = deepcopy(source_dict)
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(
        experiment_name=name,
        source=source
    ))
    output_shape = source.output_shape_after_processing()
    net_dict_copy['layers_config'] = [
        {
            'type': BLSTMLayer,
            'num_units': 40,
            'gradient_steps': GRADIENT_STEPS,
            'peepholes': False
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)
        },
        {
            'type': Conv1DLayer,
            'num_filters': 20,
            'filter_length': 4,
            'stride': 4,
            'nonlinearity': sigmoid
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)
        },
        {
            'type': BLSTMLayer,
            'num_units': 80,
            'gradient_steps': GRADIENT_STEPS,
            'peepholes': False
        },
        {
            'type': DenseLayer,
            'num_units': source.n_outputs,
            'nonlinearity': T.nnet.softplus
        }
    ]
    net = Net(**net_dict_copy)
    return net
Ejemplo n.º 7
0
def exp_c(name):
    global source
    source_dict_copy = deepcopy(source_dict)
    source_dict_copy['random_window'] = 256
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(
        experiment_name=name,
        source=source,
        learning_rate=1e-5
    ))
    N = 512 * 8
    output_shape = source.output_shape_after_processing()
    net_dict_copy['layers_config'] = [
        {
            'type': DenseLayer,
            'num_units': N * 2,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': N,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': N // 2,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': N // 4,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': output_shape[1] * output_shape[2],
            'nonlinearity': sigmoid
        }
    ]
    net = Net(**net_dict_copy)
    net.load_params(30000)
    return net
Ejemplo n.º 8
0
def exp_a(name):
    # conv, conv
    global source
    source_dict_copy = deepcopy(source_dict)
    source_dict_copy.update(dict(logger=logging.getLogger(name)))
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(experiment_name=name, source=source))
    NUM_FILTERS = 16
    target_seq_length = source.output_shape_after_processing()[1]
    net_dict_copy["layers_config"] = [
        {"type": DimshuffleLayer, "pattern": (0, 2, 1)},  # (batch, features, time)
        {
            "type": Conv1DLayer,  # convolve over the time axis
            "num_filters": NUM_FILTERS,
            "filter_size": 4,
            "stride": 1,
            "nonlinearity": None,
            "border_mode": "valid",
        },
        {
            "type": Conv1DLayer,  # convolve over the time axis
            "num_filters": NUM_FILTERS,
            "filter_size": 4,
            "stride": 1,
            "nonlinearity": None,
            "border_mode": "valid",
        },
        {"type": DimshuffleLayer, "pattern": (0, 2, 1)},  # back to (batch, time, features)
        {"type": DenseLayer, "num_units": 512, "nonlinearity": rectify},
        {"type": DenseLayer, "num_units": 512, "nonlinearity": rectify},
        {"type": DenseLayer, "num_units": 512, "nonlinearity": rectify},
        {"type": DenseLayer, "num_units": target_seq_length, "nonlinearity": None},
    ]
    net = Net(**net_dict_copy)
    return net
Ejemplo n.º 9
0
def exp_a(name):
    # conv, conv
    global source
    source_dict_copy = deepcopy(source_dict)
    source_dict_copy.update(dict(
        logger=logging.getLogger(name)
    ))
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(
        experiment_name=name,
        source=source
    ))
    NUM_FILTERS = 16
    target_seq_length = source.output_shape_after_processing()[1]
    net_dict_copy['layers_config'] = [
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)  # (batch, features, time)
        },
        {
            'type': Conv1DLayer,  # convolve over the time axis
            'num_filters': NUM_FILTERS,
            'filter_size': 4,
            'stride': 1,
            'nonlinearity': None,
            'border_mode': 'valid'
        },
        {
            'type': Conv1DLayer,  # convolve over the time axis
            'num_filters': NUM_FILTERS,
            'filter_size': 4,
            'stride': 1,
            'nonlinearity': None,
            'border_mode': 'valid'
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)  # back to (batch, time, features)
        },
        {
            'type': DenseLayer,
            'num_units': 512,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': 512,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': 512,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': target_seq_length,
            'nonlinearity': None
        }
    ]
    net = Net(**net_dict_copy)
    return net
Ejemplo n.º 10
0
def exp_a(name):
    # conv, conv
    global source
    source_dict_copy = deepcopy(source_dict)
    source_dict_copy.update(dict(
        logger=logging.getLogger(name)
    ))
    source = RealApplianceSource(**source_dict_copy)
    net_dict_copy = deepcopy(net_dict)
    net_dict_copy.update(dict(
        experiment_name=name,
        source=source
    ))
    NUM_FILTERS = 16
    target_seq_length = source.output_shape_after_processing()[1]
    net_dict_copy['layers_config'] = [
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1)  # (batch, features, time)
        },
        {
            'type': Conv1DLayer,  # convolve over the time axis
            'num_filters': NUM_FILTERS,
            'filter_size': 4,
            'stride': 1,
            'nonlinearity': None,
            'border_mode': 'valid'
        },
        #  Need to do ugly dimshuffle, reshape, reshape, dimshuffle
        #  to get output of first Conv1DLayer ready for
        #  ConcatLayer
        # {
        #     'type': DimshuffleLayer,
        #     'pattern': (0, 2, 1),  # back to (batch, time, features)
        #     'label': 'dimshuffle1'
        # },
        # {
        #     'type': ReshapeLayer,
        #     'shape': (N_SEQ_PER_BATCH, -1),
        #     'label': 'reshape0'
        # },
        # {
        #     'type': ReshapeLayer,
        #     'shape': (N_SEQ_PER_BATCH, NUM_FILTERS, -1)
        # },
        # {
        #     'type': DimshuffleLayer,
        #     'pattern': (0, 2, 1),  # back to (batch, time, features)
        #     'label': 'dimshuffle2'
        # },
        {
            'type': Conv1DLayer,  # convolve over the time axis
            'num_filters': NUM_FILTERS,
            'filter_size': 4,
            'stride': 1,
            'nonlinearity': None,
            'border_mode': 'valid'
        },
        {
            'type': DimshuffleLayer,
            'pattern': (0, 2, 1),  # back to (batch, time, features)
            'label': 'dimshuffle3'
        },
        {
            'type': DenseLayer,
            'num_units': 512,
            'nonlinearity': rectify,
            'label': 'dense0'
        },
        {
            'type': DenseLayer,
            'num_units': 512,
            'nonlinearity': rectify,
            'label': 'dense1'
        },
        {
            'type': DenseLayer,
            'num_units': 512,
            'nonlinearity': rectify,
            'label': 'dense2'
        },
        {
            'type': ConcatLayer,
            'axis': 1,
            'incomings': ['dense0', 'dense2']
        },
        {
            'type': DenseLayer,
            'num_units': 512,
            'nonlinearity': rectify
        },
        {
            'type': DenseLayer,
            'num_units': target_seq_length,
            'nonlinearity': None
        }
    ]
    net = Net(**net_dict_copy)
    return net