Skip to content

Commit

Permalink
ensure arrays are accessed with integers
Browse files Browse the repository at this point in the history
  • Loading branch information
p11o committed Oct 16, 2017
1 parent aa80e8b commit b3c6986
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pybrain/datasets/sequential.py
Expand Up @@ -42,7 +42,7 @@ def _getSequenceField(self, index, field):
seq = ravel(self.getField('sequence_index'))
if len(seq) == index + 1:
# user wants to access the last sequence, return until end of data
return self.getField(field)[seq[index]:]
return self.getField(field)[int(seq[index]):]
if len(seq) < index + 1:
# sequence index beyond number of sequences. raise exception
raise IndexError('sequence does not exist.')
Expand Down
4 changes: 2 additions & 2 deletions pybrain/rl/learners/valuebased/interface.py
Expand Up @@ -50,7 +50,7 @@ def _forwardImplementation(self, inbuf, outbuf):

def getMaxAction(self, state):
""" Return the action with the maximal value for the given state. """
values = self.params.reshape(self.numRows, self.numColumns)[state, :].flatten()
values = self.params.reshape(self.numRows, self.numColumns)[int(state), :].flatten()
action = where(values == max(values))[0]
action = choice(action)
return action
Expand Down Expand Up @@ -91,4 +91,4 @@ def getActionValues(self, state):
return values

def getValue(self, state, action):
return self.network.activate(r_[state, one_to_n(action, self.numActions)])

This comment has been minimized.

Copy link
@QQ12657890

QQ12657890 Mar 1, 2018

It seems to not work! The problem still exists!

return self.network.activate(r_[state, one_to_n(action, self.numActions)])

0 comments on commit b3c6986

Please sign in to comment.