Skip to content

Commit

Permalink
[bug-fix] Make resnet barracuda-compatible (#5358)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ervin T committed May 13, 2021
1 parent 47ba9dd commit 894bffa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ml-agents/mlagents/trainers/torch/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ def __init__(
layers.append(ResNetBlock(channel))
last_channel = channel
layers.append(Swish())
self.final_flat_size = n_channels[-1] * height * width
self.dense = linear_layer(
n_channels[-1] * height * width,
self.final_flat_size,
output_size,
kernel_init=Initialization.KaimingHeNormal,
kernel_gain=1.41, # Use ReLU gain
Expand All @@ -292,7 +293,6 @@ def __init__(
def forward(self, visual_obs: torch.Tensor) -> torch.Tensor:
if not exporting_to_onnx.is_exporting():
visual_obs = visual_obs.permute([0, 3, 1, 2])
batch_size = visual_obs.shape[0]
hidden = self.sequential(visual_obs)
before_out = hidden.reshape(batch_size, -1)
before_out = hidden.reshape(-1, self.final_flat_size)
return torch.relu(self.dense(before_out))

0 comments on commit 894bffa

Please sign in to comment.