Closed lk1983823 closed 2 years ago
I now fix this error! In the CustomEncoder class, h = torch.relu(self.fc2(x))
should be h = torch.relu(self.fc2(h))
class CustomEncoder(nn.Module):
def __init__(self, observation_shape, feature_size):
super(CustomEncoder, self).__init__()
self.feature_size = feature_size
self.fc1 = nn.Linear(observation_shape[0], feature_size)
self.fc2 = nn.Linear(feature_size, feature_size)
def forward(self, x):
h = torch.relu(self.fc1(x))
h = torch.relu(self.fc2(x))
return h
Suggest to modify the tutorials in the website.
@lk1983823 Thank you for reporting this! It's fixed in this commit: https://github.com/takuseno/d3rlpy/commit/cd7681ca150d89422f9865daaaa896ead13a7b73 . The change will be reflected to latest
documentation.
https://d3rlpy.readthedocs.io/en/latest/
Follow the tutorial https://d3rlpy.readthedocs.io/en/v1.1.1/tutorials/customize_neural_network.html, I try to customize encoders for critic and actor in SAC. I find some errors: First, all the
def __init__()
should be followed bysuper(Parentclass_name, self).__init__()
, otherwise it will show errors asAttributeError: cannot assign module before Module.__init__() call
Second, even I have fixed this, I still encounter new problems:When I run the following code:
It shows:
I have no idea as to how to fix this. I don't think the feature size should be equal to the observation size, or is there some wrong during the encoder building process? In the above example, my observation size is 4. Thanks for the reply!