Example #1
0
 def setUp(self):
     self.current_dir = os.getcwd()
     # go into this file's directory
     abspath = os.path.realpath(__file__)
     dname = os.path.dirname(abspath)
     os.chdir(dname)
     # change sys.stdout to StringIO for the duration of the test to test console output
     self.saved_stdout = sys.stdout
     self.out = StringIO()
     sys.stdout = self.out
     # configure the root logger
     config_root_logger()
     # get a logger for this session
     self.log = logging.getLogger(__name__)
     # set the paths for the logs (comes from reading logging_config.json)
     self.error_path = '../logs/error/errors.log'
     self.info_path  = '../logs/info/info.log'
     self.paths = [self.error_path, self.info_path]
Example #2
0
 def setUp(self):
     self.current_dir = os.getcwd()
     # go into this file's directory
     abspath = os.path.realpath(__file__)
     dname = os.path.dirname(abspath)
     os.chdir(dname)
     # change sys.stdout to StringIO for the duration of the test to test console output
     self.saved_stdout = sys.stdout
     self.out = StringIO()
     sys.stdout = self.out
     # configure the root logger
     config_root_logger()
     # get a logger for this session
     self.log = logging.getLogger(__name__)
     # set the paths for the logs (comes from reading logging_config.json)
     self.error_path = '../logs/error/errors.log'
     self.info_path = '../logs/info/info.log'
     self.paths = [self.error_path, self.info_path]
Example #3
0
        elif subset is TEST:
            return self.test_shape
        else:
            return None


def main():
    pass



if __name__ == '__main__':
    # http://www.physionet.org/physiobank/database/apnea-ecg/

    # if we want logging
    config_root_logger()

    i=0
    for f in find_train_files(basedir, label_ext):
        if i==0:
            data = numpy.fromfile(f, dtype=numpy.bool)
            print(data.shape)
        else:
            pass
        i+=1

    i=0
    for f in find_train_files(basedir, data_ext):
        if i == 0:
            data = numpy.fromfile(f, dtype=numpy.float16)
            print(data.shape)
Example #4
0
from __future__ import print_function
from opendeep.models.single_layer.basic import SoftmaxLayer
# import the dataset and optimizer to use
from opendeep.data.standard_datasets.image.mnist import MNIST
from opendeep.optimization.adadelta import AdaDelta

if __name__ == '__main__':
    # set up the logging environment to display outputs (optional)
    # although this is recommended over print statements everywhere
    import logging
    from opendeep.log import config_root_logger
    config_root_logger()
    log = logging.getLogger(__name__)
    log.info("Creating softmax!")

    # grab the MNIST dataset
    mnist = MNIST()
    # create the softmax classifier
    s = SoftmaxLayer(input_size=28 * 28, output_size=10, out_as_probs=False)
    # make an optimizer to train it (AdaDelta is a good default)
    optimizer = AdaDelta(model=s, dataset=mnist, epochs=20)
    # perform training!
    optimizer.train()
    # test it on some images!
    test_data, test_labels = mnist.test_inputs[:25], mnist.test_targets[:25]
    # use the run function!
    preds = s.run(test_data)
    print('-------')
    print(preds)
    print(test_labels.astype('int32'))
    print()