(self, obs_shape, feature_dim,
channels=[16, 32, 32],
num_layers=2,
num_filters=32,
output_logits=False,
image_channel=3)
| 151 | class PixelDelta2DEncoder(nn.Module): |
| 152 | """Flare encoder of pixels observations.""" |
| 153 | def __init__(self, obs_shape, feature_dim, |
| 154 | channels=[16, 32, 32], |
| 155 | num_layers=2, |
| 156 | num_filters=32, |
| 157 | output_logits=False, |
| 158 | image_channel=3): |
| 159 | super().__init__() |
| 160 | |
| 161 | assert len(obs_shape) == 3 |
| 162 | self.obs_shape = obs_shape |
| 163 | self.feature_dim = feature_dim |
| 164 | self.num_layers = num_layers |
| 165 | self.image_channel = image_channel |
| 166 | |
| 167 | time_step = obs_shape[0] // self.image_channel |
| 168 | |
| 169 | self.convs = nn.ModuleList( |
| 170 | [nn.Conv2d(self.image_channel, num_filters, 3, stride=2)] |
| 171 | ) |
| 172 | self.convs.append(nn.Conv2d(num_filters, num_filters, 3, stride=1)) |
| 173 | self.convs.append(nn.Conv2d(num_filters, num_filters, 3, stride=1)) |
| 174 | for i in range(2, num_layers - 1): |
| 175 | self.convs.append(nn.Conv2d(num_filters, num_filters, 3, stride=1)) |
| 176 | self.outputs = dict() |
| 177 | |
| 178 | x = torch.randn([32]+list(obs_shape)) |
| 179 | self.out_dim = self.forward_conv(x,flatten=False).shape[-1] |
| 180 | |
| 181 | print('conv output dim: ' + str(self.out_dim)) |
| 182 | |
| 183 | self.fc = nn.Linear(num_filters * self.out_dim * self.out_dim * (2*time_step-2), self.feature_dim) |
| 184 | self.ln = nn.LayerNorm(self.feature_dim) |
| 185 | |
| 186 | self.output_logits = output_logits |
| 187 | |
| 188 | |
| 189 | def reparameterize(self, mu, logstd): |
nothing calls this directly
no test coverage detected