예제 #1
0
valid_data = H5PYDataset(DATASET_PATH,
                         which_sets=('valid', ),
                         sources=('s_transition_obs', 'r_transition_obs',
                                  'obs', 'actions'))
stream_valid = DataStream(valid_data,
                          iteration_scheme=SequentialScheme(
                              valid_data.num_examples, batch_size))

net = LstmSimpleNet2Pusher(27, 6)
print(net)

if CUDA:
    net.cuda()

viz = VisdomExt([["loss", "validation loss"], ["diff"]], [
    dict(title='LSTM loss', xlabel='iteration', ylabel='loss'),
    dict(title='Diff loss', xlabel='iteration', ylabel='error')
])

means = {
    'o':
    np.array([
        2.2281456, 1.93128324, 1.63007331, 0.48472479, 0.4500702, 0.30325469,
        -0.38825685, -0.63075501, 0.63863981, -0.63173348, 1.01628101,
        -1.02707994
    ],
             dtype='float32'),
    's':
    np.array([
        2.25090551, 1.94997263, 1.6495719, 0.43379614, 0.3314755, 0.43763939,
        -0.38825685, -0.63075501, 0.63863981, -0.63173348, 1.01628101,
        -1.02707994
예제 #2
0
net = torch.nn.Sequential(
    torch.nn.Linear(15, HIDDEN_NODES),
    nn.LeakyReLU(0.2),
    torch.nn.Linear(HIDDEN_NODES, HIDDEN_NODES),
    nn.LeakyReLU(0.2),
    torch.nn.Linear(HIDDEN_NODES, HIDDEN_NODES/2),
    nn.LeakyReLU(0.2),
    torch.nn.Linear(HIDDEN_NODES/2, 6),
)

print(net)

if CUDA:
    net.cuda()

viz = VisdomExt([["loss", "validation loss"],["diff"]],[dict(title='LSTM loss', xlabel='iteration', ylabel='loss'),
dict(title='Diff loss', xlabel='iteration', ylabel='error')])


def makeIntoVariables(dat):
    input_ = np.concatenate([dat["obs"][:,:,:6], dat["actions"], dat["s_transition_obs"][:,:,:6]], axis=2)
    x, y = autograd.Variable(
        # Don't predict palet and goal position
        torch.from_numpy(input_).cuda(),
        requires_grad=False
    ), autograd.Variable(
        torch.from_numpy(dat["r_transition_obs"][:,:,:6]).cuda(),
        requires_grad=False
    )
    return x, y