本文整理汇总了Python中cle.cle.models.Model类的典型用法代码示例。如果您正苦于以下问题:Python Model类的具体用法?Python Model怎么用?Python Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Model
)
from cle.cle.train.opt import Adam
from cle.cle.utils import unpack, OrderedDict
from cle.datasets.bouncing_balls import BouncingBalls
#data_path = '/data/lisatmp3/chungjun/bouncing_balls/bouncing_ball_2balls_16wh_20len_50000cases.npy'
#save_path = '/u/chungjun/repos/cle/saved/'
data_path = '/home/junyoung/data/bouncing_balls/bouncing_ball_2balls_16wh_20len_50000cases.npy'
save_path = '/home/junyoung/repos/cle/saved/'
batch_size = 128
res = 256
debug = 0
model = Model()
trdata = BouncingBalls(name='train',
path=data_path)
init_W = InitCell('randn')
init_U = InitCell('ortho')
init_b = InitCell('zeros')
model.inputs = trdata.theano_vars()
x, y = model.inputs
if debug:
x.tag.test_value = np.zeros((10, batch_size, res), dtype=np.float32)
y.tag.test_value = np.zeros((10, batch_size, res), dtype=np.float32)
inputs = [x, y]
inputs_dim = {'x':256, 'y':256}
示例2: Model
#data_path = '/home/junyoung/data/timit/readable/'
#save_path = '/home/junyoung/repos/sk/cle/models/nips2015/timit/pkl/'
data_path = '/data/lisa/data/timit/readable/'
save_path = '/data/lisatmp/chungjun/nips2015/timit/pkl/'
batch_size = 64
frame_size = 200
main_lstm_dim = 2000
p_x_dim = 450
x2s_dim = 450
k = 20
target_size = frame_size * k
lr = 1e-3
debug = 0
model = Model()
train_data = TIMIT(name='train',
path=data_path,
frame_size=frame_size,
shuffle=0,
use_n_gram=1)
X_mean = train_data.X_mean
X_std = train_data.X_std
valid_data = TIMIT(name='valid',
path=data_path,
frame_size=frame_size,
shuffle=0,
use_n_gram=1,
X_mean=X_mean,
示例3: Model
GradientClipping,
Monitoring,
Picklize
)
from cle.cle.train.opt import Adam
from cle.cle.utils import flatten, sharedX, unpack, OrderedDict
from cle.datasets.enwiki import EnWiki
data_path = '/home/junyoung/data/wikipedia-text/enwiki_char_and_word.npz'
save_path = '/home/junyoung/src/cle/saved/'
batch_size = 100
reset_freq = 100
debug = 0
model = Model()
train_data = EnWiki(name='train',
path=data_path)
test_data = EnWiki(name='test',
path=data_path)
init_W = InitCell('rand')
init_U = InitCell('ortho')
init_b = InitCell('zeros')
x, y = train_data.theano_vars()
if debug:
x.tag.test_value = np.zeros((10, batch_size, 1), dtype=np.float32)
y.tag.test_value = np.zeros((10, batch_size, 1), dtype=np.float32)
示例4: Model
Monitoring,
Picklize
)
from cle.cle.train.opt import Adam
from cle.cle.utils import init_tparams, OrderedDict
from cle.datasets.bouncing_balls import BouncingBalls
data_path = '/data/lisatmp3/chungjun/bouncing_balls/bouncing_ball_2balls_16wh_20len_50000cases.npy'
save_path = '/u/chungjun/repos/cle/saved/'
batch_size = 128
frame_size = 256
debug = 0
model = Model()
train_data = BouncingBalls(name='train',
path=data_path)
valid_data = BouncingBalls(name='valid',
path=data_path)
x, y = train_data.theano_vars()
if debug:
x.tag.test_value = np.zeros((10, batch_size, frame_size), dtype=np.float32)
y.tag.test_value = np.zeros((10, batch_size, frame_size), dtype=np.float32)
init_W = InitCell('randn')
init_U = InitCell('ortho')
init_b = InitCell('zeros')
示例5: main
def main(args):
trial = int(args['trial'])
pkl_name = 'rnn_gauss_%d' % trial
channel_name = 'valid_nll'
data_path = args['data_path']
save_path = args['save_path']
monitoring_freq = int(args['monitoring_freq'])
epoch = int(args['epoch'])
batch_size = int(args['batch_size'])
x_dim = int(args['x_dim'])
z_dim = int(args['z_dim'])
rnn_dim = int(args['rnn_dim'])
lr = float(args['lr'])
debug = int(args['debug'])
print "trial no. %d" % trial
print "batch size %d" % batch_size
print "learning rate %f" % lr
print "saving pkl file '%s'" % pkl_name
print "to the save path '%s'" % save_path
x2s_dim = 340
s2x_dim = 340
target_dim = x_dim - 1
model = Model()
train_data = IAMOnDB(name='train',
prep='normalize',
cond=False,
path=data_path)
X_mean = train_data.X_mean
X_std = train_data.X_std
valid_data = IAMOnDB(name='valid',
prep='normalize',
cond=False,
path=data_path,
X_mean=X_mean,
X_std=X_std)
init_W = InitCell('rand')
init_U = InitCell('ortho')
init_b = InitCell('zeros')
init_b_sig = InitCell('const', mean=0.6)
x, mask = train_data.theano_vars()
if debug:
x.tag.test_value = np.zeros((15, batch_size, x_dim), dtype=np.float32)
temp = np.ones((15, batch_size), dtype=np.float32)
temp[:, -2:] = 0.
mask.tag.test_value = temp
x_1 = FullyConnectedLayer(name='x_1',
parent=['x_t'],
parent_dim=[x_dim],
nout=x2s_dim,
unit='relu',
init_W=init_W,
init_b=init_b)
rnn = LSTM(name='rnn',
parent=['x_1'],
parent_dim=[x2s_dim],
nout=rnn_dim,
unit='tanh',
init_W=init_W,
init_U=init_U,
init_b=init_b)
theta_1 = FullyConnectedLayer(name='theta_1',
parent=['s_tm1'],
parent_dim=[rnn_dim],
nout=s2x_dim,
unit='relu',
init_W=init_W,
init_b=init_b)
theta_mu = FullyConnectedLayer(name='theta_mu',
parent=['theta_1'],
parent_dim=[s2x_dim],
nout=target_dim,
unit='linear',
init_W=init_W,
init_b=init_b)
theta_sig = FullyConnectedLayer(name='theta_sig',
parent=['theta_1'],
parent_dim=[s2x_dim],
nout=target_dim,
unit='softplus',
cons=1e-4,
init_W=init_W,
init_b=init_b_sig)
#.........这里部分代码省略.........
示例6: main
def main(args):
trial = int(args['trial'])
pkl_name = 'vrnn_gmm_%d' % trial
channel_name = 'valid_nll_upper_bound'
data_path = args['data_path']
save_path = args['save_path']
monitoring_freq = int(args['monitoring_freq'])
force_saving_freq = int(args['force_saving_freq'])
reset_freq = int(args['reset_freq'])
epoch = int(args['epoch'])
batch_size = int(args['batch_size'])
m_batch_size = int(args['m_batch_size'])
x_dim = int(args['x_dim'])
z_dim = int(args['z_dim'])
rnn_dim = int(args['rnn_dim'])
k = int(args['num_k'])
lr = float(args['lr'])
debug = int(args['debug'])
print "trial no. %d" % trial
print "batch size %d" % batch_size
print "learning rate %f" % lr
print "saving pkl file '%s'" % pkl_name
print "to the save path '%s'" % save_path
q_z_dim = 500
p_z_dim = 500
p_x_dim = 500
x2s_dim = 500
z2s_dim = 500
target_dim = x_dim * k
file_name = 'blizzard_unseg_tbptt'
normal_params = np.load(data_path + file_name + '_normal.npz')
X_mean = normal_params['X_mean']
X_std = normal_params['X_std']
model = Model()
train_data = Blizzard_tbptt(name='train',
path=data_path,
frame_size=x_dim,
file_name=file_name,
X_mean=X_mean,
X_std=X_std)
valid_data = Blizzard_tbptt(name='valid',
path=data_path,
frame_size=x_dim,
file_name=file_name,
X_mean=X_mean,
X_std=X_std)
x = train_data.theano_vars()
m_x = valid_data.theano_vars()
if debug:
x.tag.test_value = np.zeros((15, batch_size, x_dim), dtype=theano.config.floatX)
m_x.tag.test_value = np.zeros((15, m_batch_size, x_dim), dtype=theano.config.floatX)
init_W = InitCell('rand')
init_U = InitCell('ortho')
init_b = InitCell('zeros')
init_b_sig = InitCell('const', mean=0.6)
x_1 = FullyConnectedLayer(name='x_1',
parent=['x_t'],
parent_dim=[x_dim],
nout=x2s_dim,
unit='relu',
init_W=init_W,
init_b=init_b)
x_2 = FullyConnectedLayer(name='x_2',
parent=['x_1'],
parent_dim=[x2s_dim],
nout=x2s_dim,
unit='relu',
init_W=init_W,
init_b=init_b)
x_3 = FullyConnectedLayer(name='x_3',
parent=['x_2'],
parent_dim=[x2s_dim],
nout=x2s_dim,
unit='relu',
init_W=init_W,
init_b=init_b)
x_4 = FullyConnectedLayer(name='x_4',
parent=['x_3'],
parent_dim=[x2s_dim],
nout=x2s_dim,
unit='relu',
init_W=init_W,
init_b=init_b)
z_1 = FullyConnectedLayer(name='z_1',
#.........这里部分代码省略.........
示例7: Model
Monitoring,
Picklize
)
from cle.cle.train.opt import RMSProp
from cle.cle.utils import init_tparams, sharedX
from cle.cle.utils.compat import OrderedDict
from cle.datasets.music import Music
data_path = '/home/junyoung/data/music/MuseData.pickle'
save_path = '/home/junyoung/repos/cle/saved/'
batch_size = 10
nlabel = 105
debug = 1
model = Model()
train_data = Music(name='train',
path=data_path,
nlabel=nlabel)
valid_data = Music(name='valid',
path=data_path,
nlabel=nlabel)
# Choose the random initialization method
init_W = InitCell('randn')
init_U = InitCell('ortho')
init_b = InitCell('zeros')
x, y, mask = train_data.theano_vars()
# You must use THEANO_FLAGS="compute_test_value=raise" python -m ipdb
示例8: main
def main(args):
trial = int(args["trial"])
pkl_name = "vrnn_gauss_%d" % trial
channel_name = "valid_nll_upper_bound"
data_path = args["data_path"]
save_path = args["save_path"]
monitoring_freq = int(args["monitoring_freq"])
epoch = int(args["epoch"])
batch_size = int(args["batch_size"])
x_dim = int(args["x_dim"])
z_dim = int(args["z_dim"])
rnn_dim = int(args["rnn_dim"])
lr = float(args["lr"])
debug = int(args["debug"])
print "trial no. %d" % trial
print "batch size %d" % batch_size
print "learning rate %f" % lr
print "saving pkl file '%s'" % pkl_name
print "to the save path '%s'" % save_path
q_z_dim = 150
p_z_dim = 150
p_x_dim = 250
x2s_dim = 250
z2s_dim = 150
target_dim = x_dim - 1
model = Model()
train_data = IAMOnDB(name="train", prep="normalize", cond=False, path=data_path)
X_mean = train_data.X_mean
X_std = train_data.X_std
valid_data = IAMOnDB(name="valid", prep="normalize", cond=False, path=data_path, X_mean=X_mean, X_std=X_std)
init_W = InitCell("rand")
init_U = InitCell("ortho")
init_b = InitCell("zeros")
init_b_sig = InitCell("const", mean=0.6)
x, mask = train_data.theano_vars()
if debug:
x.tag.test_value = np.zeros((15, batch_size, x_dim), dtype=np.float32)
temp = np.ones((15, batch_size), dtype=np.float32)
temp[:, -2:] = 0.0
mask.tag.test_value = temp
x_1 = FullyConnectedLayer(
name="x_1", parent=["x_t"], parent_dim=[x_dim], nout=x2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
z_1 = FullyConnectedLayer(
name="z_1", parent=["z_t"], parent_dim=[z_dim], nout=z2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
rnn = LSTM(
name="rnn",
parent=["x_1", "z_1"],
parent_dim=[x2s_dim, z2s_dim],
nout=rnn_dim,
unit="tanh",
init_W=init_W,
init_U=init_U,
init_b=init_b,
)
phi_1 = FullyConnectedLayer(
name="phi_1",
parent=["x_1", "s_tm1"],
parent_dim=[x2s_dim, rnn_dim],
nout=q_z_dim,
unit="relu",
init_W=init_W,
init_b=init_b,
)
phi_mu = FullyConnectedLayer(
name="phi_mu", parent=["phi_1"], parent_dim=[q_z_dim], nout=z_dim, unit="linear", init_W=init_W, init_b=init_b
)
phi_sig = FullyConnectedLayer(
name="phi_sig",
parent=["phi_1"],
parent_dim=[q_z_dim],
nout=z_dim,
unit="softplus",
cons=1e-4,
init_W=init_W,
init_b=init_b_sig,
)
prior_1 = FullyConnectedLayer(
name="prior_1", parent=["s_tm1"], parent_dim=[rnn_dim], nout=p_z_dim, unit="relu", init_W=init_W, init_b=init_b
)
#.........这里部分代码省略.........
示例9: Model
from cle.cle.train.opt import Adam
from cle.cle.utils import flatten
from cle.cle.utils.compat import OrderedDict
from cle.datasets.mnist import MNIST
datapath = '/home/junyoung/data/mnist/mnist_binarized_salakhutdinov.pkl'
savepath = '/home/junyoung/repos/cle/saved/'
batch_size = 100
inpsz = 784
latsz = 100
n_steps = 64
debug = 0
model = Model()
data = MNIST(name='train',
unsupervised=1,
path=datapath)
init_W = InitCell('rand')
init_U = InitCell('ortho')
init_b = InitCell('zeros')
init_b_sig = InitCell('const', mean=0.6)
x, _ = data.theano_vars()
if debug:
x.tag.test_value = np.zeros((batch_size, 784), dtype=np.float32)
error = ErrorLayer(name='error',
parent=['x'],
示例10: Model
frame_size = 200
latent_size = 200
rnn_dim = 4000
p_x_dim = 700
x2s_dim = 700
k = 20
target_size = frame_size * k
lr = 3e-4
debug = 0
file_name = 'blizzard_unseg_tbptt'
normal_params = np.load(data_path + file_name + '_normal.npz')
X_mean = normal_params['X_mean']
X_std = normal_params['X_std']
model = Model()
model = Model()
train_data = Blizzard_tbptt(name='train',
path=data_path,
frame_size=frame_size,
file_name=file_name,
X_mean=X_mean,
X_std=X_std)
valid_data = Blizzard_tbptt(name='valid',
path=data_path,
frame_size=frame_size,
file_name=file_name,
X_mean=X_mean,
X_std=X_std)
示例11: main
def main(args):
trial = int(args["trial"])
pkl_name = "vrnn_gauss_%d" % trial
channel_name = "valid_nll_upper_bound"
data_path = args["data_path"]
save_path = args["save_path"]
data_path = os.path.expanduser(args["data_path"])
save_path = os.path.expanduser(args["save_path"])
monitoring_freq = int(args["monitoring_freq"])
force_saving_freq = int(args["force_saving_freq"])
reset_freq = int(args["reset_freq"])
epoch = int(args["epoch"])
batch_size = int(args["batch_size"])
m_batch_size = int(args["m_batch_size"])
x_dim = int(args["x_dim"])
z_dim = int(args["z_dim"])
rnn_dim = int(args["rnn_dim"])
lr = float(args["lr"])
debug = int(args["debug"])
print "trial no. %d" % trial
print "batch size %d" % batch_size
print "learning rate %f" % lr
print "saving pkl file '%s'" % pkl_name
print "to the save path '%s'" % save_path
q_z_dim = 500
p_z_dim = 500
p_x_dim = 600
x2s_dim = 600
z2s_dim = 500
target_dim = x_dim
file_name = "blizzard_tbptt"
normal_params = np.load(data_path + file_name + "_normal.npz")
X_mean = normal_params["X_mean"]
X_std = normal_params["X_std"]
model = Model()
train_data = Blizzard_tbptt(
name="train", path=data_path, frame_size=x_dim, file_name=file_name, X_mean=X_mean, X_std=X_std
)
valid_data = Blizzard_tbptt(
name="valid", path=data_path, frame_size=x_dim, file_name=file_name, X_mean=X_mean, X_std=X_std
)
x = train_data.theano_vars()
m_x = valid_data.theano_vars()
if debug:
x.tag.test_value = np.zeros((15, batch_size, x_dim), dtype=theano.config.floatX)
m_x.tag.test_value = np.zeros((15, m_batch_size, x_dim), dtype=theano.config.floatX)
init_W = InitCell("rand")
init_U = InitCell("ortho")
init_b = InitCell("zeros")
init_b_sig = InitCell("const", mean=0.6)
x_1 = FullyConnectedLayer(
name="x_1", parent=["x_t"], parent_dim=[x_dim], nout=x2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
x_2 = FullyConnectedLayer(
name="x_2", parent=["x_1"], parent_dim=[x2s_dim], nout=x2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
x_3 = FullyConnectedLayer(
name="x_3", parent=["x_2"], parent_dim=[x2s_dim], nout=x2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
x_4 = FullyConnectedLayer(
name="x_4", parent=["x_3"], parent_dim=[x2s_dim], nout=x2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
z_1 = FullyConnectedLayer(
name="z_1", parent=["z_t"], parent_dim=[z_dim], nout=z2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
z_2 = FullyConnectedLayer(
name="z_2", parent=["z_1"], parent_dim=[z2s_dim], nout=z2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
z_3 = FullyConnectedLayer(
name="z_3", parent=["z_2"], parent_dim=[z2s_dim], nout=z2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
z_4 = FullyConnectedLayer(
name="z_4", parent=["z_3"], parent_dim=[z2s_dim], nout=z2s_dim, unit="relu", init_W=init_W, init_b=init_b
)
rnn = LSTM(
name="rnn",
parent=["x_4", "z_4"],
parent_dim=[x2s_dim, z2s_dim],
nout=rnn_dim,
unit="tanh",
init_W=init_W,
#.........这里部分代码省略.........
示例12: Model
# Set your dataset
data_path = ['/data/lisa/data/cifar10/pylearn2_gcn_whitened/train.npy',
'/u/chungjun/repos/cle/labels/trainy.npy']
test_data_path = ['/data/lisa/data/cifar10/pylearn2_gcn_whitened/test.npy',
'/u/chungjun/repos/cle/labels/testy.npy']
save_path = '/u/chungjun/repos/cle/saved/'
#data_path = ['/home/junyoung/data/cifar10/pylearn2_gcn_whitened/train.npy',
# '/home/junyoung/data/cifar10/pylearn2_gcn_whitened/trainy.npy']
#test_data_path = ['/home/junyoung/data/cifar10/pylearn2_gcn_whitened/test.npy',
# '/home/junyoung/data/cifar10/pylearn2_gcn_whitened/testy.npy']
#save_path = '/home/junyoung/repos/cle/saved/'
batch_size = 128
debug = 0
model = Model()
train_data = CIFAR10(name='train',
path=data_path)
test_data = CIFAR10(name='test',
path=test_data_path)
# Choose the random initialization method
init_W = InitCell('rand')
init_b = InitCell('zeros')
# Define nodes: objects
model.inputs = train_data.theano_vars()
x, y = model.inputs
# You must use THEANO_FLAGS="compute_test_value=raise" python -m ipdb
if debug: