def _build(self,input_shape):
num_actions = 128
N = input_shape[0] - num_actions
x = Input(shape=input_shape)
pre = wrap(x,tf.slice(x, [0,0], [-1,N]),name="pre")
action = wrap(x,tf.slice(x, [0,N], [-1,num_actions]),name="action")
ys = []
for i in range(num_actions):
_x = Input(shape=(N,))
_y = Sequential([
flatten,
*[Sequential([BN(),
Dense(self.parameters['layer'],activation=self.parameters['activation']),
Dropout(self.parameters['dropout']),])
for i in range(self.parameters['num_layers']) ],
Dense(1,activation="sigmoid")
])(_x)
_m = Model(_x,_y,name="action_"+str(i))
ys.append(_m(pre))
ys = Concatenate()(ys)
y = Dot(-1)([ys,action])
self.loss = bce
self.net = Model(x, y)
self.callbacks.append(GradientEarlyStopping(verbose=1,epoch=50,min_grad=self.parameters['min_grad']))
评论列表
文章目录