示例#1
0
    return h1_t, h2_t, h3_t, output_t

((h1_temp, h2_temp, h3_temp, y_hat_temp), updates) =\
    theano.scan(fn=inner_fn,
                sequences=[x],
                outputs_info=[s1_0, s2_0, s3_0, None])

ts, _, _ = y_hat_temp.shape
y_hat_in = y_hat_temp.reshape((ts*batch_size, -1))
y_in = y.reshape((ts*batch_size, -1))
cost = NllBin(y_in, y_hat_in)
cost_temp = cost.reshape((ts, batch_size))
cost = cost_temp * mask
nll = cost.sum() / mask.sum()
cost = cost.sum(axis=0).mean()
cost.name = 'cost'
nll.name = 'nll'

model.inputs = [x, y, mask]
model.params = params
model.nodes = nodes

optimizer = RMSProp(
    lr=0.0001,
    mom=0.95
)

extension = [
    GradientClipping(batch_size=batch_size),
    EpochCount(100),
    Monitoring(freq=10,
示例#2
0
文件: draw.py 项目: anirudh9119/cle
((enc_out, dec_out, canvas_out, kl_out), updates) =\
    theano.scan(fn=inner_fn,
                outputs_info=[enc.get_init_state(),
                              dec.get_init_state(),
                              canvas.get_init_state(),
                              None],
                non_sequences=[x],
                n_steps=n_steps)
for k, v in updates.iteritems():
    k.default_update = v

recon_term = NllBin(x, T.nnet.sigmoid(canvas_out[-1])).mean()
kl_term = kl_out.sum(axis=0).mean()
cost = recon_term + kl_term
cost.name = 'cost'
recon_term.name = 'recon_term'
kl_term.name = 'kl_term'
recon_err = ((x - T.nnet.sigmoid(canvas_out[-1]))**2).mean() / x.std()
recon_err.name = 'recon_err'
model.inputs = [x]
model._params = params
model.nodes = nodes

optimizer = Adam(
    lr=0.001
)

extension = [
    GradientClipping(batch_size=batch_size),
    EpochCount(10000),
    Monitoring(freq=100,
示例#3
0
    return h1_t, h2_t, h3_t, output_t

((h1_temp, h2_temp, h3_temp, y_hat_temp), updates) =\
    theano.scan(fn=inner_fn,
                sequences=[x],
                outputs_info=[s1_0, s2_0, s3_0, None])

ts, _, _ = y_hat_temp.shape
y_hat_in = y_hat_temp.reshape((ts * batch_size, -1))
y_in = y.reshape((ts * batch_size, -1))
cost = NllBin(y_in, y_hat_in)
cost_temp = cost.reshape((ts, batch_size))
cost = cost_temp * mask
nll = cost.sum() / mask.sum()
cost = cost.sum(axis=0).mean()
cost.name = 'cost'
nll.name = 'nll'

model.inputs = [x, y, mask]
model._params = params
model.nodes = nodes

optimizer = RMSProp(lr=0.0001, mom=0.95)

extension = [
    GradientClipping(batch_size=batch_size),
    EpochCount(100),
    Monitoring(freq=10,
               ddout=[cost, nll],
               data=[Iterator(valid_data, batch_size)]),
    Picklize(freq=10, path=save_path)
示例#4
0
    theano.scan(fn=inner_fn,
                outputs_info=[enc.get_init_state(),
                              dec.get_init_state(),
                              canvas.get_init_state(),
                              None],
                non_sequences=[x],
                n_steps=n_steps)

for k, v in updates.iteritems():
    k.default_update = v

recon_term = NllBin(x, T.nnet.sigmoid(canvas_out[-1])).mean()
kl_term = kl_out.sum(axis=0).mean()
cost = recon_term + kl_term
cost.name = 'cost'
recon_term.name = 'recon_term'
kl_term.name = 'kl_term'
recon_err = ((x - T.nnet.sigmoid(canvas_out[-1]))**2).mean() / x.std()
recon_err.name = 'recon_err'

model.inputs = [x]
model._params = params
model.nodes = nodes

optimizer = Adam(lr=0.001)

extension = [
    GradientClipping(batch_size=batch_size),
    EpochCount(10000),
    Monitoring(freq=100,
               ddout=[cost, recon_term, kl_term, recon_err],
示例#5
0
文件: music.py 项目: anirudh9119/cle
h4 = FullyConnectedLayer(name='h4',
                         parent=['h1', 'h2', 'h3'],
                         nout=nlabel,
                         unit='sigmoid',
                         init_W=init_W,
                         init_b=init_b)

nodes = [h1, h2, h3, h4]
rnn = Net(inputs=inputs, inputs_dim=inputs_dim, nodes=nodes)
y_hat = rnn.build_recurrent_graph(output_args=[h4])[0]
masked_y = y[mask.nonzero()]
masked_y_hat = y_hat[mask.nonzero()]
cost = NllBin(masked_y, masked_y_hat).sum()
nll = NllBin(masked_y, masked_y_hat).mean()
cost.name = 'cost'
nll.name = 'nll'
model.graphs = [rnn]

optimizer = RMSProp(
    lr=0.0001,
    mom=0.95
)

extension = [
    GradientClipping(batch_size=batch_size),
    EpochCount(100),
    Monitoring(freq=10,
               ddout=[cost, nll],
               data=[Iterator(valdata, batch_size)]),
    Picklize(freq=5,