Beispiel #1
0
    def value(self, obs):
        obs = obs / 255.0
        out = self.conv1(obs)
        out = layers.pool2d(input=out,
                            pool_size=2,
                            pool_stride=2,
                            pool_type='max')
        out = self.conv2(out)
        out = layers.pool2d(input=out,
                            pool_size=2,
                            pool_stride=2,
                            pool_type='max')
        out = self.conv3(out)
        out = layers.pool2d(input=out,
                            pool_size=2,
                            pool_stride=2,
                            pool_type='max')
        out = self.conv4(out)
        out = layers.flatten(out, axis=1)

        if self.algo == 'Dueling':
            As = self.fc2_adv(self.fc1_adv(out))
            V = self.fc2_val(self.fc1_val(out))
            Q = As + (V - layers.reduce_mean(As, dim=1, keep_dim=True))
        else:
            Q = self.fc1(out)
        return Q
 def value(self, obs):
     obs = obs / 255.0
     out = self.conv1(obs)
     out = layers.pool2d(input=out,
                         pool_size=2,
                         pool_stride=2,
                         pool_type='max',
                         data_format="NHWC")
     out = self.conv2(out)
     out = layers.pool2d(input=out,
                         pool_size=2,
                         pool_stride=2,
                         pool_type='max',
                         data_format="NHWC")
     out = layers.flatten(out, axis=1)
     Q = self.fc1(out)
     return Q
Beispiel #3
0
    def value(self, obs):
        obs = obs / 255.0
        # print(len(obs.shape))
        # if len(obs.shape)>4:
        #     obs = layers.squeeze(input=obs,axes=[-1])
        # obs = layers.squeeze(input=obs)
        out = self.conv1(obs)
        out = layers.pool2d(
            input=out, pool_size=2, pool_stride=2, pool_type='max')
        out = self.conv2(out)
        out = layers.pool2d(
            input=out, pool_size=2, pool_stride=2, pool_type='max')
        out = self.conv3(out)
        out = layers.pool2d(
            input=out, pool_size=2, pool_stride=2, pool_type='max')
        out = self.conv4(out)
        out = layers.flatten(out, axis=1)

        Q = self.fc1(out)
        return Q
Beispiel #4
0
    def value(self, obs):
        out = self.conv1(obs)
        out = layers.pool2d(input=out,
                            pool_size=2,
                            pool_stride=2,
                            pool_type='max')
        out = self.conv2(out)
        out = layers.pool2d(input=out,
                            pool_size=2,
                            pool_stride=2,
                            pool_type='max')
        out = self.conv3(out)
        out = layers.pool2d(input=out,
                            pool_size=2,
                            pool_stride=2,
                            pool_type='max')
        out = self.conv4(out)
        out = layers.flatten(out, axis=1)

        Q = self.fc1(out)
        return Q
Beispiel #5
0
 def value(self, obs):
     #         obs = obs / 255.0
     print('value', obs.shape)
     out = self.conv1(obs)
     out = layers.pool2d(input=out,
                         pool_size=4,
                         pool_stride=2,
                         pool_type='max')
     #         out = self.conv2(out)
     #         out = layers.pool2d(
     #             input=out, pool_size=2, pool_stride=2, pool_type='max')
     #         out = self.conv3(out)
     #         out = layers.pool2d(
     #             input=out, pool_size=2, pool_stride=2, pool_type='max')
     #         out = self.conv4(out)
     out = layers.flatten(out, axis=1)
     start = self.fc1(out)
     start = paddle.fluid.layers.softmax(start)
     end = self.fc2(out)
     end = paddle.fluid.layers.softmax(end)
     num = self.fc3(out)
     vec = layers.concat([start, end, num], axis=1)
     return vec