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),
kernel_constraint=W_constraint, kernel_regularizer=kernel_regularizer)(h)
if args.batch_norm and i != args.layers - 1:
h = BatchNormalization()(h)
v = Dense(1, name='v', kernel_constraint=W_constraint, \
kernel_regularizer=kernel_regularizer)(h)
m = Dense(num_actuators, name='m', kernel_constraint=W_constraint, \
kernel_regularizer=kernel_regularizer)(h)
l0 = Dense(num_actuators * (num_actuators + 1)/2, name='l0',
kernel_constraint=W_constraint, kernel_regularizer=kernel_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=(None, num_actuators,), name="a")
a = merge([m, p, u], mode=_A, output_shape=(num_actuators,), name="a")
#q = merge([v, a], mode=_Q, output_shape=(None, num_actuators,), name="q")
q = add([v, a], name="q")
return x, u, m, v, q, p, a
评论列表
文章目录