-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RLlib] added preprocessor to dataset #28420
[RLlib] added preprocessor to dataset #28420
Conversation
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple of nits.
rllib/offline/dataset_reader.py
Outdated
samples = [] | ||
for sample in batch[key]: | ||
samples.append(preprocessor.transform(sample)) | ||
batch[key] = np.stack(samples, axis=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batch[key] = np.stack([preprocessor.transform(s) for s in batch[key]])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sg.
ret.append(self._postprocess_if_needed(d)) | ||
ret = concat_samples(ret) | ||
return ret | ||
|
||
def _preprocess_if_needed(self, batch: SampleBatchType) -> SampleBatchType: | ||
# TODO: @kourosh, preprocessor is only supported for single agent case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like I can replace all of these with connectors after it's enabled by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sg, this was not supported properly yet. So let's continue with this solution for now.
count += d.count | ||
d = self._preprocess_if_needed(d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we re-arrange these to be:
...
count += d.count
d = self._preprocess_if_needed(d)
d = postprocess_actions(d, self._ioctx.worker)
d = self._postprocess_if_needed(d)
ret.append(d)
so it looks like preprocessing happens before postprocessing??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea.
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi <[email protected]>
@gjoliver I addressed all your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks nice. thanks.
Signed-off-by: ilee300a <[email protected]>
Signed-off-by: Kourosh Hakhamaneshi [email protected]
Why are these changes needed?
Dataset reader does not apply rllib preprocessors if the observation space is complex.
Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.