os.environ['ODIN'] = 'float32,gpu,%s,seed=12' % arg['backend'] from odin import backend as K from odin import nnet as N from odin import fuel, training from six.moves import cPickle # =========================================================================== # Load data # =========================================================================== USE_MNIST_DATA = True if 'mnist' in arg['ds'].lower() else False if USE_MNIST_DATA: ds = fuel.load_mnist() else: ds = fuel.load_cifar10() X = K.placeholder(shape=(None, ) + ds['X_train'].shape[1:], name='X') y = K.placeholder(shape=(None, ), name='y', dtype='int32') # =========================================================================== # Build network # =========================================================================== ops = N.Sequence([ N.Dimshuffle((0, 1, 2, 'x')) if USE_MNIST_DATA else None, N.BatchNorm(axes='auto'), N.Conv(32, (3, 3), strides=(1, 1), pad='same', activation=K.relu), N.Pool(pool_size=(2, 2), strides=None), N.Conv(64, (3, 3), strides=(1, 1), pad='same', activation=K.relu), N.Pool(pool_size=(2, 2), strides=None), N.Flatten(outdim=2),
from __future__ import print_function, division, absolute_import import os os.environ['ODIN'] = 'float32,gpu,theano,seed=12082518' import numpy as np from odin import fuel as F, nnet as N, backend as K, training, utils # =========================================================================== # Load dataset # =========================================================================== ds = F.load_cifar10() print(ds) X_learn = ds['X_train'][:].astype('float32') / 255. y_learn = ds['y_train'] X_test = ds['X_test'][:].astype('float32') / 255. y_test = ds['y_test'] # =========================================================================== # Create network # =========================================================================== X = K.placeholder(shape=(None, ) + X_learn.shape[1:], name='X') y_true = K.placeholder(shape=(None, ), name='y_true', dtype='int32') f = N.Sequence([ N.Dimshuffle(pattern=(0, 2, 3, 1)), N.Conv(32, (3, 3), pad='same', stride=(1, 1), activation=K.relu), N.Conv(32, (3, 3), pad='same', stride=(1, 1), activation=K.relu), N.Pool(pool_size=(2, 2), ignore_border=True, strides=None, mode='max'), N.Dropout(level=0.25),
import os os.environ['ODIN'] = 'float32,gpu,theano,seed=12,cnmem=0.4' from odin import backend as K from odin import nnet as N from odin import fuel, training from odin.utils import get_modelpath, ArgController, stdio, get_logpath from six.moves import cPickle stdio(get_logpath('tmp.log')) # =========================================================================== # Load data # =========================================================================== ds = fuel.load_cifar10() print(ds) X_train = K.placeholder(shape=(None,) + ds['X_train'].shape[1:], name='X_train') X_score = K.placeholder(shape=(None,) + ds['X_train'].shape[1:], name='X_score') y = K.placeholder(shape=(None,), name='y', dtype='int32') # =========================================================================== # Build network # =========================================================================== ops = N.Sequence([ N.Flatten(outdim=2), N.Dense(512, activation=K.relu), N.Dense(256, activation=K.relu), N.Dense(10, activation=K.softmax) ])