def createLayers():
x = Input(shape=env.observation_space.shape, name='x')
u = Input(shape=env.action_space.shape, name='u')
if args.batch_norm:
h = BatchNormalization()(x)
else:
h = x
for i in xrange(args.layers):
h = Dense(args.hidden_size, activation=args.activation, name='h'+str(i+1),
W_constraint=W_constraint, W_regularizer=regularizer())(h)
if args.batch_norm and i != args.layers - 1:
h = BatchNormalization()(h)
v = Dense(1, name='v', W_constraint=W_constraint, W_regularizer=regularizer())(h)
m = Dense(num_actuators, name='m', W_constraint=W_constraint, W_regularizer=regularizer())(h)
l0 = Dense(num_actuators * (num_actuators + 1)/2, name='l0',
W_constraint=W_constraint, W_regularizer=regularizer())(h)
l = Lambda(_L, output_shape=(num_actuators, num_actuators), name='l')(l0)
p = Lambda(_P, output_shape=(num_actuators, num_actuators), name='p')(l)
a = merge([m, p, u], mode=_A, output_shape=(num_actuators,), name="a")
q = merge([v, a], mode=_Q, output_shape=(num_actuators,), name="q")
return x, u, m, v, q, p, a
评论列表
文章目录