partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
Agent.from_spec
Creates an agent from a specification dict.
tensorforce/agents/agent.py
def from_spec(spec, kwargs): """ Creates an agent from a specification dict. """ agent = util.get_object( obj=spec, predefined_objects=tensorforce.agents.agents, kwargs=kwargs ) assert isinstance(agent, Agent) return agent
def from_spec(spec, kwargs): """ Creates an agent from a specification dict. """ agent = util.get_object( obj=spec, predefined_objects=tensorforce.agents.agents, kwargs=kwargs ) assert isinstance(agent, Agent) return agent
[ "Creates", "an", "agent", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/agents/agent.py#L279-L289
[ "def", "from_spec", "(", "spec", ",", "kwargs", ")", ":", "agent", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "agents", ".", "agents", ",", "kwargs", "=", "kwargs", ")", "assert", "isinsta...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Network.get_named_tensor
Returns a named tensor if available. Returns: valid: True if named tensor found, False otherwise tensor: If valid, will be a tensor, otherwise None
tensorforce/core/networks/network.py
def get_named_tensor(self, name): """ Returns a named tensor if available. Returns: valid: True if named tensor found, False otherwise tensor: If valid, will be a tensor, otherwise None """ if name in self.named_tensors: return True, self.name...
def get_named_tensor(self, name): """ Returns a named tensor if available. Returns: valid: True if named tensor found, False otherwise tensor: If valid, will be a tensor, otherwise None """ if name in self.named_tensors: return True, self.name...
[ "Returns", "a", "named", "tensor", "if", "available", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/networks/network.py#L117-L128
[ "def", "get_named_tensor", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "named_tensors", ":", "return", "True", ",", "self", ".", "named_tensors", "[", "name", "]", "else", ":", "return", "False", ",", "None" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Network.from_spec
Creates a network from a specification dict.
tensorforce/core/networks/network.py
def from_spec(spec, kwargs=None): """ Creates a network from a specification dict. """ network = util.get_object( obj=spec, default_object=LayeredNetwork, kwargs=kwargs ) assert isinstance(network, Network) return network
def from_spec(spec, kwargs=None): """ Creates a network from a specification dict. """ network = util.get_object( obj=spec, default_object=LayeredNetwork, kwargs=kwargs ) assert isinstance(network, Network) return network
[ "Creates", "a", "network", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/networks/network.py#L143-L153
[ "def", "from_spec", "(", "spec", ",", "kwargs", "=", "None", ")", ":", "network", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "default_object", "=", "LayeredNetwork", ",", "kwargs", "=", "kwargs", ")", "assert", "isinstance", "(", "netw...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SumTree.put
Stores a transition in replay memory. If the memory is full, the oldest entry is replaced.
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def put(self, item, priority=None): """ Stores a transition in replay memory. If the memory is full, the oldest entry is replaced. """ if not self._isfull(): self._memory.append(None) position = self._next_position_then_increment() old_priority = 0 if...
def put(self, item, priority=None): """ Stores a transition in replay memory. If the memory is full, the oldest entry is replaced. """ if not self._isfull(): self._memory.append(None) position = self._next_position_then_increment() old_priority = 0 if...
[ "Stores", "a", "transition", "in", "replay", "memory", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L64-L78
[ "def", "put", "(", "self", ",", "item", ",", "priority", "=", "None", ")", ":", "if", "not", "self", ".", "_isfull", "(", ")", ":", "self", ".", "_memory", ".", "append", "(", "None", ")", "position", "=", "self", ".", "_next_position_then_increment", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SumTree.move
Change the priority of a leaf node
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def move(self, external_index, new_priority): """ Change the priority of a leaf node """ index = external_index + (self._capacity - 1) return self._move(index, new_priority)
def move(self, external_index, new_priority): """ Change the priority of a leaf node """ index = external_index + (self._capacity - 1) return self._move(index, new_priority)
[ "Change", "the", "priority", "of", "a", "leaf", "node" ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L80-L85
[ "def", "move", "(", "self", ",", "external_index", ",", "new_priority", ")", ":", "index", "=", "external_index", "+", "(", "self", ".", "_capacity", "-", "1", ")", "return", "self", ".", "_move", "(", "index", ",", "new_priority", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SumTree._move
Change the priority of a leaf node.
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def _move(self, index, new_priority): """ Change the priority of a leaf node. """ item, old_priority = self._memory[index] old_priority = old_priority or 0 self._memory[index] = _SumRow(item, new_priority) self._update_internal_nodes(index, new_priority - old_prio...
def _move(self, index, new_priority): """ Change the priority of a leaf node. """ item, old_priority = self._memory[index] old_priority = old_priority or 0 self._memory[index] = _SumRow(item, new_priority) self._update_internal_nodes(index, new_priority - old_prio...
[ "Change", "the", "priority", "of", "a", "leaf", "node", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L87-L94
[ "def", "_move", "(", "self", ",", "index", ",", "new_priority", ")", ":", "item", ",", "old_priority", "=", "self", ".", "_memory", "[", "index", "]", "old_priority", "=", "old_priority", "or", "0", "self", ".", "_memory", "[", "index", "]", "=", "_Sum...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SumTree._update_internal_nodes
Update internal priority sums when leaf priority has been changed. Args: index: leaf node index delta: change in priority
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def _update_internal_nodes(self, index, delta): """ Update internal priority sums when leaf priority has been changed. Args: index: leaf node index delta: change in priority """ # Move up tree, increasing position, updating sum while index > 0: ...
def _update_internal_nodes(self, index, delta): """ Update internal priority sums when leaf priority has been changed. Args: index: leaf node index delta: change in priority """ # Move up tree, increasing position, updating sum while index > 0: ...
[ "Update", "internal", "priority", "sums", "when", "leaf", "priority", "has", "been", "changed", ".", "Args", ":", "index", ":", "leaf", "node", "index", "delta", ":", "change", "in", "priority" ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L96-L106
[ "def", "_update_internal_nodes", "(", "self", ",", "index", ",", "delta", ")", ":", "# Move up tree, increasing position, updating sum", "while", "index", ">", "0", ":", "index", "=", "(", "index", "-", "1", ")", "//", "2", "self", ".", "_memory", "[", "inde...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SumTree._next_position_then_increment
Similar to position++.
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def _next_position_then_increment(self): """ Similar to position++. """ start = self._capacity - 1 position = start + self._position self._position = (self._position + 1) % self._capacity return position
def _next_position_then_increment(self): """ Similar to position++. """ start = self._capacity - 1 position = start + self._position self._position = (self._position + 1) % self._capacity return position
[ "Similar", "to", "position", "++", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L111-L118
[ "def", "_next_position_then_increment", "(", "self", ")", ":", "start", "=", "self", ".", "_capacity", "-", "1", "position", "=", "start", "+", "self", ".", "_position", "self", ".", "_position", "=", "(", "self", ".", "_position", "+", "1", ")", "%", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SumTree._sample_with_priority
Sample random element with priority greater than p.
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def _sample_with_priority(self, p): """ Sample random element with priority greater than p. """ parent = 0 while True: left = 2 * parent + 1 if left >= len(self._memory): # parent points to a leaf node already. return parent...
def _sample_with_priority(self, p): """ Sample random element with priority greater than p. """ parent = 0 while True: left = 2 * parent + 1 if left >= len(self._memory): # parent points to a leaf node already. return parent...
[ "Sample", "random", "element", "with", "priority", "greater", "than", "p", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L120-L139
[ "def", "_sample_with_priority", "(", "self", ",", "p", ")", ":", "parent", "=", "0", "while", "True", ":", "left", "=", "2", "*", "parent", "+", "1", "if", "left", ">=", "len", "(", "self", ".", "_memory", ")", ":", "# parent points to a leaf node alread...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SumTree.sample_minibatch
Sample minibatch of size batch_size.
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def sample_minibatch(self, batch_size): """ Sample minibatch of size batch_size. """ pool_size = len(self) if pool_size == 0: return [] delta_p = self._memory[0] / batch_size chosen_idx = [] # if all priorities sum to ~0 choose randomly other...
def sample_minibatch(self, batch_size): """ Sample minibatch of size batch_size. """ pool_size = len(self) if pool_size == 0: return [] delta_p = self._memory[0] / batch_size chosen_idx = [] # if all priorities sum to ~0 choose randomly other...
[ "Sample", "minibatch", "of", "size", "batch_size", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L141-L160
[ "def", "sample_minibatch", "(", "self", ",", "batch_size", ")", ":", "pool_size", "=", "len", "(", "self", ")", "if", "pool_size", "==", "0", ":", "return", "[", "]", "delta_p", "=", "self", ".", "_memory", "[", "0", "]", "/", "batch_size", "chosen_idx...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PrioritizedReplay.get_batch
Samples a batch of the specified size according to priority. Args: batch_size: The batch size next_states: A boolean flag indicating whether 'next_states' values should be included Returns: A dict containing states, actions, rewards, terminals, internal states (and next states)
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def get_batch(self, batch_size, next_states=False): """ Samples a batch of the specified size according to priority. Args: batch_size: The batch size next_states: A boolean flag indicating whether 'next_states' values should be included Returns: A dict containin...
def get_batch(self, batch_size, next_states=False): """ Samples a batch of the specified size according to priority. Args: batch_size: The batch size next_states: A boolean flag indicating whether 'next_states' values should be included Returns: A dict containin...
[ "Samples", "a", "batch", "of", "the", "specified", "size", "according", "to", "priority", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L218-L299
[ "def", "get_batch", "(", "self", ",", "batch_size", ",", "next_states", "=", "False", ")", ":", "if", "batch_size", ">", "len", "(", "self", ".", "observations", ")", ":", "raise", "TensorForceError", "(", "\"Requested batch size is larger than observations in memor...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PrioritizedReplay.update_batch
Computes priorities according to loss. Args: loss_per_instance:
tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py
def update_batch(self, loss_per_instance): """ Computes priorities according to loss. Args: loss_per_instance: """ if self.batch_indices is None: raise TensorForceError("Need to call get_batch before each update_batch call.") # if len(loss_per_in...
def update_batch(self, loss_per_instance): """ Computes priorities according to loss. Args: loss_per_instance: """ if self.batch_indices is None: raise TensorForceError("Need to call get_batch before each update_batch call.") # if len(loss_per_in...
[ "Computes", "priorities", "according", "to", "loss", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/deprecated/deprecated_prioritized_replay.py#L301-L318
[ "def", "update_batch", "(", "self", ",", "loss_per_instance", ")", ":", "if", "self", ".", "batch_indices", "is", "None", ":", "raise", "TensorForceError", "(", "\"Need to call get_batch before each update_batch call.\"", ")", "# if len(loss_per_instance) != len(self.batch_in...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
LearningAgent.import_experience
Imports experiences. Args: experiences:
tensorforce/agents/learning_agent.py
def import_experience(self, experiences): """ Imports experiences. Args: experiences: """ if isinstance(experiences, dict): if self.unique_state: experiences['states'] = dict(state=experiences['states']) if self.unique_action:...
def import_experience(self, experiences): """ Imports experiences. Args: experiences: """ if isinstance(experiences, dict): if self.unique_state: experiences['states'] = dict(state=experiences['states']) if self.unique_action:...
[ "Imports", "experiences", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/agents/learning_agent.py#L144-L194
[ "def", "import_experience", "(", "self", ",", "experiences", ")", ":", "if", "isinstance", "(", "experiences", ",", "dict", ")", ":", "if", "self", ".", "unique_state", ":", "experiences", "[", "'states'", "]", "=", "dict", "(", "state", "=", "experiences"...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RemoteEnvironment.connect
Starts the server tcp connection on the given host:port. Args: timeout (int): The time (in seconds) for which we will attempt a connection to the remote (every 5sec). After that (or if timeout is None or 0), an error is raised.
tensorforce/contrib/remote_environment.py
def connect(self, timeout=600): """ Starts the server tcp connection on the given host:port. Args: timeout (int): The time (in seconds) for which we will attempt a connection to the remote (every 5sec). After that (or if timeout is None or 0), an error is raised. ...
def connect(self, timeout=600): """ Starts the server tcp connection on the given host:port. Args: timeout (int): The time (in seconds) for which we will attempt a connection to the remote (every 5sec). After that (or if timeout is None or 0), an error is raised. ...
[ "Starts", "the", "server", "tcp", "connection", "on", "the", "given", "host", ":", "port", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/remote_environment.py#L58-L85
[ "def", "connect", "(", "self", ",", "timeout", "=", "600", ")", ":", "# If we are already connected, return error.", "if", "self", ".", "socket", ":", "raise", "TensorForceError", "(", "\"Already connected to {}:{}. Only one connection allowed at a time. \"", "+", "\"Close ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RemoteEnvironment.disconnect
Ends our server tcp connection.
tensorforce/contrib/remote_environment.py
def disconnect(self): """ Ends our server tcp connection. """ # If we are not connected, return error. if not self.socket: logging.warning("No active socket to close!") return # Close our socket. self.socket.close() self.socket = No...
def disconnect(self): """ Ends our server tcp connection. """ # If we are not connected, return error. if not self.socket: logging.warning("No active socket to close!") return # Close our socket. self.socket.close() self.socket = No...
[ "Ends", "our", "server", "tcp", "connection", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/remote_environment.py#L87-L97
[ "def", "disconnect", "(", "self", ")", ":", "# If we are not connected, return error.", "if", "not", "self", ".", "socket", ":", "logging", ".", "warning", "(", "\"No active socket to close!\"", ")", "return", "# Close our socket.", "self", ".", "socket", ".", "clos...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MsgPackNumpyProtocol.send
Sends a message (dict) to the socket. Message consists of a 8-byte len header followed by a msgpack-numpy encoded dict. Args: message: The message dict (e.g. {"cmd": "reset"}) socket_: The python socket object to use.
tensorforce/contrib/remote_environment.py
def send(self, message, socket_): """ Sends a message (dict) to the socket. Message consists of a 8-byte len header followed by a msgpack-numpy encoded dict. Args: message: The message dict (e.g. {"cmd": "reset"}) socket_: The python socket object to use. ...
def send(self, message, socket_): """ Sends a message (dict) to the socket. Message consists of a 8-byte len header followed by a msgpack-numpy encoded dict. Args: message: The message dict (e.g. {"cmd": "reset"}) socket_: The python socket object to use. ...
[ "Sends", "a", "message", "(", "dict", ")", "to", "the", "socket", ".", "Message", "consists", "of", "a", "8", "-", "byte", "len", "header", "followed", "by", "a", "msgpack", "-", "numpy", "encoded", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/remote_environment.py#L134-L150
[ "def", "send", "(", "self", ",", "message", ",", "socket_", ")", ":", "if", "not", "socket_", ":", "raise", "TensorForceError", "(", "\"No socket given in call to `send`!\"", ")", "elif", "not", "isinstance", "(", "message", ",", "dict", ")", ":", "raise", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MsgPackNumpyProtocol.recv
Receives a message as msgpack-numpy encoded byte-string from the given socket object. Blocks until something was received. Args: socket_: The python socket object to use. encoding (str): The encoding to use for unpacking messages from the socket. Returns: The decoded (as...
tensorforce/contrib/remote_environment.py
def recv(self, socket_, encoding=None): """ Receives a message as msgpack-numpy encoded byte-string from the given socket object. Blocks until something was received. Args: socket_: The python socket object to use. encoding (str): The encoding to use for unpackin...
def recv(self, socket_, encoding=None): """ Receives a message as msgpack-numpy encoded byte-string from the given socket object. Blocks until something was received. Args: socket_: The python socket object to use. encoding (str): The encoding to use for unpackin...
[ "Receives", "a", "message", "as", "msgpack", "-", "numpy", "encoded", "byte", "-", "string", "from", "the", "given", "socket", "object", ".", "Blocks", "until", "something", "was", "received", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/remote_environment.py#L152-L196
[ "def", "recv", "(", "self", ",", "socket_", ",", "encoding", "=", "None", ")", ":", "unpacker", "=", "msgpack", ".", "Unpacker", "(", "encoding", "=", "encoding", ")", "# Wait for an immediate response.", "response", "=", "socket_", ".", "recv", "(", "8", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Game2048.is_action_available
Determines whether action is available. That is, executing it would change the state.
tensorforce/contrib/game_2048.py
def is_action_available(self, action): """Determines whether action is available. That is, executing it would change the state. """ temp_state = np.rot90(self._state, action) return self._is_action_available_left(temp_state)
def is_action_available(self, action): """Determines whether action is available. That is, executing it would change the state. """ temp_state = np.rot90(self._state, action) return self._is_action_available_left(temp_state)
[ "Determines", "whether", "action", "is", "available", ".", "That", "is", "executing", "it", "would", "change", "the", "state", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/game_2048.py#L102-L108
[ "def", "is_action_available", "(", "self", ",", "action", ")", ":", "temp_state", "=", "np", ".", "rot90", "(", "self", ".", "_state", ",", "action", ")", "return", "self", ".", "_is_action_available_left", "(", "temp_state", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Game2048._is_action_available_left
Determines whether action 'Left' is available.
tensorforce/contrib/game_2048.py
def _is_action_available_left(self, state): """Determines whether action 'Left' is available.""" # True if any field is 0 (empty) on the left of a tile or two tiles can # be merged. for row in range(4): has_empty = False for col in range(4): has_e...
def _is_action_available_left(self, state): """Determines whether action 'Left' is available.""" # True if any field is 0 (empty) on the left of a tile or two tiles can # be merged. for row in range(4): has_empty = False for col in range(4): has_e...
[ "Determines", "whether", "action", "Left", "is", "available", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/game_2048.py#L110-L125
[ "def", "_is_action_available_left", "(", "self", ",", "state", ")", ":", "# True if any field is 0 (empty) on the left of a tile or two tiles can", "# be merged.", "for", "row", "in", "range", "(", "4", ")", ":", "has_empty", "=", "False", "for", "col", "in", "range",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Game2048.do_action
Execute action, add a new tile, update the score & return the reward.
tensorforce/contrib/game_2048.py
def do_action(self, action): """Execute action, add a new tile, update the score & return the reward.""" temp_state = np.rot90(self._state, action) reward = self._do_action_left(temp_state) self._state = np.rot90(temp_state, -action) self._score += reward self.add_rando...
def do_action(self, action): """Execute action, add a new tile, update the score & return the reward.""" temp_state = np.rot90(self._state, action) reward = self._do_action_left(temp_state) self._state = np.rot90(temp_state, -action) self._score += reward self.add_rando...
[ "Execute", "action", "add", "a", "new", "tile", "update", "the", "score", "&", "return", "the", "reward", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/game_2048.py#L127-L137
[ "def", "do_action", "(", "self", ",", "action", ")", ":", "temp_state", "=", "np", ".", "rot90", "(", "self", ".", "_state", ",", "action", ")", "reward", "=", "self", ".", "_do_action_left", "(", "temp_state", ")", "self", ".", "_state", "=", "np", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Game2048._do_action_left
Executes action 'Left'.
tensorforce/contrib/game_2048.py
def _do_action_left(self, state): """Executes action 'Left'.""" reward = 0 for row in range(4): # Always the rightmost tile in the current row that was already moved merge_candidate = -1 merged = np.zeros((4,), dtype=np.bool) for col in range(4)...
def _do_action_left(self, state): """Executes action 'Left'.""" reward = 0 for row in range(4): # Always the rightmost tile in the current row that was already moved merge_candidate = -1 merged = np.zeros((4,), dtype=np.bool) for col in range(4)...
[ "Executes", "action", "Left", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/game_2048.py#L139-L169
[ "def", "_do_action_left", "(", "self", ",", "state", ")", ":", "reward", "=", "0", "for", "row", "in", "range", "(", "4", ")", ":", "# Always the rightmost tile in the current row that was already moved", "merge_candidate", "=", "-", "1", "merged", "=", "np", "....
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Game2048.add_random_tile
Adds a random tile to the grid. Assumes that it has empty fields.
tensorforce/contrib/game_2048.py
def add_random_tile(self): """Adds a random tile to the grid. Assumes that it has empty fields.""" x_pos, y_pos = np.where(self._state == 0) assert len(x_pos) != 0 empty_index = np.random.choice(len(x_pos)) value = np.random.choice([1, 2], p=[0.9, 0.1]) self._state[x_po...
def add_random_tile(self): """Adds a random tile to the grid. Assumes that it has empty fields.""" x_pos, y_pos = np.where(self._state == 0) assert len(x_pos) != 0 empty_index = np.random.choice(len(x_pos)) value = np.random.choice([1, 2], p=[0.9, 0.1]) self._state[x_po...
[ "Adds", "a", "random", "tile", "to", "the", "grid", ".", "Assumes", "that", "it", "has", "empty", "fields", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/game_2048.py#L171-L179
[ "def", "add_random_tile", "(", "self", ")", ":", "x_pos", ",", "y_pos", "=", "np", ".", "where", "(", "self", ".", "_state", "==", "0", ")", "assert", "len", "(", "x_pos", ")", "!=", "0", "empty_index", "=", "np", ".", "random", ".", "choice", "(",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Game2048.print_state
Prints the current state.
tensorforce/contrib/game_2048.py
def print_state(self): """Prints the current state.""" def tile_string(value): """Concert value to string.""" if value > 0: return '% 5d' % (2 ** value,) return " " separator_line = '-' * 25 print(separator_line) for row i...
def print_state(self): """Prints the current state.""" def tile_string(value): """Concert value to string.""" if value > 0: return '% 5d' % (2 ** value,) return " " separator_line = '-' * 25 print(separator_line) for row i...
[ "Prints", "the", "current", "state", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/game_2048.py#L181-L194
[ "def", "print_state", "(", "self", ")", ":", "def", "tile_string", "(", "value", ")", ":", "\"\"\"Concert value to string.\"\"\"", "if", "value", ">", "0", ":", "return", "'% 5d'", "%", "(", "2", "**", "value", ",", ")", "return", "\" \"", "separator_lin...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.setup
Sets up the TensorFlow model graph, starts the servers (distributed mode), creates summarizers and savers, initializes (and enters) the TensorFlow session.
tensorforce/models/model.py
def setup(self): """ Sets up the TensorFlow model graph, starts the servers (distributed mode), creates summarizers and savers, initializes (and enters) the TensorFlow session. """ # Create/get our graph, setup local model/global model links, set scope and device. graph_...
def setup(self): """ Sets up the TensorFlow model graph, starts the servers (distributed mode), creates summarizers and savers, initializes (and enters) the TensorFlow session. """ # Create/get our graph, setup local model/global model links, set scope and device. graph_...
[ "Sets", "up", "the", "TensorFlow", "model", "graph", "starts", "the", "servers", "(", "distributed", "mode", ")", "creates", "summarizers", "and", "savers", "initializes", "(", "and", "enters", ")", "the", "TensorFlow", "session", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L237-L368
[ "def", "setup", "(", "self", ")", ":", "# Create/get our graph, setup local model/global model links, set scope and device.", "graph_default_context", "=", "self", ".", "setup_graph", "(", ")", "# Start a tf Server (in case of distributed setup). Only start once.", "if", "self", "....
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.setup_graph
Creates our Graph and figures out, which shared/global model to hook up to. If we are in a global-model's setup procedure, we do not create a new graph (return None as the context). We will instead use the already existing local replica graph of the model. Returns: None or the graph's a...
tensorforce/models/model.py
def setup_graph(self): """ Creates our Graph and figures out, which shared/global model to hook up to. If we are in a global-model's setup procedure, we do not create a new graph (return None as the context). We will instead use the already existing local replica graph of the mod...
def setup_graph(self): """ Creates our Graph and figures out, which shared/global model to hook up to. If we are in a global-model's setup procedure, we do not create a new graph (return None as the context). We will instead use the already existing local replica graph of the mod...
[ "Creates", "our", "Graph", "and", "figures", "out", "which", "shared", "/", "global", "model", "to", "hook", "up", "to", ".", "If", "we", "are", "in", "a", "global", "-", "model", "s", "setup", "procedure", "we", "do", "not", "create", "a", "new", "g...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L370-L428
[ "def", "setup_graph", "(", "self", ")", ":", "graph_default_context", "=", "None", "# Single (non-distributed) mode.", "if", "self", ".", "execution_type", "==", "\"single\"", ":", "self", ".", "graph", "=", "tf", ".", "Graph", "(", ")", "graph_default_context", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.start_server
Creates and stores a tf server (and optionally joins it if we are a parameter-server). Only relevant, if we are running in distributed mode.
tensorforce/models/model.py
def start_server(self): """ Creates and stores a tf server (and optionally joins it if we are a parameter-server). Only relevant, if we are running in distributed mode. """ self.server = tf.train.Server( server_or_cluster_def=self.distributed_spec["cluster_spec"], ...
def start_server(self): """ Creates and stores a tf server (and optionally joins it if we are a parameter-server). Only relevant, if we are running in distributed mode. """ self.server = tf.train.Server( server_or_cluster_def=self.distributed_spec["cluster_spec"], ...
[ "Creates", "and", "stores", "a", "tf", "server", "(", "and", "optionally", "joins", "it", "if", "we", "are", "a", "parameter", "-", "server", ")", ".", "Only", "relevant", "if", "we", "are", "running", "in", "distributed", "mode", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L430-L446
[ "def", "start_server", "(", "self", ")", ":", "self", ".", "server", "=", "tf", ".", "train", ".", "Server", "(", "server_or_cluster_def", "=", "self", ".", "distributed_spec", "[", "\"cluster_spec\"", "]", ",", "job_name", "=", "self", ".", "distributed_spe...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.setup_placeholders
Creates the TensorFlow placeholders, variables, ops and functions for this model. NOTE: Does not add the internal state placeholders and initialization values to the model yet as that requires the model's Network (if any) to be generated first.
tensorforce/models/model.py
def setup_placeholders(self): """ Creates the TensorFlow placeholders, variables, ops and functions for this model. NOTE: Does not add the internal state placeholders and initialization values to the model yet as that requires the model's Network (if any) to be generated first. "...
def setup_placeholders(self): """ Creates the TensorFlow placeholders, variables, ops and functions for this model. NOTE: Does not add the internal state placeholders and initialization values to the model yet as that requires the model's Network (if any) to be generated first. "...
[ "Creates", "the", "TensorFlow", "placeholders", "variables", "ops", "and", "functions", "for", "this", "model", ".", "NOTE", ":", "Does", "not", "add", "the", "internal", "state", "placeholders", "and", "initialization", "values", "to", "the", "model", "yet", ...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L448-L535
[ "def", "setup_placeholders", "(", "self", ")", ":", "# States", "for", "name", "in", "sorted", "(", "self", ".", "states_spec", ")", ":", "self", ".", "states_input", "[", "name", "]", "=", "tf", ".", "placeholder", "(", "dtype", "=", "util", ".", "tf_...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.setup_components_and_tf_funcs
Allows child models to create model's component objects, such as optimizer(s), memory(s), etc.. Creates all tensorflow functions via tf.make_template calls on all the class' "tf_"-methods. Args: custom_getter: The `custom_getter_` object to use for `tf.make_template` when creating TensorFlo...
tensorforce/models/model.py
def setup_components_and_tf_funcs(self, custom_getter=None): """ Allows child models to create model's component objects, such as optimizer(s), memory(s), etc.. Creates all tensorflow functions via tf.make_template calls on all the class' "tf_"-methods. Args: custom_getter: ...
def setup_components_and_tf_funcs(self, custom_getter=None): """ Allows child models to create model's component objects, such as optimizer(s), memory(s), etc.. Creates all tensorflow functions via tf.make_template calls on all the class' "tf_"-methods. Args: custom_getter: ...
[ "Allows", "child", "models", "to", "create", "model", "s", "component", "objects", "such", "as", "optimizer", "(", "s", ")", "memory", "(", "s", ")", "etc", "..", "Creates", "all", "tensorflow", "functions", "via", "tf", ".", "make_template", "calls", "on"...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L537-L602
[ "def", "setup_components_and_tf_funcs", "(", "self", ",", "custom_getter", "=", "None", ")", ":", "if", "custom_getter", "is", "None", ":", "def", "custom_getter", "(", "getter", ",", "name", ",", "registered", "=", "False", ",", "*", "*", "kwargs", ")", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.setup_saver
Creates the tf.train.Saver object and stores it in self.saver.
tensorforce/models/model.py
def setup_saver(self): """ Creates the tf.train.Saver object and stores it in self.saver. """ if self.execution_type == "single": global_variables = self.get_variables(include_submodules=True, include_nontrainable=True) else: global_variables = self.global...
def setup_saver(self): """ Creates the tf.train.Saver object and stores it in self.saver. """ if self.execution_type == "single": global_variables = self.get_variables(include_submodules=True, include_nontrainable=True) else: global_variables = self.global...
[ "Creates", "the", "tf", ".", "train", ".", "Saver", "object", "and", "stores", "it", "in", "self", ".", "saver", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L604-L636
[ "def", "setup_saver", "(", "self", ")", ":", "if", "self", ".", "execution_type", "==", "\"single\"", ":", "global_variables", "=", "self", ".", "get_variables", "(", "include_submodules", "=", "True", ",", "include_nontrainable", "=", "True", ")", "else", ":"...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.setup_scaffold
Creates the tf.train.Scaffold object and assigns it to self.scaffold. Other fields of the Scaffold are generated automatically.
tensorforce/models/model.py
def setup_scaffold(self): """ Creates the tf.train.Scaffold object and assigns it to self.scaffold. Other fields of the Scaffold are generated automatically. """ if self.execution_type == "single": global_variables = self.get_variables(include_submodules=True, include...
def setup_scaffold(self): """ Creates the tf.train.Scaffold object and assigns it to self.scaffold. Other fields of the Scaffold are generated automatically. """ if self.execution_type == "single": global_variables = self.get_variables(include_submodules=True, include...
[ "Creates", "the", "tf", ".", "train", ".", "Scaffold", "object", "and", "assigns", "it", "to", "self", ".", "scaffold", ".", "Other", "fields", "of", "the", "Scaffold", "are", "generated", "automatically", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L638-L718
[ "def", "setup_scaffold", "(", "self", ")", ":", "if", "self", ".", "execution_type", "==", "\"single\"", ":", "global_variables", "=", "self", ".", "get_variables", "(", "include_submodules", "=", "True", ",", "include_nontrainable", "=", "True", ")", "# global_...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.setup_hooks
Creates and returns a list of hooks to use in a session. Populates self.saver_directory. Returns: List of hooks to use in a session.
tensorforce/models/model.py
def setup_hooks(self): """ Creates and returns a list of hooks to use in a session. Populates self.saver_directory. Returns: List of hooks to use in a session. """ hooks = list() # Checkpoint saver hook if self.saver_spec is not None and (self.execution_type == ...
def setup_hooks(self): """ Creates and returns a list of hooks to use in a session. Populates self.saver_directory. Returns: List of hooks to use in a session. """ hooks = list() # Checkpoint saver hook if self.saver_spec is not None and (self.execution_type == ...
[ "Creates", "and", "returns", "a", "list", "of", "hooks", "to", "use", "in", "a", "session", ".", "Populates", "self", ".", "saver_directory", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L720-L764
[ "def", "setup_hooks", "(", "self", ")", ":", "hooks", "=", "list", "(", ")", "# Checkpoint saver hook", "if", "self", ".", "saver_spec", "is", "not", "None", "and", "(", "self", ".", "execution_type", "==", "'single'", "or", "self", ".", "distributed_spec", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.setup_session
Creates and then enters the session for this model (finalizes the graph). Args: server (tf.train.Server): The tf.train.Server object to connect to (None for single execution). hooks (list): A list of (saver, summary, etc..) hooks to be passed to the session. graph_default_co...
tensorforce/models/model.py
def setup_session(self, server, hooks, graph_default_context): """ Creates and then enters the session for this model (finalizes the graph). Args: server (tf.train.Server): The tf.train.Server object to connect to (None for single execution). hooks (list): A list of (sav...
def setup_session(self, server, hooks, graph_default_context): """ Creates and then enters the session for this model (finalizes the graph). Args: server (tf.train.Server): The tf.train.Server object to connect to (None for single execution). hooks (list): A list of (sav...
[ "Creates", "and", "then", "enters", "the", "session", "for", "this", "model", "(", "finalizes", "the", "graph", ")", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L766-L818
[ "def", "setup_session", "(", "self", ",", "server", ",", "hooks", ",", "graph_default_context", ")", ":", "if", "self", ".", "execution_type", "==", "\"distributed\"", ":", "# if self.distributed_spec['task_index'] == 0:", "# TensorFlow chief session creator object", "sessi...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.close
Saves the model (of saver dir is given) and closes the session.
tensorforce/models/model.py
def close(self): """ Saves the model (of saver dir is given) and closes the session. """ if self.flush_summarizer is not None: self.monitored_session.run(fetches=self.flush_summarizer) if self.saver_directory is not None: self.save(append_timestep=True) ...
def close(self): """ Saves the model (of saver dir is given) and closes the session. """ if self.flush_summarizer is not None: self.monitored_session.run(fetches=self.flush_summarizer) if self.saver_directory is not None: self.save(append_timestep=True) ...
[ "Saves", "the", "model", "(", "of", "saver", "dir", "is", "given", ")", "and", "closes", "the", "session", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L820-L828
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "flush_summarizer", "is", "not", "None", ":", "self", ".", "monitored_session", ".", "run", "(", "fetches", "=", "self", ".", "flush_summarizer", ")", "if", "self", ".", "saver_directory", "is", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.tf_initialize
Creates tf Variables for the local state/internals/action-buffers and for the local and global counters for timestep and episode.
tensorforce/models/model.py
def tf_initialize(self): """ Creates tf Variables for the local state/internals/action-buffers and for the local and global counters for timestep and episode. """ # Timesteps/Episodes # Global: (force on global device; local and global model point to the same (global) da...
def tf_initialize(self): """ Creates tf Variables for the local state/internals/action-buffers and for the local and global counters for timestep and episode. """ # Timesteps/Episodes # Global: (force on global device; local and global model point to the same (global) da...
[ "Creates", "tf", "Variables", "for", "the", "local", "state", "/", "internals", "/", "action", "-", "buffers", "and", "for", "the", "local", "and", "global", "counters", "for", "timestep", "and", "episode", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L833-L930
[ "def", "tf_initialize", "(", "self", ")", ":", "# Timesteps/Episodes", "# Global: (force on global device; local and global model point to the same (global) data).", "with", "tf", ".", "device", "(", "device_name_or_function", "=", "(", "self", ".", "global_model", ".", "devi...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.tf_preprocess
Applies preprocessing ops to the raw states/action/reward inputs. Args: states (dict): Dict of raw state tensors. actions (dict): Dict or raw action tensors. reward: 1D (float) raw rewards tensor. Returns: The preprocessed versions of the input tensors.
tensorforce/models/model.py
def tf_preprocess(self, states, actions, reward): """ Applies preprocessing ops to the raw states/action/reward inputs. Args: states (dict): Dict of raw state tensors. actions (dict): Dict or raw action tensors. reward: 1D (float) raw rewards tensor. ...
def tf_preprocess(self, states, actions, reward): """ Applies preprocessing ops to the raw states/action/reward inputs. Args: states (dict): Dict of raw state tensors. actions (dict): Dict or raw action tensors. reward: 1D (float) raw rewards tensor. ...
[ "Applies", "preprocessing", "ops", "to", "the", "raw", "states", "/", "action", "/", "reward", "inputs", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L935-L954
[ "def", "tf_preprocess", "(", "self", ",", "states", ",", "actions", ",", "reward", ")", ":", "# States preprocessing", "for", "name", "in", "sorted", "(", "self", ".", "states_preprocessing", ")", ":", "states", "[", "name", "]", "=", "self", ".", "states_...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.tf_action_exploration
Applies optional exploration to the action (post-processor for action outputs). Args: action (tf.Tensor): The original output action tensor (to be post-processed). exploration (Exploration): The Exploration object to use. action_spec (dict): Dict specifying the action spa...
tensorforce/models/model.py
def tf_action_exploration(self, action, exploration, action_spec): """ Applies optional exploration to the action (post-processor for action outputs). Args: action (tf.Tensor): The original output action tensor (to be post-processed). exploration (Exploration): The Exp...
def tf_action_exploration(self, action, exploration, action_spec): """ Applies optional exploration to the action (post-processor for action outputs). Args: action (tf.Tensor): The original output action tensor (to be post-processed). exploration (Exploration): The Exp...
[ "Applies", "optional", "exploration", "to", "the", "action", "(", "post", "-", "processor", "for", "action", "outputs", ")", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L956-L999
[ "def", "tf_action_exploration", "(", "self", ",", "action", ",", "exploration", ",", "action_spec", ")", ":", "action_shape", "=", "tf", ".", "shape", "(", "input", "=", "action", ")", "exploration_value", "=", "exploration", ".", "tf_explore", "(", "episode",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.create_act_operations
Creates and stores tf operations that are fetched when calling act(): actions_output, internals_output and timestep_output. Args: states (dict): Dict of state tensors (each key represents one state space component). internals (dict): Dict of prior internal state tensors (each ke...
tensorforce/models/model.py
def create_act_operations(self, states, internals, deterministic, independent, index): """ Creates and stores tf operations that are fetched when calling act(): actions_output, internals_output and timestep_output. Args: states (dict): Dict of state tensors (each key represe...
def create_act_operations(self, states, internals, deterministic, independent, index): """ Creates and stores tf operations that are fetched when calling act(): actions_output, internals_output and timestep_output. Args: states (dict): Dict of state tensors (each key represe...
[ "Creates", "and", "stores", "tf", "operations", "that", "are", "fetched", "when", "calling", "act", "()", ":", "actions_output", "internals_output", "and", "timestep_output", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1036-L1153
[ "def", "create_act_operations", "(", "self", ",", "states", ",", "internals", ",", "deterministic", ",", "independent", ",", "index", ")", ":", "# Optional variable noise", "operations", "=", "list", "(", ")", "if", "self", ".", "variable_noise", "is", "not", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.create_observe_operations
Returns the tf op to fetch when an observation batch is passed in (e.g. an episode's rewards and terminals). Uses the filled tf buffers for states, actions and internals to run the tf_observe_timestep (model-dependent), resets buffer index and increases counters (episodes, timesteps). A...
tensorforce/models/model.py
def create_observe_operations(self, terminal, reward, index): """ Returns the tf op to fetch when an observation batch is passed in (e.g. an episode's rewards and terminals). Uses the filled tf buffers for states, actions and internals to run the tf_observe_timestep (model-dependent), re...
def create_observe_operations(self, terminal, reward, index): """ Returns the tf op to fetch when an observation batch is passed in (e.g. an episode's rewards and terminals). Uses the filled tf buffers for states, actions and internals to run the tf_observe_timestep (model-dependent), re...
[ "Returns", "the", "tf", "op", "to", "fetch", "when", "an", "observation", "batch", "is", "passed", "in", "(", "e", ".", "g", ".", "an", "episode", "s", "rewards", "and", "terminals", ")", ".", "Uses", "the", "filled", "tf", "buffers", "for", "states", ...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1155-L1201
[ "def", "create_observe_operations", "(", "self", ",", "terminal", ",", "reward", ",", "index", ")", ":", "# Increment episode", "num_episodes", "=", "tf", ".", "count_nonzero", "(", "input_tensor", "=", "terminal", ",", "dtype", "=", "util", ".", "tf_dtype", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.create_atomic_observe_operations
Returns the tf op to fetch when unbuffered observations are passed in. Args: states (any): One state (usually a value tuple) or dict of states if multiple states are expected. actions (any): One action (usually a value tuple) or dict of states if multiple actions are expected. ...
tensorforce/models/model.py
def create_atomic_observe_operations(self, states, actions, internals, terminal, reward, index): """ Returns the tf op to fetch when unbuffered observations are passed in. Args: states (any): One state (usually a value tuple) or dict of states if multiple states are expected. ...
def create_atomic_observe_operations(self, states, actions, internals, terminal, reward, index): """ Returns the tf op to fetch when unbuffered observations are passed in. Args: states (any): One state (usually a value tuple) or dict of states if multiple states are expected. ...
[ "Returns", "the", "tf", "op", "to", "fetch", "when", "unbuffered", "observations", "are", "passed", "in", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1206-L1244
[ "def", "create_atomic_observe_operations", "(", "self", ",", "states", ",", "actions", ",", "internals", ",", "terminal", ",", "reward", ",", "index", ")", ":", "# Increment episode", "num_episodes", "=", "tf", ".", "count_nonzero", "(", "input_tensor", "=", "te...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.create_operations
Creates and stores tf operations for when `act()` and `observe()` are called.
tensorforce/models/model.py
def create_operations(self, states, internals, actions, terminal, reward, deterministic, independent, index): """ Creates and stores tf operations for when `act()` and `observe()` are called. """ self.create_act_operations( states=states, internals=internals, ...
def create_operations(self, states, internals, actions, terminal, reward, deterministic, independent, index): """ Creates and stores tf operations for when `act()` and `observe()` are called. """ self.create_act_operations( states=states, internals=internals, ...
[ "Creates", "and", "stores", "tf", "operations", "for", "when", "act", "()", "and", "observe", "()", "are", "called", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1246-L1269
[ "def", "create_operations", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ",", "deterministic", ",", "independent", ",", "index", ")", ":", "self", ".", "create_act_operations", "(", "states", "=", "states", ",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.get_variables
Returns the TensorFlow variables used by the model. Args: include_submodules: Includes variables of submodules (e.g. baseline, target network) if true. include_nontrainable: Includes non-trainable variables if true. Returns: List of variables.
tensorforce/models/model.py
def get_variables(self, include_submodules=False, include_nontrainable=False): """ Returns the TensorFlow variables used by the model. Args: include_submodules: Includes variables of submodules (e.g. baseline, target network) if true. include_nontrainable...
def get_variables(self, include_submodules=False, include_nontrainable=False): """ Returns the TensorFlow variables used by the model. Args: include_submodules: Includes variables of submodules (e.g. baseline, target network) if true. include_nontrainable...
[ "Returns", "the", "TensorFlow", "variables", "used", "by", "the", "model", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1271-L1305
[ "def", "get_variables", "(", "self", ",", "include_submodules", "=", "False", ",", "include_nontrainable", "=", "False", ")", ":", "if", "include_nontrainable", ":", "model_variables", "=", "[", "self", ".", "all_variables", "[", "key", "]", "for", "key", "in"...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.reset
Resets the model to its initial state on episode start. This should also reset all preprocessor(s). Returns: tuple: Current episode, timestep counter and the shallow-copied list of internal state initialization Tensors.
tensorforce/models/model.py
def reset(self): """ Resets the model to its initial state on episode start. This should also reset all preprocessor(s). Returns: tuple: Current episode, timestep counter and the shallow-copied list of internal state initialization Tensors. """ fetche...
def reset(self): """ Resets the model to its initial state on episode start. This should also reset all preprocessor(s). Returns: tuple: Current episode, timestep counter and the shallow-copied list of internal state initialization Tensors. """ fetche...
[ "Resets", "the", "model", "to", "its", "initial", "state", "on", "episode", "start", ".", "This", "should", "also", "reset", "all", "preprocessor", "(", "s", ")", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1307-L1330
[ "def", "reset", "(", "self", ")", ":", "fetches", "=", "[", "self", ".", "global_episode", ",", "self", ".", "global_timestep", "]", "# Loop through all preprocessors and reset them as well.", "for", "name", "in", "sorted", "(", "self", ".", "states_preprocessing", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.get_feed_dict
Returns the feed-dict for the model's acting and observing tf fetches. Args: states (dict): Dict of state values (each key represents one state space component). internals (dict): Dict of internal state values (each key represents one internal state component). actions (dict...
tensorforce/models/model.py
def get_feed_dict( self, states=None, internals=None, actions=None, terminal=None, reward=None, deterministic=None, independent=None, index=None ): """ Returns the feed-dict for the model's acting and observing tf fetches. ...
def get_feed_dict( self, states=None, internals=None, actions=None, terminal=None, reward=None, deterministic=None, independent=None, index=None ): """ Returns the feed-dict for the model's acting and observing tf fetches. ...
[ "Returns", "the", "feed", "-", "dict", "for", "the", "model", "s", "acting", "and", "observing", "tf", "fetches", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1332-L1417
[ "def", "get_feed_dict", "(", "self", ",", "states", "=", "None", ",", "internals", "=", "None", ",", "actions", "=", "None", ",", "terminal", "=", "None", ",", "reward", "=", "None", ",", "deterministic", "=", "None", ",", "independent", "=", "None", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.act
Does a forward pass through the model to retrieve action (outputs) given inputs for state (and internal state, if applicable (e.g. RNNs)) Args: states (dict): Dict of state values (each key represents one state space component). internals (dict): Dict of internal state values (e...
tensorforce/models/model.py
def act(self, states, internals, deterministic=False, independent=False, fetch_tensors=None, index=0): """ Does a forward pass through the model to retrieve action (outputs) given inputs for state (and internal state, if applicable (e.g. RNNs)) Args: states (dict): Dict of s...
def act(self, states, internals, deterministic=False, independent=False, fetch_tensors=None, index=0): """ Does a forward pass through the model to retrieve action (outputs) given inputs for state (and internal state, if applicable (e.g. RNNs)) Args: states (dict): Dict of s...
[ "Does", "a", "forward", "pass", "through", "the", "model", "to", "retrieve", "action", "(", "outputs", ")", "given", "inputs", "for", "state", "(", "and", "internal", "state", "if", "applicable", "(", "e", ".", "g", ".", "RNNs", "))" ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1419-L1479
[ "def", "act", "(", "self", ",", "states", ",", "internals", ",", "deterministic", "=", "False", ",", "independent", "=", "False", ",", "fetch_tensors", "=", "None", ",", "index", "=", "0", ")", ":", "name", "=", "next", "(", "iter", "(", "states", ")...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.observe
Adds an observation (reward and is-terminal) to the model without updating its trainable variables. Args: terminal (List[bool]): List of is-terminal signals. reward (List[float]): List of reward signals. index: (int) parallel episode you want to observe Returns: ...
tensorforce/models/model.py
def observe(self, terminal, reward, index=0): """ Adds an observation (reward and is-terminal) to the model without updating its trainable variables. Args: terminal (List[bool]): List of is-terminal signals. reward (List[float]): List of reward signals. index...
def observe(self, terminal, reward, index=0): """ Adds an observation (reward and is-terminal) to the model without updating its trainable variables. Args: terminal (List[bool]): List of is-terminal signals. reward (List[float]): List of reward signals. index...
[ "Adds", "an", "observation", "(", "reward", "and", "is", "-", "terminal", ")", "to", "the", "model", "without", "updating", "its", "trainable", "variables", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1481-L1498
[ "def", "observe", "(", "self", ",", "terminal", ",", "reward", ",", "index", "=", "0", ")", ":", "fetches", "=", "self", ".", "episode_output", "feed_dict", "=", "self", ".", "get_feed_dict", "(", "terminal", "=", "terminal", ",", "reward", "=", "reward"...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.save
Save TensorFlow model. If no checkpoint directory is given, the model's default saver directory is used. Optionally appends current timestep to prevent overwriting previous checkpoint files. Turn off to be able to load model from the same given path argument as given here. Args: ...
tensorforce/models/model.py
def save(self, directory=None, append_timestep=True): """ Save TensorFlow model. If no checkpoint directory is given, the model's default saver directory is used. Optionally appends current timestep to prevent overwriting previous checkpoint files. Turn off to be able to load model from ...
def save(self, directory=None, append_timestep=True): """ Save TensorFlow model. If no checkpoint directory is given, the model's default saver directory is used. Optionally appends current timestep to prevent overwriting previous checkpoint files. Turn off to be able to load model from ...
[ "Save", "TensorFlow", "model", ".", "If", "no", "checkpoint", "directory", "is", "given", "the", "model", "s", "default", "saver", "directory", "is", "used", ".", "Optionally", "appends", "current", "timestep", "to", "prevent", "overwriting", "previous", "checkp...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1515-L1540
[ "def", "save", "(", "self", ",", "directory", "=", "None", ",", "append_timestep", "=", "True", ")", ":", "if", "self", ".", "flush_summarizer", "is", "not", "None", ":", "self", ".", "monitored_session", ".", "run", "(", "fetches", "=", "self", ".", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.restore
Restore TensorFlow model. If no checkpoint file is given, the latest checkpoint is restored. If no checkpoint directory is given, the model's default saver directory is used (unless file specifies the entire path). Args: directory: Optional checkpoint directory. file: Op...
tensorforce/models/model.py
def restore(self, directory=None, file=None): """ Restore TensorFlow model. If no checkpoint file is given, the latest checkpoint is restored. If no checkpoint directory is given, the model's default saver directory is used (unless file specifies the entire path). Args: ...
def restore(self, directory=None, file=None): """ Restore TensorFlow model. If no checkpoint file is given, the latest checkpoint is restored. If no checkpoint directory is given, the model's default saver directory is used (unless file specifies the entire path). Args: ...
[ "Restore", "TensorFlow", "model", ".", "If", "no", "checkpoint", "file", "is", "given", "the", "latest", "checkpoint", "is", "restored", ".", "If", "no", "checkpoint", "directory", "is", "given", "the", "model", "s", "default", "saver", "directory", "is", "u...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1542-L1566
[ "def", "restore", "(", "self", ",", "directory", "=", "None", ",", "file", "=", "None", ")", ":", "if", "file", "is", "None", ":", "file", "=", "tf", ".", "train", ".", "latest_checkpoint", "(", "checkpoint_dir", "=", "(", "self", ".", "saver_directory...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.get_savable_components
Returns the list of all of the components this model consists of that can be individually saved and restored. For instance the network or distribution. Returns: List of util.SavableComponent
tensorforce/models/model.py
def get_savable_components(self): """ Returns the list of all of the components this model consists of that can be individually saved and restored. For instance the network or distribution. Returns: List of util.SavableComponent """ components = self.get_comp...
def get_savable_components(self): """ Returns the list of all of the components this model consists of that can be individually saved and restored. For instance the network or distribution. Returns: List of util.SavableComponent """ components = self.get_comp...
[ "Returns", "the", "list", "of", "all", "of", "the", "components", "this", "model", "consists", "of", "that", "can", "be", "individually", "saved", "and", "restored", ".", "For", "instance", "the", "network", "or", "distribution", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1577-L1587
[ "def", "get_savable_components", "(", "self", ")", ":", "components", "=", "self", ".", "get_components", "(", ")", "components", "=", "[", "components", "[", "name", "]", "for", "name", "in", "sorted", "(", "components", ")", "]", "return", "set", "(", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.save_component
Saves a component of this model to the designated location. Args: component_name: The component to save. save_path: The location to save to. Returns: Checkpoint path where the component was saved.
tensorforce/models/model.py
def save_component(self, component_name, save_path): """ Saves a component of this model to the designated location. Args: component_name: The component to save. save_path: The location to save to. Returns: Checkpoint path where the component was save...
def save_component(self, component_name, save_path): """ Saves a component of this model to the designated location. Args: component_name: The component to save. save_path: The location to save to. Returns: Checkpoint path where the component was save...
[ "Saves", "a", "component", "of", "this", "model", "to", "the", "designated", "location", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1596-L1608
[ "def", "save_component", "(", "self", ",", "component_name", ",", "save_path", ")", ":", "component", "=", "self", ".", "get_component", "(", "component_name", "=", "component_name", ")", "self", ".", "_validate_savable", "(", "component", "=", "component", ",",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.restore_component
Restores a component's parameters from a save location. Args: component_name: The component to restore. save_path: The save location.
tensorforce/models/model.py
def restore_component(self, component_name, save_path): """ Restores a component's parameters from a save location. Args: component_name: The component to restore. save_path: The save location. """ component = self.get_component(component_name=component_n...
def restore_component(self, component_name, save_path): """ Restores a component's parameters from a save location. Args: component_name: The component to restore. save_path: The save location. """ component = self.get_component(component_name=component_n...
[ "Restores", "a", "component", "s", "parameters", "from", "a", "save", "location", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1610-L1620
[ "def", "restore_component", "(", "self", ",", "component_name", ",", "save_path", ")", ":", "component", "=", "self", ".", "get_component", "(", "component_name", "=", "component_name", ")", "self", ".", "_validate_savable", "(", "component", "=", "component", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Model.get_component
Looks up a component by its name. Args: component_name: The name of the component to look up. Returns: The component for the provided name or None if there is no such component.
tensorforce/models/model.py
def get_component(self, component_name): """ Looks up a component by its name. Args: component_name: The name of the component to look up. Returns: The component for the provided name or None if there is no such component. """ mapping = self.get_c...
def get_component(self, component_name): """ Looks up a component by its name. Args: component_name: The name of the component to look up. Returns: The component for the provided name or None if there is no such component. """ mapping = self.get_c...
[ "Looks", "up", "a", "component", "by", "its", "name", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1622-L1632
[ "def", "get_component", "(", "self", ",", "component_name", ")", ":", "mapping", "=", "self", ".", "get_components", "(", ")", "return", "mapping", "[", "component_name", "]", "if", "component_name", "in", "mapping", "else", "None" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
DQFDAgent.import_demonstrations
Imports demonstrations, i.e. expert observations. Note that for large numbers of observations, set_demonstrations is more appropriate, which directly sets memory contents to an array an expects a different layout. Args: demonstrations: List of observation dicts
tensorforce/agents/dqfd_agent.py
def import_demonstrations(self, demonstrations): """ Imports demonstrations, i.e. expert observations. Note that for large numbers of observations, set_demonstrations is more appropriate, which directly sets memory contents to an array an expects a different layout. Args: ...
def import_demonstrations(self, demonstrations): """ Imports demonstrations, i.e. expert observations. Note that for large numbers of observations, set_demonstrations is more appropriate, which directly sets memory contents to an array an expects a different layout. Args: ...
[ "Imports", "demonstrations", "i", ".", "e", ".", "expert", "observations", ".", "Note", "that", "for", "large", "numbers", "of", "observations", "set_demonstrations", "is", "more", "appropriate", "which", "directly", "sets", "memory", "contents", "to", "an", "ar...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/agents/dqfd_agent.py#L204-L256
[ "def", "import_demonstrations", "(", "self", ",", "demonstrations", ")", ":", "if", "isinstance", "(", "demonstrations", ",", "dict", ")", ":", "if", "self", ".", "unique_state", ":", "demonstrations", "[", "'states'", "]", "=", "dict", "(", "state", "=", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PLE.seed
Sets the random seed of the environment to the given value (current time, if seed=None). Naturally deterministic Environments (e.g. ALE or some gym Envs) don't have to implement this method. Args: seed (int): The seed to use for initializing the pseudo-random number generator (default=epoch...
tensorforce/contrib/pygame_learning_environment.py
def seed(self, seed): # pylint: disable=E0202 """ Sets the random seed of the environment to the given value (current time, if seed=None). Naturally deterministic Environments (e.g. ALE or some gym Envs) don't have to implement this method. Args: seed (int): The seed to use ...
def seed(self, seed): # pylint: disable=E0202 """ Sets the random seed of the environment to the given value (current time, if seed=None). Naturally deterministic Environments (e.g. ALE or some gym Envs) don't have to implement this method. Args: seed (int): The seed to use ...
[ "Sets", "the", "random", "seed", "of", "the", "environment", "to", "the", "given", "value", "(", "current", "time", "if", "seed", "=", "None", ")", ".", "Naturally", "deterministic", "Environments", "(", "e", ".", "g", ".", "ALE", "or", "some", "gym", ...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/pygame_learning_environment.py#L71-L84
[ "def", "seed", "(", "self", ",", "seed", ")", ":", "# pylint: disable=E0202", "if", "seed", "is", "None", ":", "self", ".", "env", ".", "seed", "=", "round", "(", "time", ".", "time", "(", ")", ")", "else", ":", "self", ".", "env", ".", "seed", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PLE.execute
Executes action, observes next state and reward. Args: actions: Action to execute. Returns: (Dict of) next state(s), boolean indicating terminal, and reward signal.
tensorforce/contrib/pygame_learning_environment.py
def execute(self, action): """ Executes action, observes next state and reward. Args: actions: Action to execute. Returns: (Dict of) next state(s), boolean indicating terminal, and reward signal. """ if self.env.game_over(): return se...
def execute(self, action): """ Executes action, observes next state and reward. Args: actions: Action to execute. Returns: (Dict of) next state(s), boolean indicating terminal, and reward signal. """ if self.env.game_over(): return se...
[ "Executes", "action", "observes", "next", "state", "and", "reward", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/pygame_learning_environment.py#L96-L113
[ "def", "execute", "(", "self", ",", "action", ")", ":", "if", "self", ".", "env", ".", "game_over", "(", ")", ":", "return", "self", ".", "env", ".", "getScreenRGB", "(", ")", ",", "True", ",", "0", "action_space", "=", "self", ".", "env", ".", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PLE.states
Return the state space. Might include subdicts if multiple states are available simultaneously. Returns: dict of state properties (shape and type).
tensorforce/contrib/pygame_learning_environment.py
def states(self): """ Return the state space. Might include subdicts if multiple states are available simultaneously. Returns: dict of state properties (shape and type). """ screen = self.env.getScreenRGB() return dict(shape=screen.shape, type='int')
def states(self): """ Return the state space. Might include subdicts if multiple states are available simultaneously. Returns: dict of state properties (shape and type). """ screen = self.env.getScreenRGB() return dict(shape=screen.shape, type='int')
[ "Return", "the", "state", "space", ".", "Might", "include", "subdicts", "if", "multiple", "states", "are", "available", "simultaneously", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/pygame_learning_environment.py#L116-L125
[ "def", "states", "(", "self", ")", ":", "screen", "=", "self", ".", "env", ".", "getScreenRGB", "(", ")", "return", "dict", "(", "shape", "=", "screen", ".", "shape", ",", "type", "=", "'int'", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
sanity_check_states
Sanity checks a states dict, used to define the state space for an MDP. Throws an error or warns if mismatches are found. Args: states_spec (Union[None,dict]): The spec-dict to check (or None). Returns: Tuple of 1) the state space desc and 2) whether there is only one component in the state space.
tensorforce/contrib/sanity_check_specs.py
def sanity_check_states(states_spec): """ Sanity checks a states dict, used to define the state space for an MDP. Throws an error or warns if mismatches are found. Args: states_spec (Union[None,dict]): The spec-dict to check (or None). Returns: Tuple of 1) the state space desc and 2) wheth...
def sanity_check_states(states_spec): """ Sanity checks a states dict, used to define the state space for an MDP. Throws an error or warns if mismatches are found. Args: states_spec (Union[None,dict]): The spec-dict to check (or None). Returns: Tuple of 1) the state space desc and 2) wheth...
[ "Sanity", "checks", "a", "states", "dict", "used", "to", "define", "the", "state", "space", "for", "an", "MDP", ".", "Throws", "an", "error", "or", "warns", "if", "mismatches", "are", "found", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/sanity_check_specs.py#L24-L52
[ "def", "sanity_check_states", "(", "states_spec", ")", ":", "# Leave incoming states dict intact.", "states", "=", "copy", ".", "deepcopy", "(", "states_spec", ")", "# Unique state shortform.", "is_unique", "=", "(", "'shape'", "in", "states", ")", "if", "is_unique", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
sanity_check_actions
Sanity checks an actions dict, used to define the action space for an MDP. Throws an error or warns if mismatches are found. Args: actions_spec (Union[None,dict]): The spec-dict to check (or None). Returns: Tuple of 1) the action space desc and 2) whether there is only one component in the action ...
tensorforce/contrib/sanity_check_specs.py
def sanity_check_actions(actions_spec): """ Sanity checks an actions dict, used to define the action space for an MDP. Throws an error or warns if mismatches are found. Args: actions_spec (Union[None,dict]): The spec-dict to check (or None). Returns: Tuple of 1) the action space desc and 2...
def sanity_check_actions(actions_spec): """ Sanity checks an actions dict, used to define the action space for an MDP. Throws an error or warns if mismatches are found. Args: actions_spec (Union[None,dict]): The spec-dict to check (or None). Returns: Tuple of 1) the action space desc and 2...
[ "Sanity", "checks", "an", "actions", "dict", "used", "to", "define", "the", "action", "space", "for", "an", "MDP", ".", "Throws", "an", "error", "or", "warns", "if", "mismatches", "are", "found", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/sanity_check_specs.py#L55-L95
[ "def", "sanity_check_actions", "(", "actions_spec", ")", ":", "# Leave incoming spec-dict intact.", "actions", "=", "copy", ".", "deepcopy", "(", "actions_spec", ")", "# Unique action shortform.", "is_unique", "=", "(", "'type'", "in", "actions", ")", "if", "is_unique...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
sanity_check_execution_spec
Sanity checks a execution_spec dict, used to define execution logic (distributed vs single, shared memories, etc..) and distributed learning behavior of agents/models. Throws an error or warns if mismatches are found. Args: execution_spec (Union[None,dict]): The spec-dict to check (or None). Dict n...
tensorforce/contrib/sanity_check_specs.py
def sanity_check_execution_spec(execution_spec): """ Sanity checks a execution_spec dict, used to define execution logic (distributed vs single, shared memories, etc..) and distributed learning behavior of agents/models. Throws an error or warns if mismatches are found. Args: execution_spec...
def sanity_check_execution_spec(execution_spec): """ Sanity checks a execution_spec dict, used to define execution logic (distributed vs single, shared memories, etc..) and distributed learning behavior of agents/models. Throws an error or warns if mismatches are found. Args: execution_spec...
[ "Sanity", "checks", "a", "execution_spec", "dict", "used", "to", "define", "execution", "logic", "(", "distributed", "vs", "single", "shared", "memories", "etc", "..", ")", "and", "distributed", "learning", "behavior", "of", "agents", "/", "models", ".", "Thro...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/sanity_check_specs.py#L98-L150
[ "def", "sanity_check_execution_spec", "(", "execution_spec", ")", ":", "# default spec: single mode", "def_", "=", "dict", "(", "type", "=", "\"single\"", ",", "distributed_spec", "=", "None", ",", "session_config", "=", "None", ")", "if", "execution_spec", "is", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
make_game
Builds and returns an Extraterrestrial Marauders game.
examples/extraterrestrial_maurauders.py
def make_game(): """Builds and returns an Extraterrestrial Marauders game.""" return ascii_art.ascii_art_to_game( GAME_ART, what_lies_beneath=' ', sprites=dict( [('P', PlayerSprite)] + [(c, UpwardLaserBoltSprite) for c in UPWARD_BOLT_CHARS] + [(c, DownwardLaserBoltSprite) f...
def make_game(): """Builds and returns an Extraterrestrial Marauders game.""" return ascii_art.ascii_art_to_game( GAME_ART, what_lies_beneath=' ', sprites=dict( [('P', PlayerSprite)] + [(c, UpwardLaserBoltSprite) for c in UPWARD_BOLT_CHARS] + [(c, DownwardLaserBoltSprite) f...
[ "Builds", "and", "returns", "an", "Extraterrestrial", "Marauders", "game", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/examples/extraterrestrial_maurauders.py#L78-L88
[ "def", "make_game", "(", ")", ":", "return", "ascii_art", ".", "ascii_art_to_game", "(", "GAME_ART", ",", "what_lies_beneath", "=", "' '", ",", "sprites", "=", "dict", "(", "[", "(", "'P'", ",", "PlayerSprite", ")", "]", "+", "[", "(", "c", ",", "Upwar...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
UpwardLaserBoltSprite._fly
Handles the behaviour of visible bolts flying toward Marauders.
examples/extraterrestrial_maurauders.py
def _fly(self, board, layers, things, the_plot): """Handles the behaviour of visible bolts flying toward Marauders.""" # Disappear if we've hit a Marauder or a bunker. if (self.character in the_plot['bunker_hitters'] or self.character in the_plot['marauder_hitters']): return self._teleport((-1...
def _fly(self, board, layers, things, the_plot): """Handles the behaviour of visible bolts flying toward Marauders.""" # Disappear if we've hit a Marauder or a bunker. if (self.character in the_plot['bunker_hitters'] or self.character in the_plot['marauder_hitters']): return self._teleport((-1...
[ "Handles", "the", "behaviour", "of", "visible", "bolts", "flying", "toward", "Marauders", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/examples/extraterrestrial_maurauders.py#L191-L198
[ "def", "_fly", "(", "self", ",", "board", ",", "layers", ",", "things", ",", "the_plot", ")", ":", "# Disappear if we've hit a Marauder or a bunker.", "if", "(", "self", ".", "character", "in", "the_plot", "[", "'bunker_hitters'", "]", "or", "self", ".", "char...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
UpwardLaserBoltSprite._fire
Launches a new bolt from the player.
examples/extraterrestrial_maurauders.py
def _fire(self, layers, things, the_plot): """Launches a new bolt from the player.""" # We don't fire if the player fired another bolt just now. if the_plot.get('last_player_shot') == the_plot.frame: return the_plot['last_player_shot'] = the_plot.frame # We start just above the player. row, col ...
def _fire(self, layers, things, the_plot): """Launches a new bolt from the player.""" # We don't fire if the player fired another bolt just now. if the_plot.get('last_player_shot') == the_plot.frame: return the_plot['last_player_shot'] = the_plot.frame # We start just above the player. row, col ...
[ "Launches", "a", "new", "bolt", "from", "the", "player", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/examples/extraterrestrial_maurauders.py#L200-L207
[ "def", "_fire", "(", "self", ",", "layers", ",", "things", ",", "the_plot", ")", ":", "# We don't fire if the player fired another bolt just now.", "if", "the_plot", ".", "get", "(", "'last_player_shot'", ")", "==", "the_plot", ".", "frame", ":", "return", "the_pl...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
DownwardLaserBoltSprite._fly
Handles the behaviour of visible bolts flying toward the player.
examples/extraterrestrial_maurauders.py
def _fly(self, board, layers, things, the_plot): """Handles the behaviour of visible bolts flying toward the player.""" # Disappear if we've hit a bunker. if self.character in the_plot['bunker_hitters']: return self._teleport((-1, -1)) # End the game if we've hit the player. if self.position =...
def _fly(self, board, layers, things, the_plot): """Handles the behaviour of visible bolts flying toward the player.""" # Disappear if we've hit a bunker. if self.character in the_plot['bunker_hitters']: return self._teleport((-1, -1)) # End the game if we've hit the player. if self.position =...
[ "Handles", "the", "behaviour", "of", "visible", "bolts", "flying", "toward", "the", "player", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/examples/extraterrestrial_maurauders.py#L225-L232
[ "def", "_fly", "(", "self", ",", "board", ",", "layers", ",", "things", ",", "the_plot", ")", ":", "# Disappear if we've hit a bunker.", "if", "self", ".", "character", "in", "the_plot", "[", "'bunker_hitters'", "]", ":", "return", "self", ".", "_teleport", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
DownwardLaserBoltSprite._fire
Launches a new bolt from a random Marauder.
examples/extraterrestrial_maurauders.py
def _fire(self, layers, the_plot): """Launches a new bolt from a random Marauder.""" # We don't fire if another Marauder fired a bolt just now. if the_plot.get('last_marauder_shot') == the_plot.frame: return the_plot['last_marauder_shot'] = the_plot.frame # Which Marauder should fire the laser bolt?...
def _fire(self, layers, the_plot): """Launches a new bolt from a random Marauder.""" # We don't fire if another Marauder fired a bolt just now. if the_plot.get('last_marauder_shot') == the_plot.frame: return the_plot['last_marauder_shot'] = the_plot.frame # Which Marauder should fire the laser bolt?...
[ "Launches", "a", "new", "bolt", "from", "a", "random", "Marauder", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/examples/extraterrestrial_maurauders.py#L234-L243
[ "def", "_fire", "(", "self", ",", "layers", ",", "the_plot", ")", ":", "# We don't fire if another Marauder fired a bolt just now.", "if", "the_plot", ".", "get", "(", "'last_marauder_shot'", ")", "==", "the_plot", ".", "frame", ":", "return", "the_plot", "[", "'l...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
BaseRunner.reset
Resets the Runner's internal stats counters. If history is empty, use default values in history.get(). Args: history (dict): A dictionary containing an already run experiment's results. Keys should be: episode_rewards (list of rewards), episode_timesteps (lengths of episodes...
tensorforce/execution/base_runner.py
def reset(self, history=None): """ Resets the Runner's internal stats counters. If history is empty, use default values in history.get(). Args: history (dict): A dictionary containing an already run experiment's results. Keys should be: episode_rewards (list ...
def reset(self, history=None): """ Resets the Runner's internal stats counters. If history is empty, use default values in history.get(). Args: history (dict): A dictionary containing an already run experiment's results. Keys should be: episode_rewards (list ...
[ "Resets", "the", "Runner", "s", "internal", "stats", "counters", ".", "If", "history", "is", "empty", "use", "default", "values", "in", "history", ".", "get", "()", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/execution/base_runner.py#L53-L67
[ "def", "reset", "(", "self", ",", "history", "=", "None", ")", ":", "if", "not", "history", ":", "history", "=", "dict", "(", ")", "self", ".", "episode_rewards", "=", "history", ".", "get", "(", "\"episode_rewards\"", ",", "list", "(", ")", ")", "se...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
BaseRunner.run
Executes this runner by starting to act (via Agent(s)) in the given Environment(s). Stops execution according to certain conditions (e.g. max. number of episodes, etc..). Calls callback functions after each episode and/or after some summary criteria are met. Args: num_episodes (int)...
tensorforce/execution/base_runner.py
def run(self, num_episodes, num_timesteps, max_episode_timesteps, deterministic, episode_finished, summary_report, summary_interval): """ Executes this runner by starting to act (via Agent(s)) in the given Environment(s). Stops execution according to certain conditions (e.g. max. num...
def run(self, num_episodes, num_timesteps, max_episode_timesteps, deterministic, episode_finished, summary_report, summary_interval): """ Executes this runner by starting to act (via Agent(s)) in the given Environment(s). Stops execution according to certain conditions (e.g. max. num...
[ "Executes", "this", "runner", "by", "starting", "to", "act", "(", "via", "Agent", "(", "s", "))", "in", "the", "given", "Environment", "(", "s", ")", ".", "Stops", "execution", "according", "to", "certain", "conditions", "(", "e", ".", "g", ".", "max",...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/execution/base_runner.py#L75-L95
[ "def", "run", "(", "self", ",", "num_episodes", ",", "num_timesteps", ",", "max_episode_timesteps", ",", "deterministic", ",", "episode_finished", ",", "summary_report", ",", "summary_interval", ")", ":", "raise", "NotImplementedError" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PrioritizedReplay.tf_retrieve_indices
Fetches experiences for given indices by combining entries from buffer which have no priorities, and entries from priority memory. Args: buffer_elements: Number of buffer elements to retrieve priority_indices: Index tensor for priority memory Returns: Batch of experienc...
tensorforce/core/memories/prioritized_replay.py
def tf_retrieve_indices(self, buffer_elements, priority_indices): """ Fetches experiences for given indices by combining entries from buffer which have no priorities, and entries from priority memory. Args: buffer_elements: Number of buffer elements to retrieve p...
def tf_retrieve_indices(self, buffer_elements, priority_indices): """ Fetches experiences for given indices by combining entries from buffer which have no priorities, and entries from priority memory. Args: buffer_elements: Number of buffer elements to retrieve p...
[ "Fetches", "experiences", "for", "given", "indices", "by", "combining", "entries", "from", "buffer", "which", "have", "no", "priorities", "and", "entries", "from", "priority", "memory", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/prioritized_replay.py#L351-L434
[ "def", "tf_retrieve_indices", "(", "self", ",", "buffer_elements", ",", "priority_indices", ")", ":", "states", "=", "dict", "(", ")", "buffer_start", "=", "self", ".", "buffer_index", "-", "buffer_elements", "buffer_end", "=", "self", ".", "buffer_index", "# Fe...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PrioritizedReplay.tf_update_batch
Updates priority memory by performing the following steps: 1. Use saved indices from prior retrieval to reconstruct the batch elements which will have their priorities updated. 2. Compute priorities for these elements. 3. Insert buffer elements to memory, potentially overwriting existin...
tensorforce/core/memories/prioritized_replay.py
def tf_update_batch(self, loss_per_instance): """ Updates priority memory by performing the following steps: 1. Use saved indices from prior retrieval to reconstruct the batch elements which will have their priorities updated. 2. Compute priorities for these elements. 3....
def tf_update_batch(self, loss_per_instance): """ Updates priority memory by performing the following steps: 1. Use saved indices from prior retrieval to reconstruct the batch elements which will have their priorities updated. 2. Compute priorities for these elements. 3....
[ "Updates", "priority", "memory", "by", "performing", "the", "following", "steps", ":" ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/prioritized_replay.py#L436-L602
[ "def", "tf_update_batch", "(", "self", ",", "loss_per_instance", ")", ":", "# 1. We reconstruct the batch from the buffer and the priority memory via", "# the TensorFlow variables holding the respective indices.", "mask", "=", "tf", ".", "not_equal", "(", "x", "=", "self", ".",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
DistributionModel.setup_components_and_tf_funcs
Creates and stores Network and Distribution objects. Generates and stores all template functions.
tensorforce/models/distribution_model.py
def setup_components_and_tf_funcs(self, custom_getter=None): """ Creates and stores Network and Distribution objects. Generates and stores all template functions. """ # Create network before super-call, since non-empty internals_spec attribute (for RNN) is required subsequently. ...
def setup_components_and_tf_funcs(self, custom_getter=None): """ Creates and stores Network and Distribution objects. Generates and stores all template functions. """ # Create network before super-call, since non-empty internals_spec attribute (for RNN) is required subsequently. ...
[ "Creates", "and", "stores", "Network", "and", "Distribution", "objects", ".", "Generates", "and", "stores", "all", "template", "functions", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/distribution_model.py#L93-L132
[ "def", "setup_components_and_tf_funcs", "(", "self", ",", "custom_getter", "=", "None", ")", ":", "# Create network before super-call, since non-empty internals_spec attribute (for RNN) is required subsequently.", "self", ".", "network", "=", "Network", ".", "from_spec", "(", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
DistributionModel.create_distributions
Creates and returns the Distribution objects based on self.distributions_spec. Returns: Dict of distributions according to self.distributions_spec.
tensorforce/models/distribution_model.py
def create_distributions(self): """ Creates and returns the Distribution objects based on self.distributions_spec. Returns: Dict of distributions according to self.distributions_spec. """ distributions = dict() for name in sorted(self.actions_spec): action = ...
def create_distributions(self): """ Creates and returns the Distribution objects based on self.distributions_spec. Returns: Dict of distributions according to self.distributions_spec. """ distributions = dict() for name in sorted(self.actions_spec): action = ...
[ "Creates", "and", "returns", "the", "Distribution", "objects", "based", "on", "self", ".", "distributions_spec", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/distribution_model.py#L134-L185
[ "def", "create_distributions", "(", "self", ")", ":", "distributions", "=", "dict", "(", ")", "for", "name", "in", "sorted", "(", "self", ".", "actions_spec", ")", ":", "action", "=", "self", ".", "actions_spec", "[", "name", "]", "if", "self", ".", "d...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Exploration.from_spec
Creates an exploration object from a specification dict.
tensorforce/core/explorations/exploration.py
def from_spec(spec): """ Creates an exploration object from a specification dict. """ exploration = util.get_object( obj=spec, predefined_objects=tensorforce.core.explorations.explorations ) assert isinstance(exploration, Exploration) retur...
def from_spec(spec): """ Creates an exploration object from a specification dict. """ exploration = util.get_object( obj=spec, predefined_objects=tensorforce.core.explorations.explorations ) assert isinstance(exploration, Exploration) retur...
[ "Creates", "an", "exploration", "object", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/explorations/exploration.py#L65-L74
[ "def", "from_spec", "(", "spec", ")", ":", "exploration", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "core", ".", "explorations", ".", "explorations", ")", "assert", "isinstance", "(", "explor...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Memory.from_spec
Creates a memory from a specification dict.
tensorforce/core/memories/memory.py
def from_spec(spec, kwargs=None): """ Creates a memory from a specification dict. """ memory = util.get_object( obj=spec, predefined_objects=tensorforce.core.memories.memories, kwargs=kwargs ) assert isinstance(memory, Memory) r...
def from_spec(spec, kwargs=None): """ Creates a memory from a specification dict. """ memory = util.get_object( obj=spec, predefined_objects=tensorforce.core.memories.memories, kwargs=kwargs ) assert isinstance(memory, Memory) r...
[ "Creates", "a", "memory", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/memory.py#L182-L192
[ "def", "from_spec", "(", "spec", ",", "kwargs", "=", "None", ")", ":", "memory", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "core", ".", "memories", ".", "memories", ",", "kwargs", "=", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SubsamplingStep.tf_step
Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. arguments: Dict of arguments for callables, like fn_loss. **kwargs: Additional arguments passed on to the internal optimizer....
tensorforce/core/optimizers/subsampling_step.py
def tf_step( self, time, variables, arguments, **kwargs ): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. arguments: Dic...
def tf_step( self, time, variables, arguments, **kwargs ): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. arguments: Dic...
[ "Creates", "the", "TensorFlow", "operations", "for", "performing", "an", "optimization", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/subsampling_step.py#L45-L104
[ "def", "tf_step", "(", "self", ",", "time", ",", "variables", ",", "arguments", ",", "*", "*", "kwargs", ")", ":", "# Get some (batched) argument to determine batch size.", "arguments_iter", "=", "iter", "(", "arguments", ".", "values", "(", ")", ")", "some_argu...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Runner.run
Args: timesteps (int): Deprecated; see num_timesteps. episodes (int): Deprecated; see num_episodes.
tensorforce/execution/runner.py
def run(self, num_timesteps=None, num_episodes=None, max_episode_timesteps=None, deterministic=False, episode_finished=None, summary_report=None, summary_interval=None, timesteps=None, episodes=None, testing=False, sleep=None ): """ Args: timesteps (int): Deprecated; ...
def run(self, num_timesteps=None, num_episodes=None, max_episode_timesteps=None, deterministic=False, episode_finished=None, summary_report=None, summary_interval=None, timesteps=None, episodes=None, testing=False, sleep=None ): """ Args: timesteps (int): Deprecated; ...
[ "Args", ":", "timesteps", "(", "int", ")", ":", "Deprecated", ";", "see", "num_timesteps", ".", "episodes", "(", "int", ")", ":", "Deprecated", ";", "see", "num_episodes", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/execution/runner.py#L50-L149
[ "def", "run", "(", "self", ",", "num_timesteps", "=", "None", ",", "num_episodes", "=", "None", ",", "max_episode_timesteps", "=", "None", ",", "deterministic", "=", "False", ",", "episode_finished", "=", "None", ",", "summary_report", "=", "None", ",", "sum...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Queue.tf_retrieve_indices
Fetches experiences for given indices. Args: indices: Index tensor Returns: Batch of experiences
tensorforce/core/memories/queue.py
def tf_retrieve_indices(self, indices): """ Fetches experiences for given indices. Args: indices: Index tensor Returns: Batch of experiences """ states = dict() for name in sorted(self.states_memory): states[name] = tf.gather(params=self....
def tf_retrieve_indices(self, indices): """ Fetches experiences for given indices. Args: indices: Index tensor Returns: Batch of experiences """ states = dict() for name in sorted(self.states_memory): states[name] = tf.gather(params=self....
[ "Fetches", "experiences", "for", "given", "indices", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/memories/queue.py#L219-L271
[ "def", "tf_retrieve_indices", "(", "self", ",", "indices", ")", ":", "states", "=", "dict", "(", ")", "for", "name", "in", "sorted", "(", "self", ".", "states_memory", ")", ":", "states", "[", "name", "]", "=", "tf", ".", "gather", "(", "params", "="...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
LineSearch.tf_solve
Iteratively optimizes $f(x)$ for $x$ on the line between $x'$ and $x_0$. Args: fn_x: A callable returning the value $f(x)$ at $x$. x_init: Initial solution guess $x_0$. base_value: Value $f(x')$ at $x = x'$. target_value: Value $f(x_0)$ at $x = x_0$. ...
tensorforce/core/optimizers/solvers/line_search.py
def tf_solve(self, fn_x, x_init, base_value, target_value, estimated_improvement=None): """ Iteratively optimizes $f(x)$ for $x$ on the line between $x'$ and $x_0$. Args: fn_x: A callable returning the value $f(x)$ at $x$. x_init: Initial solution guess $x_0$. ...
def tf_solve(self, fn_x, x_init, base_value, target_value, estimated_improvement=None): """ Iteratively optimizes $f(x)$ for $x$ on the line between $x'$ and $x_0$. Args: fn_x: A callable returning the value $f(x)$ at $x$. x_init: Initial solution guess $x_0$. ...
[ "Iteratively", "optimizes", "$f", "(", "x", ")", "$", "for", "$x$", "on", "the", "line", "between", "$x", "$", "and", "$x_0$", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/line_search.py#L53-L67
[ "def", "tf_solve", "(", "self", ",", "fn_x", ",", "x_init", ",", "base_value", ",", "target_value", ",", "estimated_improvement", "=", "None", ")", ":", "return", "super", "(", "LineSearch", ",", "self", ")", ".", "tf_solve", "(", "fn_x", ",", "x_init", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
LineSearch.tf_initialize
Initialization step preparing the arguments for the first iteration of the loop body. Args: x_init: Initial solution guess $x_0$. base_value: Value $f(x')$ at $x = x'$. target_value: Value $f(x_0)$ at $x = x_0$. estimated_improvement: Estimated value at $x = x_0$...
tensorforce/core/optimizers/solvers/line_search.py
def tf_initialize(self, x_init, base_value, target_value, estimated_improvement): """ Initialization step preparing the arguments for the first iteration of the loop body. Args: x_init: Initial solution guess $x_0$. base_value: Value $f(x')$ at $x = x'$. targ...
def tf_initialize(self, x_init, base_value, target_value, estimated_improvement): """ Initialization step preparing the arguments for the first iteration of the loop body. Args: x_init: Initial solution guess $x_0$. base_value: Value $f(x')$ at $x = x'$. targ...
[ "Initialization", "step", "preparing", "the", "arguments", "for", "the", "first", "iteration", "of", "the", "loop", "body", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/line_search.py#L69-L103
[ "def", "tf_initialize", "(", "self", ",", "x_init", ",", "base_value", ",", "target_value", ",", "estimated_improvement", ")", ":", "self", ".", "base_value", "=", "base_value", "if", "estimated_improvement", "is", "None", ":", "# TODO: Is this a good alternative?", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
LineSearch.tf_step
Iteration loop body of the line search algorithm. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. deltas: Current difference $x_t - x'$. improvement: Current improvement $(f(x_t) - f(x')) / v'$. last_improvement: La...
tensorforce/core/optimizers/solvers/line_search.py
def tf_step(self, x, iteration, deltas, improvement, last_improvement, estimated_improvement): """ Iteration loop body of the line search algorithm. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. deltas: Current difference...
def tf_step(self, x, iteration, deltas, improvement, last_improvement, estimated_improvement): """ Iteration loop body of the line search algorithm. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. deltas: Current difference...
[ "Iteration", "loop", "body", "of", "the", "line", "search", "algorithm", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/line_search.py#L105-L141
[ "def", "tf_step", "(", "self", ",", "x", ",", "iteration", ",", "deltas", ",", "improvement", ",", "last_improvement", ",", "estimated_improvement", ")", ":", "x", ",", "next_iteration", ",", "deltas", ",", "improvement", ",", "last_improvement", ",", "estimat...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
LineSearch.tf_next_step
Termination condition: max number of iterations, or no improvement for last step, or improvement less than acceptable ratio, or estimated value not positive. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. deltas: Current differe...
tensorforce/core/optimizers/solvers/line_search.py
def tf_next_step(self, x, iteration, deltas, improvement, last_improvement, estimated_improvement): """ Termination condition: max number of iterations, or no improvement for last step, or improvement less than acceptable ratio, or estimated value not positive. Args: x: Cu...
def tf_next_step(self, x, iteration, deltas, improvement, last_improvement, estimated_improvement): """ Termination condition: max number of iterations, or no improvement for last step, or improvement less than acceptable ratio, or estimated value not positive. Args: x: Cu...
[ "Termination", "condition", ":", "max", "number", "of", "iterations", "or", "no", "improvement", "for", "last", "step", "or", "improvement", "less", "than", "acceptable", "ratio", "or", "estimated", "value", "not", "positive", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/line_search.py#L143-L177
[ "def", "tf_next_step", "(", "self", ",", "x", ",", "iteration", ",", "deltas", ",", "improvement", ",", "last_improvement", ",", "estimated_improvement", ")", ":", "next_step", "=", "super", "(", "LineSearch", ",", "self", ")", ".", "tf_next_step", "(", "x",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
escape
Replace special characters "&", "<" and ">" to HTML-safe sequences. The original cgi.escape will always escape "&", but you can control this one for a smart escape amp. :param quote: if set to True, " and ' will be escaped. :param smart_amp: if set to False, & will always be escaped.
docs/mistune.py
def escape(text, quote=False, smart_amp=True): """Replace special characters "&", "<" and ">" to HTML-safe sequences. The original cgi.escape will always escape "&", but you can control this one for a smart escape amp. :param quote: if set to True, " and ' will be escaped. :param smart_amp: if set...
def escape(text, quote=False, smart_amp=True): """Replace special characters "&", "<" and ">" to HTML-safe sequences. The original cgi.escape will always escape "&", but you can control this one for a smart escape amp. :param quote: if set to True, " and ' will be escaped. :param smart_amp: if set...
[ "Replace", "special", "characters", "&", "<", "and", ">", "to", "HTML", "-", "safe", "sequences", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L67-L85
[ "def", "escape", "(", "text", ",", "quote", "=", "False", ",", "smart_amp", "=", "True", ")", ":", "if", "smart_amp", ":", "text", "=", "_escape_pattern", ".", "sub", "(", "'&amp;'", ",", "text", ")", "else", ":", "text", "=", "text", ".", "replace",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
escape_link
Remove dangerous URL schemes like javascript: and escape afterwards.
docs/mistune.py
def escape_link(url): """Remove dangerous URL schemes like javascript: and escape afterwards.""" lower_url = url.lower().strip('\x00\x1a \n\r\t') for scheme in _scheme_blacklist: if lower_url.startswith(scheme): return '' return escape(url, quote=True, smart_amp=False)
def escape_link(url): """Remove dangerous URL schemes like javascript: and escape afterwards.""" lower_url = url.lower().strip('\x00\x1a \n\r\t') for scheme in _scheme_blacklist: if lower_url.startswith(scheme): return '' return escape(url, quote=True, smart_amp=False)
[ "Remove", "dangerous", "URL", "schemes", "like", "javascript", ":", "and", "escape", "afterwards", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L88-L94
[ "def", "escape_link", "(", "url", ")", ":", "lower_url", "=", "url", ".", "lower", "(", ")", ".", "strip", "(", "'\\x00\\x1a \\n\\r\\t'", ")", "for", "scheme", "in", "_scheme_blacklist", ":", "if", "lower_url", ".", "startswith", "(", "scheme", ")", ":", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
markdown
Render markdown formatted text to html. :param text: markdown formatted text content. :param escape: if set to False, all html tags will not be escaped. :param use_xhtml: output with xhtml tags. :param hard_wrap: if set to True, it will use the GFM line breaks feature. :param parse_block_html: pars...
docs/mistune.py
def markdown(text, escape=True, **kwargs): """Render markdown formatted text to html. :param text: markdown formatted text content. :param escape: if set to False, all html tags will not be escaped. :param use_xhtml: output with xhtml tags. :param hard_wrap: if set to True, it will use the GFM line...
def markdown(text, escape=True, **kwargs): """Render markdown formatted text to html. :param text: markdown formatted text content. :param escape: if set to False, all html tags will not be escaped. :param use_xhtml: output with xhtml tags. :param hard_wrap: if set to True, it will use the GFM line...
[ "Render", "markdown", "formatted", "text", "to", "html", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L1160-L1170
[ "def", "markdown", "(", "text", ",", "escape", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "Markdown", "(", "escape", "=", "escape", ",", "*", "*", "kwargs", ")", "(", "text", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
BlockLexer.parse_lheading
Parse setext heading.
docs/mistune.py
def parse_lheading(self, m): """Parse setext heading.""" self.tokens.append({ 'type': 'heading', 'level': 1 if m.group(2) == '=' else 2, 'text': m.group(1), })
def parse_lheading(self, m): """Parse setext heading.""" self.tokens.append({ 'type': 'heading', 'level': 1 if m.group(2) == '=' else 2, 'text': m.group(1), })
[ "Parse", "setext", "heading", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L271-L277
[ "def", "parse_lheading", "(", "self", ",", "m", ")", ":", "self", ".", "tokens", ".", "append", "(", "{", "'type'", ":", "'heading'", ",", "'level'", ":", "1", "if", "m", ".", "group", "(", "2", ")", "==", "'='", "else", "2", ",", "'text'", ":", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
InlineGrammar.hard_wrap
Grammar for hard wrap linebreak. You don't need to add two spaces at the end of a line.
docs/mistune.py
def hard_wrap(self): """Grammar for hard wrap linebreak. You don't need to add two spaces at the end of a line. """ self.linebreak = re.compile(r'^ *\n(?!\s*$)') self.text = re.compile( r'^[\s\S]+?(?=[\\<!\[_*`~]|https?://| *\n|$)' )
def hard_wrap(self): """Grammar for hard wrap linebreak. You don't need to add two spaces at the end of a line. """ self.linebreak = re.compile(r'^ *\n(?!\s*$)') self.text = re.compile( r'^[\s\S]+?(?=[\\<!\[_*`~]|https?://| *\n|$)' )
[ "Grammar", "for", "hard", "wrap", "linebreak", ".", "You", "don", "t", "need", "to", "add", "two", "spaces", "at", "the", "end", "of", "a", "line", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L495-L502
[ "def", "hard_wrap", "(", "self", ")", ":", "self", ".", "linebreak", "=", "re", ".", "compile", "(", "r'^ *\\n(?!\\s*$)'", ")", "self", ".", "text", "=", "re", ".", "compile", "(", "r'^[\\s\\S]+?(?=[\\\\<!\\[_*`~]|https?://| *\\n|$)'", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.block_code
Rendering block level code. ``pre > code``. :param code: text content of the code block. :param lang: language of the given code.
docs/mistune.py
def block_code(self, code, lang=None): """Rendering block level code. ``pre > code``. :param code: text content of the code block. :param lang: language of the given code. """ code = code.rstrip('\n') if not lang: code = escape(code, smart_amp=False) ...
def block_code(self, code, lang=None): """Rendering block level code. ``pre > code``. :param code: text content of the code block. :param lang: language of the given code. """ code = code.rstrip('\n') if not lang: code = escape(code, smart_amp=False) ...
[ "Rendering", "block", "level", "code", ".", "pre", ">", "code", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L701-L712
[ "def", "block_code", "(", "self", ",", "code", ",", "lang", "=", "None", ")", ":", "code", "=", "code", ".", "rstrip", "(", "'\\n'", ")", "if", "not", "lang", ":", "code", "=", "escape", "(", "code", ",", "smart_amp", "=", "False", ")", "return", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.block_html
Rendering block level pure html content. :param html: text content of the html snippet.
docs/mistune.py
def block_html(self, html): """Rendering block level pure html content. :param html: text content of the html snippet. """ if self.options.get('skip_style') and \ html.lower().startswith('<style'): return '' if self.options.get('escape'): retur...
def block_html(self, html): """Rendering block level pure html content. :param html: text content of the html snippet. """ if self.options.get('skip_style') and \ html.lower().startswith('<style'): return '' if self.options.get('escape'): retur...
[ "Rendering", "block", "level", "pure", "html", "content", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L721-L731
[ "def", "block_html", "(", "self", ",", "html", ")", ":", "if", "self", ".", "options", ".", "get", "(", "'skip_style'", ")", "and", "html", ".", "lower", "(", ")", ".", "startswith", "(", "'<style'", ")", ":", "return", "''", "if", "self", ".", "op...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.list
Rendering list tags like ``<ul>`` and ``<ol>``. :param body: body contents of the list. :param ordered: whether this list is ordered or not.
docs/mistune.py
def list(self, body, ordered=True): """Rendering list tags like ``<ul>`` and ``<ol>``. :param body: body contents of the list. :param ordered: whether this list is ordered or not. """ tag = 'ul' if ordered: tag = 'ol' return '<%s>\n%s</%s>\n' % (tag, ...
def list(self, body, ordered=True): """Rendering list tags like ``<ul>`` and ``<ol>``. :param body: body contents of the list. :param ordered: whether this list is ordered or not. """ tag = 'ul' if ordered: tag = 'ol' return '<%s>\n%s</%s>\n' % (tag, ...
[ "Rendering", "list", "tags", "like", "<ul", ">", "and", "<ol", ">", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L748-L757
[ "def", "list", "(", "self", ",", "body", ",", "ordered", "=", "True", ")", ":", "tag", "=", "'ul'", "if", "ordered", ":", "tag", "=", "'ol'", "return", "'<%s>\\n%s</%s>\\n'", "%", "(", "tag", ",", "body", ",", "tag", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.table_cell
Rendering a table cell. Like ``<th>`` ``<td>``. :param content: content of current table cell. :param header: whether this is header or not. :param align: align of current table cell.
docs/mistune.py
def table_cell(self, content, **flags): """Rendering a table cell. Like ``<th>`` ``<td>``. :param content: content of current table cell. :param header: whether this is header or not. :param align: align of current table cell. """ if flags['header']: tag = 't...
def table_cell(self, content, **flags): """Rendering a table cell. Like ``<th>`` ``<td>``. :param content: content of current table cell. :param header: whether this is header or not. :param align: align of current table cell. """ if flags['header']: tag = 't...
[ "Rendering", "a", "table", "cell", ".", "Like", "<th", ">", "<td", ">", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L785-L801
[ "def", "table_cell", "(", "self", ",", "content", ",", "*", "*", "flags", ")", ":", "if", "flags", "[", "'header'", "]", ":", "tag", "=", "'th'", "else", ":", "tag", "=", "'td'", "align", "=", "flags", "[", "'align'", "]", "if", "not", "align", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.codespan
Rendering inline `code` text. :param text: text content for inline code.
docs/mistune.py
def codespan(self, text): """Rendering inline `code` text. :param text: text content for inline code. """ text = escape(text.rstrip(), smart_amp=False) return '<code>%s</code>' % text
def codespan(self, text): """Rendering inline `code` text. :param text: text content for inline code. """ text = escape(text.rstrip(), smart_amp=False) return '<code>%s</code>' % text
[ "Rendering", "inline", "code", "text", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L817-L823
[ "def", "codespan", "(", "self", ",", "text", ")", ":", "text", "=", "escape", "(", "text", ".", "rstrip", "(", ")", ",", "smart_amp", "=", "False", ")", "return", "'<code>%s</code>'", "%", "text" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.autolink
Rendering a given link or email address. :param link: link content or email address. :param is_email: whether this is an email or not.
docs/mistune.py
def autolink(self, link, is_email=False): """Rendering a given link or email address. :param link: link content or email address. :param is_email: whether this is an email or not. """ text = link = escape(link) if is_email: link = 'mailto:%s' % link r...
def autolink(self, link, is_email=False): """Rendering a given link or email address. :param link: link content or email address. :param is_email: whether this is an email or not. """ text = link = escape(link) if is_email: link = 'mailto:%s' % link r...
[ "Rendering", "a", "given", "link", "or", "email", "address", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L854-L863
[ "def", "autolink", "(", "self", ",", "link", ",", "is_email", "=", "False", ")", ":", "text", "=", "link", "=", "escape", "(", "link", ")", "if", "is_email", ":", "link", "=", "'mailto:%s'", "%", "link", "return", "'<a href=\"%s\">%s</a>'", "%", "(", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.link
Rendering a given link with content and title. :param link: href link for ``<a>`` tag. :param title: title content for `title` attribute. :param text: text content for description.
docs/mistune.py
def link(self, link, title, text): """Rendering a given link with content and title. :param link: href link for ``<a>`` tag. :param title: title content for `title` attribute. :param text: text content for description. """ link = escape_link(link) if not title: ...
def link(self, link, title, text): """Rendering a given link with content and title. :param link: href link for ``<a>`` tag. :param title: title content for `title` attribute. :param text: text content for description. """ link = escape_link(link) if not title: ...
[ "Rendering", "a", "given", "link", "with", "content", "and", "title", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L865-L876
[ "def", "link", "(", "self", ",", "link", ",", "title", ",", "text", ")", ":", "link", "=", "escape_link", "(", "link", ")", "if", "not", "title", ":", "return", "'<a href=\"%s\">%s</a>'", "%", "(", "link", ",", "text", ")", "title", "=", "escape", "(...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.image
Rendering a image with title and text. :param src: source link of the image. :param title: title text of the image. :param text: alt text of the image.
docs/mistune.py
def image(self, src, title, text): """Rendering a image with title and text. :param src: source link of the image. :param title: title text of the image. :param text: alt text of the image. """ src = escape_link(src) text = escape(text, quote=True) if tit...
def image(self, src, title, text): """Rendering a image with title and text. :param src: source link of the image. :param title: title text of the image. :param text: alt text of the image. """ src = escape_link(src) text = escape(text, quote=True) if tit...
[ "Rendering", "a", "image", "with", "title", "and", "text", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L878-L894
[ "def", "image", "(", "self", ",", "src", ",", "title", ",", "text", ")", ":", "src", "=", "escape_link", "(", "src", ")", "text", "=", "escape", "(", "text", ",", "quote", "=", "True", ")", "if", "title", ":", "title", "=", "escape", "(", "title"...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.footnote_ref
Rendering the ref anchor of a footnote. :param key: identity key for the footnote. :param index: the index count of current footnote.
docs/mistune.py
def footnote_ref(self, key, index): """Rendering the ref anchor of a footnote. :param key: identity key for the footnote. :param index: the index count of current footnote. """ html = ( '<sup class="footnote-ref" id="fnref-%s">' '<a href="#fn-%s">%d</a></...
def footnote_ref(self, key, index): """Rendering the ref anchor of a footnote. :param key: identity key for the footnote. :param index: the index count of current footnote. """ html = ( '<sup class="footnote-ref" id="fnref-%s">' '<a href="#fn-%s">%d</a></...
[ "Rendering", "the", "ref", "anchor", "of", "a", "footnote", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L909-L919
[ "def", "footnote_ref", "(", "self", ",", "key", ",", "index", ")", ":", "html", "=", "(", "'<sup class=\"footnote-ref\" id=\"fnref-%s\">'", "'<a href=\"#fn-%s\">%d</a></sup>'", ")", "%", "(", "escape", "(", "key", ")", ",", "escape", "(", "key", ")", ",", "ind...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Renderer.footnote_item
Rendering a footnote item. :param key: identity key for the footnote. :param text: text content of the footnote.
docs/mistune.py
def footnote_item(self, key, text): """Rendering a footnote item. :param key: identity key for the footnote. :param text: text content of the footnote. """ back = ( '<a href="#fnref-%s" class="footnote">&#8617;</a>' ) % escape(key) text = text.rstrip(...
def footnote_item(self, key, text): """Rendering a footnote item. :param key: identity key for the footnote. :param text: text content of the footnote. """ back = ( '<a href="#fnref-%s" class="footnote">&#8617;</a>' ) % escape(key) text = text.rstrip(...
[ "Rendering", "a", "footnote", "item", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/mistune.py#L921-L936
[ "def", "footnote_item", "(", "self", ",", "key", ",", "text", ")", ":", "back", "=", "(", "'<a href=\"#fnref-%s\" class=\"footnote\">&#8617;</a>'", ")", "%", "escape", "(", "key", ")", "text", "=", "text", ".", "rstrip", "(", ")", "if", "text", ".", "endsw...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MetaParameterRecorder.build_metagraph_list
Convert MetaParams into TF Summary Format and create summary_op. Returns: Merged TF Op for TEXT summary elements, should only be executed once to reduce data duplication.
tensorforce/meta_parameter_recorder.py
def build_metagraph_list(self): """ Convert MetaParams into TF Summary Format and create summary_op. Returns: Merged TF Op for TEXT summary elements, should only be executed once to reduce data duplication. """ ops = [] self.ignore_unknown_dtypes = True ...
def build_metagraph_list(self): """ Convert MetaParams into TF Summary Format and create summary_op. Returns: Merged TF Op for TEXT summary elements, should only be executed once to reduce data duplication. """ ops = [] self.ignore_unknown_dtypes = True ...
[ "Convert", "MetaParams", "into", "TF", "Summary", "Format", "and", "create", "summary_op", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/meta_parameter_recorder.py#L242-L263
[ "def", "build_metagraph_list", "(", "self", ")", ":", "ops", "=", "[", "]", "self", ".", "ignore_unknown_dtypes", "=", "True", "for", "key", "in", "sorted", "(", "self", ".", "meta_params", ")", ":", "value", "=", "self", ".", "convert_data_to_string", "("...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
process_docstring
Enable markdown syntax in docstrings
docs/conf.py
def process_docstring(app, what, name, obj, options, lines): """Enable markdown syntax in docstrings""" markdown = "\n".join(lines) # ast = cm_parser.parse(markdown) # html = cm_renderer.render(ast) rest = m2r(markdown) rest.replace("\r\n", "\n") del lines[:] lines.extend(rest.spl...
def process_docstring(app, what, name, obj, options, lines): """Enable markdown syntax in docstrings""" markdown = "\n".join(lines) # ast = cm_parser.parse(markdown) # html = cm_renderer.render(ast) rest = m2r(markdown) rest.replace("\r\n", "\n") del lines[:] lines.extend(rest.spl...
[ "Enable", "markdown", "syntax", "in", "docstrings" ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/conf.py#L182-L193
[ "def", "process_docstring", "(", "app", ",", "what", ",", "name", ",", "obj", ",", "options", ",", "lines", ")", ":", "markdown", "=", "\"\\n\"", ".", "join", "(", "lines", ")", "# ast = cm_parser.parse(markdown)", "# html = cm_renderer.render(ast)", "rest", "="...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
NaturalGradient.tf_step
Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. arguments: Dict of arguments for callables, like fn_loss. fn_loss: A callable returning the loss of the current model. ...
tensorforce/core/optimizers/natural_gradient.py
def tf_step( self, time, variables, arguments, fn_loss, fn_kl_divergence, return_estimated_improvement=False, **kwargs ): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time t...
def tf_step( self, time, variables, arguments, fn_loss, fn_kl_divergence, return_estimated_improvement=False, **kwargs ): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time t...
[ "Creates", "the", "TensorFlow", "operations", "for", "performing", "an", "optimization", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/natural_gradient.py#L60-L167
[ "def", "tf_step", "(", "self", ",", "time", ",", "variables", ",", "arguments", ",", "fn_loss", ",", "fn_kl_divergence", ",", "return_estimated_improvement", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Optimize: argmin(w) loss(w + delta) such that kldiv(P(w) |...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MultiStep.tf_step
Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. arguments: Dict of arguments for callables, like fn_loss. fn_reference: A callable returning the reference values, in case of...
tensorforce/core/optimizers/multi_step.py
def tf_step(self, time, variables, arguments, fn_reference=None, **kwargs): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. arguments: Dict of arguments for callable...
def tf_step(self, time, variables, arguments, fn_reference=None, **kwargs): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. arguments: Dict of arguments for callable...
[ "Creates", "the", "TensorFlow", "operations", "for", "performing", "an", "optimization", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/multi_step.py#L48-L91
[ "def", "tf_step", "(", "self", ",", "time", ",", "variables", ",", "arguments", ",", "fn_reference", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Set reference to compare with at each optimization step, in case of a comparative loss.", "arguments", "[", "'referenc...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PGModel.tf_baseline_loss
Creates the TensorFlow operations for calculating the baseline loss of a batch. Args: states: Dict of state tensors. internals: List of prior internal state tensors. reward: Reward tensor. update: Boolean tensor indicating whether this call happens during an upda...
tensorforce/models/pg_model.py
def tf_baseline_loss(self, states, internals, reward, update, reference=None): """ Creates the TensorFlow operations for calculating the baseline loss of a batch. Args: states: Dict of state tensors. internals: List of prior internal state tensors. reward: Re...
def tf_baseline_loss(self, states, internals, reward, update, reference=None): """ Creates the TensorFlow operations for calculating the baseline loss of a batch. Args: states: Dict of state tensors. internals: List of prior internal state tensors. reward: Re...
[ "Creates", "the", "TensorFlow", "operations", "for", "calculating", "the", "baseline", "loss", "of", "a", "batch", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/pg_model.py#L216-L252
[ "def", "tf_baseline_loss", "(", "self", ",", "states", ",", "internals", ",", "reward", ",", "update", ",", "reference", "=", "None", ")", ":", "if", "self", ".", "baseline_mode", "==", "'states'", ":", "loss", "=", "self", ".", "baseline", ".", "loss", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PGModel.baseline_optimizer_arguments
Returns the baseline optimizer arguments including the time, the list of variables to optimize, and various functions which the optimizer might require to perform an update step. Args: states: Dict of state tensors. internals: List of prior internal state tensors. ...
tensorforce/models/pg_model.py
def baseline_optimizer_arguments(self, states, internals, reward): """ Returns the baseline optimizer arguments including the time, the list of variables to optimize, and various functions which the optimizer might require to perform an update step. Args: states:...
def baseline_optimizer_arguments(self, states, internals, reward): """ Returns the baseline optimizer arguments including the time, the list of variables to optimize, and various functions which the optimizer might require to perform an update step. Args: states:...
[ "Returns", "the", "baseline", "optimizer", "arguments", "including", "the", "time", "the", "list", "of", "variables", "to", "optimize", "and", "various", "functions", "which", "the", "optimizer", "might", "require", "to", "perform", "an", "update", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/pg_model.py#L254-L283
[ "def", "baseline_optimizer_arguments", "(", "self", ",", "states", ",", "internals", ",", "reward", ")", ":", "arguments", "=", "dict", "(", "time", "=", "self", ".", "global_timestep", ",", "variables", "=", "self", ".", "baseline", ".", "get_variables", "(...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Synchronization.tf_step
Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. source_variables: List of source variables to synchronize with. **kwargs: Additional arguments, not used. Returns: ...
tensorforce/core/optimizers/synchronization.py
def tf_step(self, time, variables, source_variables, **kwargs): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. source_variables: List of source variables to synchro...
def tf_step(self, time, variables, source_variables, **kwargs): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. source_variables: List of source variables to synchro...
[ "Creates", "the", "TensorFlow", "operations", "for", "performing", "an", "optimization", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/synchronization.py#L50-L94
[ "def", "tf_step", "(", "self", ",", "time", ",", "variables", ",", "source_variables", ",", "*", "*", "kwargs", ")", ":", "assert", "all", "(", "util", ".", "shape", "(", "source", ")", "==", "util", ".", "shape", "(", "target", ")", "for", "source",...
520a8d992230e382f08e315ede5fc477f5e26bfb