-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make RL training compatible with PyTorch (#1520)
* Make RLEstimator() PyTorch compatible & modify cartpole notebook * set use_pytorch to False by default * minor refactor; check in first unit test * indent correction
- Loading branch information
1 parent
fbdca81
commit 09ad9a7
Showing
8 changed files
with
60 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
31 changes: 31 additions & 0 deletions
31
reinforcement_learning/common/tests/unit/test_ray_launcher.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2017-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
from __future__ import absolute_import | ||
import pytest | ||
from mock import Mock, MagicMock, patch | ||
|
||
from sagemaker_rl.ray_launcher import SageMakerRayLauncher | ||
|
||
@patch("sagemaker_rl.ray_launcher.SageMakerRayLauncher.__init__", return_value=None) | ||
@patch("sagemaker_rl.ray_launcher.change_permissions_recursive") | ||
def test_pytorch_save_checkpoint_and_serving_model(change_permission, launcher_init): | ||
launcher = SageMakerRayLauncher() | ||
launcher.copy_checkpoints_to_model_output = Mock() | ||
launcher.create_tf_serving_model = Mock() | ||
launcher.save_experiment_config = Mock() | ||
|
||
launcher.save_checkpoint_and_serving_model(use_pytorch=True) | ||
launcher.create_tf_serving_model.assert_not_called() | ||
launcher.save_checkpoint_and_serving_model(use_pytorch=False) | ||
launcher.create_tf_serving_model.assert_called_once() | ||
assert 4 == change_permission.call_count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters