Exemple #1
0
def run():
    disturb_mem.disturb_mem()


    b = sharedX(np.zeros((2,)))
    channels = OrderedDict()

    disturb_mem.disturb_mem()

    v_max = b.max(axis=0)
    v_min = b.min(axis=0)
    v_range = v_max - v_min

    updates = []
    for i, val in enumerate([
            v_max.max(),
            v_max.min(),
            v_range.max(),
            ]):
        disturb_mem.disturb_mem()
        s = sharedX(0., name='s_'+str(i))
        updates.append((s, val))

    for var in theano.gof.graph.ancestors(update for var, update in updates):
        if var.name is not None:
            if var.name[0] != 's' or len(var.name) != 2:
                var.name = None

    for key in channels:
        updates.append((s, channels[key]))
    file_path='nondeterminism_6.txt'
    mode = RecordMode(file_path=file_path,
                      replay=0)
    f = theano.function([], mode=mode, updates=updates, on_unused_input='ignore', name='f')

    """
    print 'type(f): ',type(f)
    print 'elements of f:'
    for elem in dir(f):
        print '\t',elem
    print 'type(f.fn): ',type(f.fn)
    print 'elements of f.fn:'
    for elem in dir(f.fn):
        print '\t',elem
    """

    trials = 1

    for i in xrange(trials):
        disturb_mem.disturb_mem()
        f()

    mode.record.f.flush()
    mode.record.f.close()

    mode.set_record(Record(file_path=file_path, replay=1))

    for i in xrange(trials):
        disturb_mem.disturb_mem()
        f()
Exemple #2
0
def run():
    disturb_mem.disturb_mem()

    b = sharedX(np.zeros((2, )))
    channels = OrderedDict()

    disturb_mem.disturb_mem()

    v_max = b.max(axis=0)
    v_min = b.min(axis=0)
    v_range = v_max - v_min

    updates = []
    for i, val in enumerate([
            v_max.max(),
            v_max.min(),
            v_range.max(),
    ]):
        disturb_mem.disturb_mem()
        s = sharedX(0., name='s_' + str(i))
        updates.append((s, val))

    for var in theano.gof.graph.ancestors(update for var, update in updates):
        if var.name is not None:
            if var.name[0] != 's' or len(var.name) != 2:
                var.name = None

    for key in channels:
        updates.append((s, channels[key]))
    file_path = 'nondeterminism_5.txt'
    mode = RecordMode(file_path=file_path, replay=0)
    f = theano.function([],
                        mode=mode,
                        updates=updates,
                        on_unused_input='ignore',
                        name='f')

    for i in xrange(100):
        disturb_mem.disturb_mem()
        f()

    mode.record.f.flush()
    mode.record.f.close()

    mode.set_record(Record(file_path=file_path, replay=1))

    for i in xrange(100):
        disturb_mem.disturb_mem()
        f()
Exemple #3
0
def run(replay):
    disturb_mem.disturb_mem()

    mode = RecordMode(file_path="nondeterminism_4.txt", replay=replay)

    b = sharedX(np.zeros((1, )), name='b')
    channels = OrderedDict()

    disturb_mem.disturb_mem()

    v_max = b.max(axis=0)
    v_min = b.min(axis=0)
    v_range = v_max - v_min

    updates = []
    for i, val in enumerate([
            v_max.max(),
            v_max.min(),
            v_range.max(),
    ]):
        disturb_mem.disturb_mem()
        s = sharedX(0., name='s_' + str(i))
        updates.append((s, val))

    for var in theano.gof.graph.ancestors(update for var, update in updates):
        if var.name is not None and var.name is not 'b':
            if var.name[0] != 's' or len(var.name) != 2:
                var.name = None

    for key in channels:
        updates.append((s, channels[key]))
    f = theano.function([],
                        mode=mode,
                        updates=updates,
                        on_unused_input='ignore',
                        name='f')
    for output in f.maker.fgraph.outputs:
        mode.record.handle_line(var_descriptor(output) + '\n')
    disturb_mem.disturb_mem()
    f()

    mode.record.f.flush()
    mode.record.f.close()
Exemple #4
0
def run(replay):
    disturb_mem.disturb_mem()

    mode = RecordMode(file_path= "nondeterminism_4.txt",
                      replay=replay)

    b = sharedX(np.zeros((2,)), name='b')
    channels = OrderedDict()

    disturb_mem.disturb_mem()

    v_max = b.max(axis=0)
    v_min = b.min(axis=0)
    v_range = v_max - v_min

    updates = []
    for i, val in enumerate([
            v_max.max(),
            v_max.min(),
            v_range.max(),
            ]):
        disturb_mem.disturb_mem()
        s = sharedX(0., name='s_'+str(i))
        updates.append((s, val))

    for var in theano.gof.graph.ancestors(update for var, update in updates):
        if var.name is not None and var.name is not 'b':
            if var.name[0] != 's' or len(var.name) != 2:
                var.name = None

    for key in channels:
        updates.append((s, channels[key]))
    f = theano.function([], mode=mode, updates=updates, on_unused_input='ignore', name='f')
    for output in f.maker.fgraph.outputs:
        mode.record.handle_line(var_descriptor(output)+'\n')
    disturb_mem.disturb_mem()
    f()

    mode.record.f.flush()
    mode.record.f.close()
Exemple #5
0
from pylearn2.config import yaml_parse
from pylearn2.devtools import disturb_mem
import sys

disturb_mem.disturb_mem()

_, replay = sys.argv
replay = int(replay)

disturb_mem.disturb_mem()
disturb_mem.disturb_mem()
disturb_mem.disturb_mem()
disturb_mem.disturb_mem()
disturb_mem.disturb_mem()
disturb_mem.disturb_mem()

yaml_src = """
!obj:pylearn2.train.Train {
    dataset:  &train !obj:pylearn2.datasets.mnist.MNIST {
        which_set: "train",
        #binarize: 1,
        one_hot: 1,
        start: 0,
        stop: 100
    },
        model: !obj:galatea.dbm.inpaint.super_dbm.MLP_Wrapper {
                        decapitate: 0,
                        super_dbm: !obj:galatea.dbm.inpaint.super_dbm.SuperDBM {
                              batch_size : 100,
                              niter: 6, #note: since we have to backprop through the whole thing, this does
                                         #increase the memory usage