Skip to content

Commit

Permalink
Fix some typos. (#1095)
Browse files Browse the repository at this point in the history
Signed-off-by: Yulv-git <[email protected]>
  • Loading branch information
Yulv-git authored Apr 20, 2023
1 parent bb4d877 commit 1fc50bf
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion benchmark/fluid/MADDPG/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def train_agent():
final_ep_ag_rewards = [] # agent rewards for training curve

if args.restore:
# restore modle
# restore model
for i in range(len(agents)):
model_file = args.model_dir + '/agent_' + str(i)
if not os.path.exists(model_file):
Expand Down
2 changes: 1 addition & 1 deletion benchmark/fluid/offline-Q-learning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ learn_program = parl.compile(learn_program, loss=training_loss)

## Demonstration

We provide a demonstration of offline Q-learning with parallel executing, in which we seperate the procedures of collecting data and training the model. First we collect data by interacting with the environment and save them to a replay memory file, and then fit and evaluate the Q network with the collected data. Repeat these two steps to improve the performance gradually.
We provide a demonstration of offline Q-learning with parallel executing, in which we separate the procedures of collecting data and training the model. First we collect data by interacting with the environment and save them to a replay memory file, and then fit and evaluate the Q network with the collected data. Repeat these two steps to improve the performance gradually.

### Dependencies:
+ [paddlepaddle==1.8.5](https://github.com/PaddlePaddle/Paddle)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/torch/ES/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def step(self):

while num_episodes < self.config['min_episodes_per_batch'] or \
num_timesteps < self.config['min_steps_per_batch']:
# setting the lastest params to the actor, getting the fitness and the noise seed sync.
# setting the latest params to the actor, getting the fitness and the noise seed sync.
future_object_ids = [remote_actor.sample(self.latest_flat_weights) \
for remote_actor in self.remote_actors]
results = [
Expand Down
2 changes: 1 addition & 1 deletion benchmark/torch/a2c/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def step(self):
"""
1.setting latest_params to each actor model
2.getting the sample data from all the actors synchronizely
3.traing the model with the sample data and the params is upgraded, and goto step 1
3.training the model with the sample data and the params is upgraded, and goto step 1
"""

latest_params = self.agent.get_weights()
Expand Down
2 changes: 1 addition & 1 deletion benchmark/torch/maddpg/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def main():
agents.append(agent)

if args.restore:
# restore modle
# restore model
for i in range(len(agents)):
model_file = args.model_dir + '/agent_' + str(i)
if not os.path.exists(model_file):
Expand Down
2 changes: 1 addition & 1 deletion benchmark/torch/mappo/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def main():
buffers.append(bu)

if args.restore:
# restore modle
# restore model
for i in range(len(agents)):
model_file = args.model_dir + '/' + args.env_name + '/agent_' + str(
i)
Expand Down
4 changes: 2 additions & 2 deletions docs/basic_structure/agent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Methods

3. predict(self, obs)

Predict the action with current observation of the enviroment. Note that this function will only do the prediction and it doesn't try any exploration.
Predict the action with current observation of the environment. Note that this function will only do the prediction and it doesn't try any exploration.
To explore in the action space, you should create your process in `sample` function below.
Basically, this function is often used in test process.

4. sample(self, obs)

Predict the action given current observation of the enviroment.
Predict the action given current observation of the environment.
Additionaly, action will be added noise here to explore a new trajectory.
Basically, this function is often used in training process.

Expand Down
4 changes: 2 additions & 2 deletions docs/locale/zh_CN/LC_MESSAGES/basic_structure.po
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ msgstr ""

#: ../../basic_structure/agent.rst:17
msgid ""
"Predict the action with current observation of the enviroment. Note that "
"Predict the action with current observation of the environment. Note that "
"this function will only do the prediction and it doesn't try any "
"exploration. To explore in the action space, you should create your "
"process in `sample` function below. Basically, this function is often "
Expand All @@ -66,7 +66,7 @@ msgstr ""

#: ../../basic_structure/agent.rst:23
msgid ""
"Predict the action given current observation of the enviroment. "
"Predict the action given current observation of the environment. "
"Additionaly, action will be added noise here to explore a new trajectory."
" Basically, this function is often used in training process."
msgstr ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def sample(self, obs):
Return:
value (paddle.tensor): predicted state value
action (paddle.tensor): actions sampled from a distribution
action_log_probs (paddle.tensor): the log probabilites of action
action_log_probs (paddle.tensor): the log probabilities of action
"""

batch_size = obs.shape[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def sample(self, obs):
Return:
value (torch.tensor): predicted state value
action (torch.tensor): actions sampled from a distribution
action_log_probs (torch.tensor): the log probabilites of action
action_log_probs (torch.tensor): the log probabilities of action
"""
with torch.no_grad():
value = self.critic(obs)
Expand Down
2 changes: 1 addition & 1 deletion examples/ES/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def step(self):

while num_episodes < self.config['min_episodes_per_batch'] or \
num_timesteps < self.config['min_steps_per_batch']:
# setting the lastest to the actors and get the fitness, noise seed sync.
# setting the latest to the actors and get the fitness, noise seed sync.
future_object_ids = [remote_actor.sample(self.latest_flat_weights) \
for remote_actor in self.remote_actors]
results = [
Expand Down
2 changes: 1 addition & 1 deletion examples/MADDPG/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def main():
agents.append(agent)

if args.restore:
# restore modle
# restore model
for i in range(len(agents)):
model_file = args.model_dir + '/agent_' + str(i)
if not os.path.exists(model_file):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _new_ready_client(self):

def Send(self, request, context):
""" Implement Send function in SimulatorServicer
Everytime a request comming, will create a new thread to handle
Everytime a request coming, will create a new thread to handle
"""
ident, obs, reward, done, info = request.id, request.observation, request.reward, request.done, request.info
client = self.clients[ident]
Expand Down
6 changes: 3 additions & 3 deletions examples/others/deepes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ def reward_normalize(reward):
for epcho in range(100):
rewards = []
noises = []
lastest_flat_weights = agent.get_flat_weights()
latest_flat_weights = agent.get_flat_weights()

for episode in range(10):
noise = np.random.randn(agent.weights_total_size)
perturbation = noise * 0.05

agent.set_flat_weights(lastest_flat_weights + perturbation)
agent.set_flat_weights(latest_flat_weights + perturbation)
ep_reward = evaluate(env, agent)

noises.append(noise)
rewards.append(ep_reward)

normalized_rewards = reward_normalize(rewards)
agent.set_flat_weights(lastest_flat_weights)
agent.set_flat_weights(latest_flat_weights)
agent.learn(normalized_rewards, noises)
# evaluate
if (epcho % 10) == 0:
Expand Down
4 changes: 2 additions & 2 deletions parl/core/agent_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def learn(self, *args, **kwargs):
raise NotImplementedError

def predict(self, *args, **kwargs):
"""Predict the action when given the observation of the enviroment.
"""Predict the action when given the observation of the environment.
In general, this function is used in test process.
Expand All @@ -66,7 +66,7 @@ def predict(self, *args, **kwargs):
raise NotImplementedError

def sample(self, *args, **kwargs):
"""Sample the action when given the observation of the enviroment.
"""Sample the action when given the observation of the environment.
In general, this function is used in train process.
Expand Down
6 changes: 3 additions & 3 deletions parl/core/paddle/tests/policy_distribution_test_paddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def test_kl(self):
dist2 = self.get_dist(mean=mean, log_std=paddle.log(std2))
kl = dist1.kl(dist2)
single_kl_expect = np.log(2) - (3 / 8)
expect_ouput = paddle.ones_like(
expect_output = paddle.ones_like(
kl) * self.num_actions * single_kl_expect
self.assertTrue(self.paddle_check_eq(kl, expect_ouput))
self.assertTrue(self.paddle_check_eq(kl, expect_output))

def test_init_with_wrong_logits_shape(self):
# input logits with wrong shape
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_sample(self):
self.assertGreaterEqual(paddle.max(sample_action), 0)
self.assertLess(paddle.min(sample_action), self.num_actions)

# construct a logit to ouput determined class
# construct a logit to output determined class
fool_logits = paddle.zeros(shape=(self.batch_size, self.num_actions))
fool_logits[:, 0] = 9999999999
set_random_seed(12)
Expand Down
6 changes: 3 additions & 3 deletions parl/core/torch/tests/policy_distribution_test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def test_kl(self):
dist2 = self.get_dist(mean=mean, logstd=torch.log(std2))
kl = dist1.kl(dist2)
single_kl_expect = np.log(2) - (3 / 8)
expect_ouput = self.num_actions * single_kl_expect
self.assertTrue(self.torch_check_eq(expect_ouput, kl))
expect_output = self.num_actions * single_kl_expect
self.assertTrue(self.torch_check_eq(expect_output, kl))

def test_init_with_wrong_logits_shape(self):
# input logits with wrong shape
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_sample(self):
self.assertGreaterEqual(torch.max(sample_action), 0)
self.assertLess(torch.min(sample_action), self.num_actions)

# construct a logit to ouput determined class
# construct a logit to output determined class
fool_logits = torch.zeros(size=(self.batch_size, self.num_actions))
fool_logits[:, 0] = 9999999999
set_random_seed(12)
Expand Down
2 changes: 1 addition & 1 deletion parl/env/continuous_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def reset(self, **kwargs):
def step(self, model_output_act):
"""
Args:
model_output_act(np.array): The values must be in in [-1, 1].
model_output_act(np.array): The values must be in [-1, 1].
"""
assert np.all(((model_output_act<=1.0 + 1e-3), (model_output_act>=-1.0 - 1e-3))), \
'the action should be in range [-1.0, 1.0]'
Expand Down
4 changes: 2 additions & 2 deletions parl/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ def check_env_consistency(self):
master_pyarrow_version = to_str(message[4])
if client_pyarrow_version != master_pyarrow_version:
if master_pyarrow_version == 'None':
error_message = """"pyarrow" is provided in your current enviroment, however, it is not \
error_message = """"pyarrow" is provided in your current environment, however, it is not \
found in "master"'s environment. To use "pyarrow" for serialization, please install \
"pyarrow={}" in "master"'s environment!""".format(client_pyarrow_version)
elif client_pyarrow_version == 'None':
error_message = """"pyarrow" is provided in "master"'s enviroment, however, it is not \
error_message = """"pyarrow" is provided in "master"'s environment, however, it is not \
found in your current environment. To use "pyarrow" for serialization, please install \
"pyarrow={}" in your current environment!""".format(master_pyarrow_version)
else:
Expand Down
2 changes: 1 addition & 1 deletion parl/remote/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RemoteError(Exception):
"""

def __init__(self, func_name, error_info):
self.error_info = "[Error occured in xparl, when calling " +\
self.error_info = "[Error occurred in xparl, when calling " +\
"function `{}`]:\n{}".format(func_name, error_info)

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion parl/remote/templates/jobs.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h5 class="modal-title" id="log-modal-title">
</div>
<div class="modal-footer">
<a style="position: relative; left: -160px; font-size: small;">
* Only the lastest 500 lines of the log are shown, <br />
* Only the latest 500 lines of the log are shown, <br />
download the log file for the full log.
</a>
<button
Expand Down
4 changes: 2 additions & 2 deletions parl/remote/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ def check_env_consistency(self):
master_pyarrow_version = to_str(message[4])
if worker_pyarrow_version != master_pyarrow_version:
if master_pyarrow_version == 'None':
error_message = """"pyarrow" is provided in your current enviroment, however, it is not \
error_message = """"pyarrow" is provided in your current environment, however, it is not \
found in "master"'s environment. To use "pyarrow" for serialization, please install \
"pyarrow={}" in "master"'s environment!""".format(worker_pyarrow_version)
elif worker_pyarrow_version == 'None':
error_message = """"pyarrow" is provided in "master"'s enviroment, however, it is not \
error_message = """"pyarrow" is provided in "master"'s environment, however, it is not \
found in your current environment. To use "pyarrow" for serialization, please install \
"pyarrow={}" in your current environment!""".format(master_pyarrow_version)
else:
Expand Down
2 changes: 1 addition & 1 deletion parl/utils/csv_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, output_file):
self.keys_set = None

def log_dict(self, result):
"""Ouput result to the csv file.
"""Output result to the csv file.
Will create the header of the csv file automatically when the function is called for the first time.
Ususally, the keys of the result should be the same every time you call the function.
Expand Down
2 changes: 1 addition & 1 deletion parl/utils/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def format_uniform_path(path):
"""format the path to a new path which seperated by os.sep.
"""format the path to a new path which separated by os.sep.
"""
path = path.replace("//", os.sep)
path = path.replace("/", os.sep)
Expand Down
2 changes: 1 addition & 1 deletion parl/utils/tests/not_import_dl_framework_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class TestNotImportPaddle(unittest.TestCase):
def test_import(self):
# setting this enviroment variable will not import deep learning framework
# setting this environment variable will not import deep learning framework
os.environ['XPARL_igonre_core'] = 'true'
import parl
self.assertFalse('paddle' in sys.modules)
Expand Down
2 changes: 1 addition & 1 deletion parl/utils/tests/not_import_dl_framework_test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class TestNotImportPaddle(unittest.TestCase):
def test_import(self):
# setting this enviroment variable will not import deep learning framework
# setting this environment variable will not import deep learning framework
os.environ['XPARL_igonre_core'] = 'true'
import parl
self.assertFalse('torch' in sys.modules)
Expand Down

0 comments on commit 1fc50bf

Please sign in to comment.