Skip to content

Commit 863b309

Browse files
authored
Small fixes from @pctablet505: cross_entropy_loss bug + dead-code cleanup (#1330)
Fix utils4e.cross_entropy_loss (use _x not x) and remove dead Grab block from XYEnvironment. Supersedes #1214, #1215.
1 parent 24360d5 commit 863b309

2 files changed

Lines changed: 1 addition & 6 deletions

File tree

agents4e.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,6 @@ def execute_action(self, agent, action):
510510
agent.direction += Direction.L
511511
elif action == 'Forward':
512512
agent.bump = self.move_to(agent, agent.direction.move_forward(agent.location))
513-
# elif action == 'Grab':
514-
# things = [thing for thing in self.list_things_at(agent.location)
515-
# if agent.can_grab(thing)]
516-
# if things:
517-
# agent.holding.append(things[0])
518513
elif action == 'Release':
519514
if agent.holding:
520515
agent.holding.pop()

utils4e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def mean_boolean_error(x, y):
334334

335335
def cross_entropy_loss(x, y):
336336
"""Cross entropy loss function. x and y are 1D iterable objects."""
337-
return (-1.0 / len(x)) * sum(x * np.log(_y) + (1 - _x) * np.log(1 - _y) for _x, _y in zip(x, y))
337+
return (-1.0 / len(x)) * sum(_x * np.log(_y) + (1 - _x) * np.log(1 - _y) for _x, _y in zip(x, y))
338338

339339

340340
def mean_squared_error_loss(x, y):

0 commit comments

Comments
 (0)