コード例 #1
0
ファイル: feed_forward.py プロジェクト: 52nlp/deepy
 def test(self):
     from deepy.dataset import HeartScaleDataset
     from deepy.conf import NetworkConfig
     from deepy import NeuralLayer
     import logging
     logging.basicConfig(level=logging.INFO)
     conf = NetworkConfig(input_size=13)
     conf.layers = [NeuralLayer(10), NeuralLayer(5), NeuralLayer(1, 'linear')]
     ff = NeuralRegressor(conf)
     t = SGDTrainer(ff)
     train_set = [(np.array([[1,2,3,4,5,6,7,8,9,10,11,12,13]]), np.array([[1,0]]))]
     a = [HeartScaleDataset(single_target=True).train_set()]
     b = [HeartScaleDataset(single_target=True).valid_set()]
     for k in list(t.train(a, b)):
         pass
     print k
コード例 #2
0
    def __init__(self, input_dim, config=None, input_tensor=None):
        logging.info(DEEPY_MESSAGE)
        self.network_config = config if config else NetworkConfig()
        self.input_dim = input_dim
        self.input_tensor = input_tensor
        self.parameter_count = 0

        self.parameters = []
        self.free_parameters = []

        self.training_updates = []
        self.updates = []

        self.input_variables = []
        self.target_variables = []

        self.training_callbacks = []
        self.testing_callbacks = []
        self.epoch_callbacks = []

        self.layers = []

        self._hidden_outputs = []
        self.training_monitors = []
        self.testing_monitors = []

        self.setup_variables()
        self.train_logger = TrainLogger()

        if self.network_config.layers:
            self.stack(self.network_config.layers)
コード例 #3
0
ファイル: rnn.py プロジェクト: 52nlp/deepy
import time
import logging

import numpy as np

from deepy.layers.recurrent import RecurrentLayer, RecurrentNetwork
from deepy.conf import NetworkConfig, TrainerConfig
from deepy.utils.functions import FLOATX
from deepy import SGDTrainer


logging.basicConfig(level=logging.INFO)

if __name__ == '__main__':
    net_conf = NetworkConfig(input_size=6)
    net_conf.layers = [RecurrentLayer(size=10, activation='sigmoid', bptt=True)]

    trainer_conf = TrainerConfig()
    trainer_conf.learning_rate = 0.03
    trainer_conf.weight_l2 = 0.0001
    trainer_conf.hidden_l2 = 0.0001
    trainer_conf.monitor_frequency = trainer_conf.validation_frequency = trainer_conf.test_frequency = 1

    network = RecurrentNetwork(net_conf)
    trainer = SGDTrainer(network)

    data = np.array([[1,0,0,0,0,0],
                     [0,1,0,0,0,0],
                     [0,0,1,0,0,0],
                     [0,0,0,1,0,0],
コード例 #4
0
ファイル: auto_encoder.py プロジェクト: 52nlp/deepy

import time
import logging

import numpy as np

from deepy.conf import NetworkConfig, TrainerConfig
from deepy.utils.functions import FLOATX
from deepy import NeuralLayer, SGDTrainer, AutoEncoder


logging.basicConfig(level=logging.INFO)

if __name__ == '__main__':
    net_conf = NetworkConfig(input_size=6)
    net_conf.layers = [NeuralLayer(3, 'sigmoid'), NeuralLayer(6, 'softmax')]

    trainer_conf = TrainerConfig()
    trainer_conf.learning_rate = 0.03
    trainer_conf.weight_l2 = 0.0001
    trainer_conf.hidden_l2 = 0.0001
    trainer_conf.monitor_frequency = trainer_conf.validation_frequency = trainer_conf.test_frequency = 1000

    network = AutoEncoder(net_conf)
    trainer = SGDTrainer(network)

    data = np.array([[1,0,0,0,0,0],
                     [0,1,0,0,0,0],
                     [0,0,1,0,0,0],
                     [0,0,0,1,0,0],