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
SRE_Match.group
Returns one or more subgroups of the match. Each argument is either a group index or a group name.
third_party/pypy/_sre.py
def group(self, *args): """Returns one or more subgroups of the match. Each argument is either a group index or a group name.""" if len(args) == 0: args = (0,) grouplist = [] for group in args: grouplist.append(self._get_slice(self._get_index(group), None)...
def group(self, *args): """Returns one or more subgroups of the match. Each argument is either a group index or a group name.""" if len(args) == 0: args = (0,) grouplist = [] for group in args: grouplist.append(self._get_slice(self._get_index(group), None)...
[ "Returns", "one", "or", "more", "subgroups", "of", "the", "match", ".", "Each", "argument", "is", "either", "a", "group", "index", "or", "a", "group", "name", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_sre.py#L317-L328
[ "def", "group", "(", "self", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "args", "=", "(", "0", ",", ")", "grouplist", "=", "[", "]", "for", "group", "in", "args", ":", "grouplist", ".", "append", "(", "self", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_State.fast_search
Skips forward in a string as fast as possible using information from an optimization info block.
third_party/pypy/_sre.py
def fast_search(self, pattern_codes): """Skips forward in a string as fast as possible using information from an optimization info block.""" # pattern starts with a known prefix # <5=length> <6=skip> <7=prefix data> <overlap data> flags = pattern_codes[2] prefix_len = pat...
def fast_search(self, pattern_codes): """Skips forward in a string as fast as possible using information from an optimization info block.""" # pattern starts with a known prefix # <5=length> <6=skip> <7=prefix data> <overlap data> flags = pattern_codes[2] prefix_len = pat...
[ "Skips", "forward", "in", "a", "string", "as", "fast", "as", "possible", "using", "information", "from", "an", "optimization", "info", "block", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_sre.py#L419-L453
[ "def", "fast_search", "(", "self", ",", "pattern_codes", ")", ":", "# pattern starts with a known prefix", "# <5=length> <6=skip> <7=prefix data> <overlap data>", "flags", "=", "pattern_codes", "[", "2", "]", "prefix_len", "=", "pattern_codes", "[", "5", "]", "prefix_skip...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_MatchContext.push_new_context
Creates a new child context of this context and pushes it on the stack. pattern_offset is the offset off the current code position to start interpreting from.
third_party/pypy/_sre.py
def push_new_context(self, pattern_offset): """Creates a new child context of this context and pushes it on the stack. pattern_offset is the offset off the current code position to start interpreting from.""" child_context = _MatchContext(self.state, self.pattern_codes[self.c...
def push_new_context(self, pattern_offset): """Creates a new child context of this context and pushes it on the stack. pattern_offset is the offset off the current code position to start interpreting from.""" child_context = _MatchContext(self.state, self.pattern_codes[self.c...
[ "Creates", "a", "new", "child", "context", "of", "this", "context", "and", "pushes", "it", "on", "the", "stack", ".", "pattern_offset", "is", "the", "offset", "off", "the", "current", "code", "position", "to", "start", "interpreting", "from", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_sre.py#L501-L508
[ "def", "push_new_context", "(", "self", ",", "pattern_offset", ")", ":", "child_context", "=", "_MatchContext", "(", "self", ".", "state", ",", "self", ".", "pattern_codes", "[", "self", ".", "code_position", "+", "pattern_offset", ":", "]", ")", "self", "."...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_OpcodeDispatcher.match
Returns True if the current context matches, False if it doesn't and None if matching is not finished, ie must be resumed after child contexts have been matched.
third_party/pypy/_sre.py
def match(self, context): """Returns True if the current context matches, False if it doesn't and None if matching is not finished, ie must be resumed after child contexts have been matched.""" while context.remaining_codes() > 0 and context.has_matched is None: opcode = cont...
def match(self, context): """Returns True if the current context matches, False if it doesn't and None if matching is not finished, ie must be resumed after child contexts have been matched.""" while context.remaining_codes() > 0 and context.has_matched is None: opcode = cont...
[ "Returns", "True", "if", "the", "current", "context", "matches", "False", "if", "it", "doesn", "t", "and", "None", "if", "matching", "is", "not", "finished", "ie", "must", "be", "resumed", "after", "child", "contexts", "have", "been", "matched", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_sre.py#L586-L596
[ "def", "match", "(", "self", ",", "context", ")", ":", "while", "context", ".", "remaining_codes", "(", ")", ">", "0", "and", "context", ".", "has_matched", "is", "None", ":", "opcode", "=", "context", ".", "peek_code", "(", ")", "if", "not", "self", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_OpcodeDispatcher.dispatch
Dispatches a context on a given opcode. Returns True if the context is done matching, False if it must be resumed when next encountered.
third_party/pypy/_sre.py
def dispatch(self, opcode, context): """Dispatches a context on a given opcode. Returns True if the context is done matching, False if it must be resumed when next encountered.""" if id(context) in self.executing_contexts: generator = self.executing_contexts[id(context)] ...
def dispatch(self, opcode, context): """Dispatches a context on a given opcode. Returns True if the context is done matching, False if it must be resumed when next encountered.""" if id(context) in self.executing_contexts: generator = self.executing_contexts[id(context)] ...
[ "Dispatches", "a", "context", "on", "a", "given", "opcode", ".", "Returns", "True", "if", "the", "context", "is", "done", "matching", "False", "if", "it", "must", "be", "resumed", "when", "next", "encountered", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_sre.py#L598-L613
[ "def", "dispatch", "(", "self", ",", "opcode", ",", "context", ")", ":", "if", "id", "(", "context", ")", "in", "self", ".", "executing_contexts", ":", "generator", "=", "self", ".", "executing_contexts", "[", "id", "(", "context", ")", "]", "del", "se...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_OpcodeDispatcher.check_charset
Checks whether a character matches set of arbitrary length. Assumes the code pointer is at the first member of the set.
third_party/pypy/_sre.py
def check_charset(self, ctx, char): """Checks whether a character matches set of arbitrary length. Assumes the code pointer is at the first member of the set.""" self.set_dispatcher.reset(char) save_position = ctx.code_position result = None while result is None: ...
def check_charset(self, ctx, char): """Checks whether a character matches set of arbitrary length. Assumes the code pointer is at the first member of the set.""" self.set_dispatcher.reset(char) save_position = ctx.code_position result = None while result is None: ...
[ "Checks", "whether", "a", "character", "matches", "set", "of", "arbitrary", "length", ".", "Assumes", "the", "code", "pointer", "is", "at", "the", "first", "member", "of", "the", "set", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_sre.py#L1068-L1077
[ "def", "check_charset", "(", "self", ",", "ctx", ",", "char", ")", ":", "self", ".", "set_dispatcher", ".", "reset", "(", "char", ")", "save_position", "=", "ctx", ".", "code_position", "result", "=", "None", "while", "result", "is", "None", ":", "result...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_OpcodeDispatcher.count_repetitions
Returns the number of repetitions of a single item, starting from the current string position. The code pointer is expected to point to a REPEAT_ONE operation (with the repeated 4 ahead).
third_party/pypy/_sre.py
def count_repetitions(self, ctx, maxcount): """Returns the number of repetitions of a single item, starting from the current string position. The code pointer is expected to point to a REPEAT_ONE operation (with the repeated 4 ahead).""" count = 0 real_maxcount = ctx.state.end - ...
def count_repetitions(self, ctx, maxcount): """Returns the number of repetitions of a single item, starting from the current string position. The code pointer is expected to point to a REPEAT_ONE operation (with the repeated 4 ahead).""" count = 0 real_maxcount = ctx.state.end - ...
[ "Returns", "the", "number", "of", "repetitions", "of", "a", "single", "item", "starting", "from", "the", "current", "string", "position", ".", "The", "code", "pointer", "is", "expected", "to", "point", "to", "a", "REPEAT_ONE", "operation", "(", "with", "the"...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pypy/_sre.py#L1079-L1105
[ "def", "count_repetitions", "(", "self", ",", "ctx", ",", "maxcount", ")", ":", "count", "=", "0", "real_maxcount", "=", "ctx", ".", "state", ".", "end", "-", "ctx", ".", "string_position", "if", "maxcount", "<", "real_maxcount", "and", "maxcount", "!=", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
extract
Return (sign, intpart, fraction, expo) or raise an exception: sign is '+' or '-' intpart is 0 or more digits beginning with a nonzero fraction is 0 or more digits expo is an integer
third_party/stdlib/fpformat.py
def extract(s): """Return (sign, intpart, fraction, expo) or raise an exception: sign is '+' or '-' intpart is 0 or more digits beginning with a nonzero fraction is 0 or more digits expo is an integer""" res = decoder.match(s) if res is None: raise NotANumber, s sign, intpart, fraction, ...
def extract(s): """Return (sign, intpart, fraction, expo) or raise an exception: sign is '+' or '-' intpart is 0 or more digits beginning with a nonzero fraction is 0 or more digits expo is an integer""" res = decoder.match(s) if res is None: raise NotANumber, s sign, intpart, fraction, ...
[ "Return", "(", "sign", "intpart", "fraction", "expo", ")", "or", "raise", "an", "exception", ":", "sign", "is", "+", "or", "-", "intpart", "is", "0", "or", "more", "digits", "beginning", "with", "a", "nonzero", "fraction", "is", "0", "or", "more", "dig...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/fpformat.py#L35-L48
[ "def", "extract", "(", "s", ")", ":", "res", "=", "decoder", ".", "match", "(", "s", ")", "if", "res", "is", "None", ":", "raise", "NotANumber", ",", "s", "sign", ",", "intpart", ",", "fraction", ",", "exppart", "=", "res", ".", "group", "(", "1"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
unexpo
Remove the exponent by changing intpart and fraction.
third_party/stdlib/fpformat.py
def unexpo(intpart, fraction, expo): """Remove the exponent by changing intpart and fraction.""" if expo > 0: # Move the point left f = len(fraction) intpart, fraction = intpart + fraction[:expo], fraction[expo:] if expo > f: intpart = intpart + '0'*(expo-f) elif expo < 0...
def unexpo(intpart, fraction, expo): """Remove the exponent by changing intpart and fraction.""" if expo > 0: # Move the point left f = len(fraction) intpart, fraction = intpart + fraction[:expo], fraction[expo:] if expo > f: intpart = intpart + '0'*(expo-f) elif expo < 0...
[ "Remove", "the", "exponent", "by", "changing", "intpart", "and", "fraction", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/fpformat.py#L50-L62
[ "def", "unexpo", "(", "intpart", ",", "fraction", ",", "expo", ")", ":", "if", "expo", ">", "0", ":", "# Move the point left", "f", "=", "len", "(", "fraction", ")", "intpart", ",", "fraction", "=", "intpart", "+", "fraction", "[", ":", "expo", "]", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
roundfrac
Round or extend the fraction to size digs.
third_party/stdlib/fpformat.py
def roundfrac(intpart, fraction, digs): """Round or extend the fraction to size digs.""" f = len(fraction) if f <= digs: return intpart, fraction + '0'*(digs-f) i = len(intpart) if i+digs < 0: return '0'*-digs, '' total = intpart + fraction nextdigit = total[i+digs] if ne...
def roundfrac(intpart, fraction, digs): """Round or extend the fraction to size digs.""" f = len(fraction) if f <= digs: return intpart, fraction + '0'*(digs-f) i = len(intpart) if i+digs < 0: return '0'*-digs, '' total = intpart + fraction nextdigit = total[i+digs] if ne...
[ "Round", "or", "extend", "the", "fraction", "to", "size", "digs", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/fpformat.py#L64-L88
[ "def", "roundfrac", "(", "intpart", ",", "fraction", ",", "digs", ")", ":", "f", "=", "len", "(", "fraction", ")", "if", "f", "<=", "digs", ":", "return", "intpart", ",", "fraction", "+", "'0'", "*", "(", "digs", "-", "f", ")", "i", "=", "len", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
fix
Format x as [-]ddd.ddd with 'digs' digits after the point and at least one digit before. If digs <= 0, the point is suppressed.
third_party/stdlib/fpformat.py
def fix(x, digs): """Format x as [-]ddd.ddd with 'digs' digits after the point and at least one digit before. If digs <= 0, the point is suppressed.""" if type(x) != type(''): x = repr(x) try: sign, intpart, fraction, expo = extract(x) except NotANumber: return x intpart, fra...
def fix(x, digs): """Format x as [-]ddd.ddd with 'digs' digits after the point and at least one digit before. If digs <= 0, the point is suppressed.""" if type(x) != type(''): x = repr(x) try: sign, intpart, fraction, expo = extract(x) except NotANumber: return x intpart, fra...
[ "Format", "x", "as", "[", "-", "]", "ddd", ".", "ddd", "with", "digs", "digits", "after", "the", "point", "and", "at", "least", "one", "digit", "before", ".", "If", "digs", "<", "=", "0", "the", "point", "is", "suppressed", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/fpformat.py#L90-L104
[ "def", "fix", "(", "x", ",", "digs", ")", ":", "if", "type", "(", "x", ")", "!=", "type", "(", "''", ")", ":", "x", "=", "repr", "(", "x", ")", "try", ":", "sign", ",", "intpart", ",", "fraction", ",", "expo", "=", "extract", "(", "x", ")",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
sci
Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point and exactly one digit before. If digs is <= 0, one digit is kept and the point is suppressed.
third_party/stdlib/fpformat.py
def sci(x, digs): """Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point and exactly one digit before. If digs is <= 0, one digit is kept and the point is suppressed.""" if type(x) != type(''): x = repr(x) sign, intpart, fraction, expo = extract(x) if not intpart: while fract...
def sci(x, digs): """Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point and exactly one digit before. If digs is <= 0, one digit is kept and the point is suppressed.""" if type(x) != type(''): x = repr(x) sign, intpart, fraction, expo = extract(x) if not intpart: while fract...
[ "Format", "x", "as", "[", "-", "]", "d", ".", "dddE", "[", "+", "-", "]", "ddd", "with", "digs", "digits", "after", "the", "point", "and", "exactly", "one", "digit", "before", ".", "If", "digs", "is", "<", "=", "0", "one", "digit", "is", "kept", ...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/fpformat.py#L106-L136
[ "def", "sci", "(", "x", ",", "digs", ")", ":", "if", "type", "(", "x", ")", "!=", "type", "(", "''", ")", ":", "x", "=", "repr", "(", "x", ")", "sign", ",", "intpart", ",", "fraction", ",", "expo", "=", "extract", "(", "x", ")", "if", "not"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
GrumpyRandom.getrandbits
getrandbits(k) -> x. Generates an int with k random bits.
lib/_random.py
def getrandbits(self, k): """getrandbits(k) -> x. Generates an int with k random bits.""" if k <= 0: raise ValueError('number of bits must be greater than zero') if k != int(k): raise TypeError('number of bits should be an integer') numbytes = (k + 7) // 8 # bits / 8 a...
def getrandbits(self, k): """getrandbits(k) -> x. Generates an int with k random bits.""" if k <= 0: raise ValueError('number of bits must be greater than zero') if k != int(k): raise TypeError('number of bits should be an integer') numbytes = (k + 7) // 8 # bits / 8 a...
[ "getrandbits", "(", "k", ")", "-", ">", "x", ".", "Generates", "an", "int", "with", "k", "random", "bits", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/lib/_random.py#L74-L82
[ "def", "getrandbits", "(", "self", ",", "k", ")", ":", "if", "k", "<=", "0", ":", "raise", "ValueError", "(", "'number of bits must be greater than zero'", ")", "if", "k", "!=", "int", "(", "k", ")", ":", "raise", "TypeError", "(", "'number of bits should be...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
GrumpyRandom._randbelow
Return a random int in the range [0,n).
lib/_random.py
def _randbelow(self, n): """Return a random int in the range [0,n).""" # TODO # change once int.bit_length is implemented. # k = n.bit_length() k = _int_bit_length(n) r = self.getrandbits(k) while r >= n: r = self.getrandbits(k) return r
def _randbelow(self, n): """Return a random int in the range [0,n).""" # TODO # change once int.bit_length is implemented. # k = n.bit_length() k = _int_bit_length(n) r = self.getrandbits(k) while r >= n: r = self.getrandbits(k) return r
[ "Return", "a", "random", "int", "in", "the", "range", "[", "0", "n", ")", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/lib/_random.py#L90-L99
[ "def", "_randbelow", "(", "self", ",", "n", ")", ":", "# TODO", "# change once int.bit_length is implemented.", "# k = n.bit_length()", "k", "=", "_int_bit_length", "(", "n", ")", "r", "=", "self", ".", "getrandbits", "(", "k", ")", "while", "r", ">=", "n", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
getopt
getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the string of option letters that the script wants to ...
third_party/stdlib/getopt.py
def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the ...
def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the ...
[ "getopt", "(", "args", "options", "[", "long_options", "]", ")", "-", ">", "opts", "args" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/getopt.py#L51-L92
[ "def", "getopt", "(", "args", ",", "shortopts", ",", "longopts", "=", "[", "]", ")", ":", "opts", "=", "[", "]", "if", "type", "(", "longopts", ")", "==", "type", "(", "\"\"", ")", ":", "longopts", "=", "[", "longopts", "]", "else", ":", "longopt...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
gnu_getopt
getopt(args, options[, long_options]) -> opts, args This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing options as soon as a non-option argument is encoun...
third_party/stdlib/getopt.py
def gnu_getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing...
def gnu_getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing...
[ "getopt", "(", "args", "options", "[", "long_options", "]", ")", "-", ">", "opts", "args" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/getopt.py#L94-L142
[ "def", "gnu_getopt", "(", "args", ",", "shortopts", ",", "longopts", "=", "[", "]", ")", ":", "opts", "=", "[", "]", "prog_args", "=", "[", "]", "if", "isinstance", "(", "longopts", ",", "str", ")", ":", "longopts", "=", "[", "longopts", "]", "else...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
filter
Return the subset of the list NAMES that match PAT
third_party/stdlib/fnmatch.py
def filter(names, pat): """Return the subset of the list NAMES that match PAT""" import os # import posixpath result=[] # pat=os.path.normcase(pat) try: re_pat = _cache[pat] except KeyError: res = translate(pat) if len(_cache) >= _MAXCACHE: # _cache.clear(...
def filter(names, pat): """Return the subset of the list NAMES that match PAT""" import os # import posixpath result=[] # pat=os.path.normcase(pat) try: re_pat = _cache[pat] except KeyError: res = translate(pat) if len(_cache) >= _MAXCACHE: # _cache.clear(...
[ "Return", "the", "subset", "of", "the", "list", "NAMES", "that", "match", "PAT" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/fnmatch.py#L46-L71
[ "def", "filter", "(", "names", ",", "pat", ")", ":", "import", "os", "# import posixpath", "result", "=", "[", "]", "# pat=os.path.normcase(pat)", "try", ":", "re_pat", "=", "_cache", "[", "pat", "]", "except", "KeyError", ":", "res", "=", "translate", "("...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
fnmatchcase
Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize its arguments.
third_party/stdlib/fnmatch.py
def fnmatchcase(name, pat): """Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize its arguments. """ try: re_pat = _cache[pat] except KeyError: res = translate(pat) if len(_cache) >= _MAXCACHE: ...
def fnmatchcase(name, pat): """Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize its arguments. """ try: re_pat = _cache[pat] except KeyError: res = translate(pat) if len(_cache) >= _MAXCACHE: ...
[ "Test", "whether", "FILENAME", "matches", "PATTERN", "including", "case", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/fnmatch.py#L73-L88
[ "def", "fnmatchcase", "(", "name", ",", "pat", ")", ":", "try", ":", "re_pat", "=", "_cache", "[", "pat", "]", "except", "KeyError", ":", "res", "=", "translate", "(", "pat", ")", "if", "len", "(", "_cache", ")", ">=", "_MAXCACHE", ":", "# _cache.cle...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
translate
Translate a shell PATTERN to a regular expression. There is no way to quote meta-characters.
third_party/stdlib/fnmatch.py
def translate(pat): """Translate a shell PATTERN to a regular expression. There is no way to quote meta-characters. """ i, n = 0, len(pat) res = '' while i < n: c = pat[i] i = i+1 if c == '*': res = res + '.*' elif c == '?': res = res + '...
def translate(pat): """Translate a shell PATTERN to a regular expression. There is no way to quote meta-characters. """ i, n = 0, len(pat) res = '' while i < n: c = pat[i] i = i+1 if c == '*': res = res + '.*' elif c == '?': res = res + '...
[ "Translate", "a", "shell", "PATTERN", "to", "a", "regular", "expression", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/fnmatch.py#L90-L125
[ "def", "translate", "(", "pat", ")", ":", "i", ",", "n", "=", "0", ",", "len", "(", "pat", ")", "res", "=", "''", "while", "i", "<", "n", ":", "c", "=", "pat", "[", "i", "]", "i", "=", "i", "+", "1", "if", "c", "==", "'*'", ":", "res", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Queue.task_done
Indicate that a formerly enqueued task is complete. Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items ...
third_party/stdlib/Queue.py
def task_done(self): """Indicate that a formerly enqueued task is complete. Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it ...
def task_done(self): """Indicate that a formerly enqueued task is complete. Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it ...
[ "Indicate", "that", "a", "formerly", "enqueued", "task", "is", "complete", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/Queue.py#L45-L68
[ "def", "task_done", "(", "self", ")", ":", "self", ".", "all_tasks_done", ".", "acquire", "(", ")", "try", ":", "unfinished", "=", "self", ".", "unfinished_tasks", "-", "1", "if", "unfinished", "<=", "0", ":", "if", "unfinished", "<", "0", ":", "raise"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Queue.qsize
Return the approximate size of the queue (not reliable!).
third_party/stdlib/Queue.py
def qsize(self): """Return the approximate size of the queue (not reliable!).""" self.mutex.acquire() n = self._qsize() self.mutex.release() return n
def qsize(self): """Return the approximate size of the queue (not reliable!).""" self.mutex.acquire() n = self._qsize() self.mutex.release() return n
[ "Return", "the", "approximate", "size", "of", "the", "queue", "(", "not", "reliable!", ")", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/Queue.py#L86-L91
[ "def", "qsize", "(", "self", ")", ":", "self", ".", "mutex", ".", "acquire", "(", ")", "n", "=", "self", ".", "_qsize", "(", ")", "self", ".", "mutex", ".", "release", "(", ")", "return", "n" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Queue.empty
Return True if the queue is empty, False otherwise (not reliable!).
third_party/stdlib/Queue.py
def empty(self): """Return True if the queue is empty, False otherwise (not reliable!).""" self.mutex.acquire() n = not self._qsize() self.mutex.release() return n
def empty(self): """Return True if the queue is empty, False otherwise (not reliable!).""" self.mutex.acquire() n = not self._qsize() self.mutex.release() return n
[ "Return", "True", "if", "the", "queue", "is", "empty", "False", "otherwise", "(", "not", "reliable!", ")", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/Queue.py#L93-L98
[ "def", "empty", "(", "self", ")", ":", "self", ".", "mutex", ".", "acquire", "(", ")", "n", "=", "not", "self", ".", "_qsize", "(", ")", "self", ".", "mutex", ".", "release", "(", ")", "return", "n" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Queue.full
Return True if the queue is full, False otherwise (not reliable!).
third_party/stdlib/Queue.py
def full(self): """Return True if the queue is full, False otherwise (not reliable!).""" self.mutex.acquire() n = 0 < self.maxsize == self._qsize() self.mutex.release() return n
def full(self): """Return True if the queue is full, False otherwise (not reliable!).""" self.mutex.acquire() n = 0 < self.maxsize == self._qsize() self.mutex.release() return n
[ "Return", "True", "if", "the", "queue", "is", "full", "False", "otherwise", "(", "not", "reliable!", ")", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/Queue.py#L100-L105
[ "def", "full", "(", "self", ")", ":", "self", ".", "mutex", ".", "acquire", "(", ")", "n", "=", "0", "<", "self", ".", "maxsize", "==", "self", ".", "_qsize", "(", ")", "self", ".", "mutex", ".", "release", "(", ")", "return", "n" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Queue.put
Put an item into the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until a free slot is available. If 'timeout' is a non-negative number, it blocks at most 'timeout' seconds and raises the Full exception if no free slot was available wit...
third_party/stdlib/Queue.py
def put(self, item, block=True, timeout=None): """Put an item into the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until a free slot is available. If 'timeout' is a non-negative number, it blocks at most 'timeout' seconds and raises ...
def put(self, item, block=True, timeout=None): """Put an item into the queue. If optional args 'block' is true and 'timeout' is None (the default), block if necessary until a free slot is available. If 'timeout' is a non-negative number, it blocks at most 'timeout' seconds and raises ...
[ "Put", "an", "item", "into", "the", "queue", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/Queue.py#L107-L140
[ "def", "put", "(", "self", ",", "item", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "self", ".", "not_full", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "maxsize", ">", "0", ":", "if", "not", "block", ":", "if...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
calculate_transitive_deps
Determines all modules that script transitively depends upon.
compiler/imputil.py
def calculate_transitive_deps(modname, script, gopath): """Determines all modules that script transitively depends upon.""" deps = set() def calc(modname, script): if modname in deps: return deps.add(modname) for imp in collect_imports(modname, script, gopath): if imp.is_native: de...
def calculate_transitive_deps(modname, script, gopath): """Determines all modules that script transitively depends upon.""" deps = set() def calc(modname, script): if modname in deps: return deps.add(modname) for imp in collect_imports(modname, script, gopath): if imp.is_native: de...
[ "Determines", "all", "modules", "that", "script", "transitively", "depends", "upon", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/compiler/imputil.py#L207-L233
[ "def", "calculate_transitive_deps", "(", "modname", ",", "script", ",", "gopath", ")", ":", "deps", "=", "set", "(", ")", "def", "calc", "(", "modname", ",", "script", ")", ":", "if", "modname", "in", "deps", ":", "return", "deps", ".", "add", "(", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_make_future_features
Processes a future import statement, returning set of flags it defines.
compiler/imputil.py
def _make_future_features(node): """Processes a future import statement, returning set of flags it defines.""" assert isinstance(node, ast.ImportFrom) assert node.module == '__future__' features = FutureFeatures() for alias in node.names: name = alias.name if name in _FUTURE_FEATURES: if name no...
def _make_future_features(node): """Processes a future import statement, returning set of flags it defines.""" assert isinstance(node, ast.ImportFrom) assert node.module == '__future__' features = FutureFeatures() for alias in node.names: name = alias.name if name in _FUTURE_FEATURES: if name no...
[ "Processes", "a", "future", "import", "statement", "returning", "set", "of", "flags", "it", "defines", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/compiler/imputil.py#L276-L293
[ "def", "_make_future_features", "(", "node", ")", ":", "assert", "isinstance", "(", "node", ",", "ast", ".", "ImportFrom", ")", "assert", "node", ".", "module", "==", "'__future__'", "features", "=", "FutureFeatures", "(", ")", "for", "alias", "in", "node", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
parse_future_features
Accumulates a set of flags for the compiler __future__ imports.
compiler/imputil.py
def parse_future_features(mod): """Accumulates a set of flags for the compiler __future__ imports.""" assert isinstance(mod, ast.Module) found_docstring = False for node in mod.body: if isinstance(node, ast.ImportFrom): if node.module == '__future__': return node, _make_future_features(node) ...
def parse_future_features(mod): """Accumulates a set of flags for the compiler __future__ imports.""" assert isinstance(mod, ast.Module) found_docstring = False for node in mod.body: if isinstance(node, ast.ImportFrom): if node.module == '__future__': return node, _make_future_features(node) ...
[ "Accumulates", "a", "set", "of", "flags", "for", "the", "compiler", "__future__", "imports", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/compiler/imputil.py#L296-L311
[ "def", "parse_future_features", "(", "mod", ")", ":", "assert", "isinstance", "(", "mod", ",", "ast", ".", "Module", ")", "found_docstring", "=", "False", "for", "node", "in", "mod", ".", "body", ":", "if", "isinstance", "(", "node", ",", "ast", ".", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
contextmanager
@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<arguments>) as <variable>: <b...
third_party/stdlib/contextlib.py
def contextmanager(func): """@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<argument...
def contextmanager(func): """@contextmanager decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<argument...
[ "@contextmanager", "decorator", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/contextlib.py#L60-L91
[ "def", "contextmanager", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "helper", "(", "*", "args", ",", "*", "*", "kwds", ")", ":", "return", "GeneratorContextManager", "(", "func", "(", "*", "args", ",", "*", "*", "kwds", ")", ")",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
nested
Combine multiple context managers into a single nested context manager. This function has been deprecated in favour of the multiple manager form of the with statement. The one advantage of this function over the multiple manager form of the with statement is that argument unpacking allows it to be used...
third_party/stdlib/contextlib.py
def nested(*managers): """Combine multiple context managers into a single nested context manager. This function has been deprecated in favour of the multiple manager form of the with statement. The one advantage of this function over the multiple manager form of the with statement is that argument unp...
def nested(*managers): """Combine multiple context managers into a single nested context manager. This function has been deprecated in favour of the multiple manager form of the with statement. The one advantage of this function over the multiple manager form of the with statement is that argument unp...
[ "Combine", "multiple", "context", "managers", "into", "a", "single", "nested", "context", "manager", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/contextlib.py#L95-L135
[ "def", "nested", "(", "*", "managers", ")", ":", "warn", "(", "\"With-statements now directly support multiple context managers\"", ",", "DeprecationWarning", ",", "3", ")", "exits", "=", "[", "]", "vars", "=", "[", "]", "exc", "=", "(", "None", ",", "None", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
JSONDecoder.decode
Return the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document)
third_party/stdlib/json/decoder.py
def decode(self, s, _w=WHITESPACE.match): """Return the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) """ obj, end = self.raw_decode(s, idx=_w(s, 0).end()) end = _w(s, end).end() if end != len(s): raise ValueErr...
def decode(self, s, _w=WHITESPACE.match): """Return the Python representation of ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) """ obj, end = self.raw_decode(s, idx=_w(s, 0).end()) end = _w(s, end).end() if end != len(s): raise ValueErr...
[ "Return", "the", "Python", "representation", "of", "s", "(", "a", "str", "or", "unicode", "instance", "containing", "a", "JSON", "document", ")" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/json/decoder.py#L362-L371
[ "def", "decode", "(", "self", ",", "s", ",", "_w", "=", "WHITESPACE", ".", "match", ")", ":", "obj", ",", "end", "=", "self", ".", "raw_decode", "(", "s", ",", "idx", "=", "_w", "(", "s", ",", "0", ")", ".", "end", "(", ")", ")", "end", "="...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Baseline.tf_loss
Creates the TensorFlow operations for calculating the L2 loss between predicted state values and actual rewards. Args: states: Dict of state tensors. internals: List of prior internal state tensors. reward: Reward tensor. update: Boolean tensor indicating...
tensorforce/core/baselines/baseline.py
def tf_loss(self, states, internals, reward, update, reference=None): """ Creates the TensorFlow operations for calculating the L2 loss between predicted state values and actual rewards. Args: states: Dict of state tensors. internals: List of prior internal state...
def tf_loss(self, states, internals, reward, update, reference=None): """ Creates the TensorFlow operations for calculating the L2 loss between predicted state values and actual rewards. Args: states: Dict of state tensors. internals: List of prior internal state...
[ "Creates", "the", "TensorFlow", "operations", "for", "calculating", "the", "L2", "loss", "between", "predicted", "state", "values", "and", "actual", "rewards", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/baselines/baseline.py#L107-L123
[ "def", "tf_loss", "(", "self", ",", "states", ",", "internals", ",", "reward", ",", "update", ",", "reference", "=", "None", ")", ":", "prediction", "=", "self", ".", "predict", "(", "states", "=", "states", ",", "internals", "=", "internals", ",", "up...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Baseline.get_variables
Returns the TensorFlow variables used by the baseline. Returns: List of variables
tensorforce/core/baselines/baseline.py
def get_variables(self, include_nontrainable=False): """ Returns the TensorFlow variables used by the baseline. Returns: List of variables """ if include_nontrainable: return [self.all_variables[key] for key in sorted(self.all_variables)] else: ...
def get_variables(self, include_nontrainable=False): """ Returns the TensorFlow variables used by the baseline. Returns: List of variables """ if include_nontrainable: return [self.all_variables[key] for key in sorted(self.all_variables)] else: ...
[ "Returns", "the", "TensorFlow", "variables", "used", "by", "the", "baseline", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/baselines/baseline.py#L134-L144
[ "def", "get_variables", "(", "self", ",", "include_nontrainable", "=", "False", ")", ":", "if", "include_nontrainable", ":", "return", "[", "self", ".", "all_variables", "[", "key", "]", "for", "key", "in", "sorted", "(", "self", ".", "all_variables", ")", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Baseline.from_spec
Creates a baseline from a specification dict.
tensorforce/core/baselines/baseline.py
def from_spec(spec, kwargs=None): """ Creates a baseline from a specification dict. """ baseline = util.get_object( obj=spec, predefined_objects=tensorforce.core.baselines.baselines, kwargs=kwargs ) assert isinstance(baseline, Baseline)...
def from_spec(spec, kwargs=None): """ Creates a baseline from a specification dict. """ baseline = util.get_object( obj=spec, predefined_objects=tensorforce.core.baselines.baselines, kwargs=kwargs ) assert isinstance(baseline, Baseline)...
[ "Creates", "a", "baseline", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/baselines/baseline.py#L147-L157
[ "def", "from_spec", "(", "spec", ",", "kwargs", "=", "None", ")", ":", "baseline", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "core", ".", "baselines", ".", "baselines", ",", "kwargs", "="...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
UE4Environment.reset
same as step (no kwargs to pass), but needs to block and return observation_dict - stores the received observation in self.last_observation
tensorforce/contrib/unreal_engine.py
def reset(self): """ same as step (no kwargs to pass), but needs to block and return observation_dict - stores the received observation in self.last_observation """ # Send command. self.protocol.send({"cmd": "reset"}, self.socket) # Wait for response. resp...
def reset(self): """ same as step (no kwargs to pass), but needs to block and return observation_dict - stores the received observation in self.last_observation """ # Send command. self.protocol.send({"cmd": "reset"}, self.socket) # Wait for response. resp...
[ "same", "as", "step", "(", "no", "kwargs", "to", "pass", ")", "but", "needs", "to", "block", "and", "return", "observation_dict", "-", "stores", "the", "received", "observation", "in", "self", ".", "last_observation" ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/unreal_engine.py#L118-L128
[ "def", "reset", "(", "self", ")", ":", "# Send command.", "self", ".", "protocol", ".", "send", "(", "{", "\"cmd\"", ":", "\"reset\"", "}", ",", "self", ".", "socket", ")", "# Wait for response.", "response", "=", "self", ".", "protocol", ".", "recv", "(...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
UE4Environment.execute
Executes a single step in the UE4 game. This step may be comprised of one or more actual game ticks for all of which the same given action- and axis-inputs (or action number in case of discretized actions) are repeated. UE4 distinguishes between action-mappings, which are boolean actions (e.g. j...
tensorforce/contrib/unreal_engine.py
def execute(self, action): """ Executes a single step in the UE4 game. This step may be comprised of one or more actual game ticks for all of which the same given action- and axis-inputs (or action number in case of discretized actions) are repeated. UE4 distinguishes between act...
def execute(self, action): """ Executes a single step in the UE4 game. This step may be comprised of one or more actual game ticks for all of which the same given action- and axis-inputs (or action number in case of discretized actions) are repeated. UE4 distinguishes between act...
[ "Executes", "a", "single", "step", "in", "the", "UE4", "game", ".", "This", "step", "may", "be", "comprised", "of", "one", "or", "more", "actual", "game", "ticks", "for", "all", "of", "which", "the", "same", "given", "action", "-", "and", "axis", "-", ...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/unreal_engine.py#L155-L209
[ "def", "execute", "(", "self", ",", "action", ")", ":", "action_mappings", ",", "axis_mappings", "=", "[", "]", ",", "[", "]", "# TODO: what if more than one actions are passed?", "# Discretized -> each action is an int", "if", "self", ".", "discretize_actions", ":", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
UE4Environment.translate_abstract_actions_to_keys
Translates a list of tuples ([pretty mapping], [value]) to a list of tuples ([some key], [translated value]) each single item in abstract will undergo the following translation: Example1: we want: "MoveRight": 5.0 possible keys for the action are: ("Right", 1.0), ("Left", -1.0) ...
tensorforce/contrib/unreal_engine.py
def translate_abstract_actions_to_keys(self, abstract): """ Translates a list of tuples ([pretty mapping], [value]) to a list of tuples ([some key], [translated value]) each single item in abstract will undergo the following translation: Example1: we want: "MoveRight": 5.0 ...
def translate_abstract_actions_to_keys(self, abstract): """ Translates a list of tuples ([pretty mapping], [value]) to a list of tuples ([some key], [translated value]) each single item in abstract will undergo the following translation: Example1: we want: "MoveRight": 5.0 ...
[ "Translates", "a", "list", "of", "tuples", "(", "[", "pretty", "mapping", "]", "[", "value", "]", ")", "to", "a", "list", "of", "tuples", "(", "[", "some", "key", "]", "[", "translated", "value", "]", ")", "each", "single", "item", "in", "abstract", ...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/unreal_engine.py#L276-L311
[ "def", "translate_abstract_actions_to_keys", "(", "self", ",", "abstract", ")", ":", "# Solve single tuple with name and value -> should become a list (len=1) of this tuple.", "if", "len", "(", "abstract", ")", ">=", "2", "and", "not", "isinstance", "(", "abstract", "[", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
UE4Environment.discretize_action_space_desc
Creates a list of discrete action(-combinations) in case we want to learn with a discrete set of actions, but only have action-combinations (maybe even continuous) available from the env. E.g. the UE4 game has the following action/axis-mappings: ```javascript { 'Fire': ...
tensorforce/contrib/unreal_engine.py
def discretize_action_space_desc(self): """ Creates a list of discrete action(-combinations) in case we want to learn with a discrete set of actions, but only have action-combinations (maybe even continuous) available from the env. E.g. the UE4 game has the following action/axis-mappings...
def discretize_action_space_desc(self): """ Creates a list of discrete action(-combinations) in case we want to learn with a discrete set of actions, but only have action-combinations (maybe even continuous) available from the env. E.g. the UE4 game has the following action/axis-mappings...
[ "Creates", "a", "list", "of", "discrete", "action", "(", "-", "combinations", ")", "in", "case", "we", "want", "to", "learn", "with", "a", "discrete", "set", "of", "actions", "but", "only", "have", "action", "-", "combinations", "(", "maybe", "even", "co...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/unreal_engine.py#L313-L376
[ "def", "discretize_action_space_desc", "(", "self", ")", ":", "# Put all unique_keys lists in one list and itertools.product that list.", "unique_list", "=", "[", "]", "for", "nice", ",", "record", "in", "self", ".", "action_space_desc", ".", "items", "(", ")", ":", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
DeepMindLab.reset
Resets the environment to its initialization state. This method needs to be called to start a new episode after the last episode ended. :return: initial state
tensorforce/contrib/deepmind_lab.py
def reset(self): """ Resets the environment to its initialization state. This method needs to be called to start a new episode after the last episode ended. :return: initial state """ self.level.reset() # optional: episode=-1, seed=None return self.level.observa...
def reset(self): """ Resets the environment to its initialization state. This method needs to be called to start a new episode after the last episode ended. :return: initial state """ self.level.reset() # optional: episode=-1, seed=None return self.level.observa...
[ "Resets", "the", "environment", "to", "its", "initialization", "state", ".", "This", "method", "needs", "to", "be", "called", "to", "start", "a", "new", "episode", "after", "the", "last", "episode", "ended", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/deepmind_lab.py#L102-L110
[ "def", "reset", "(", "self", ")", ":", "self", ".", "level", ".", "reset", "(", ")", "# optional: episode=-1, seed=None", "return", "self", ".", "level", ".", "observations", "(", ")", "[", "self", ".", "state_attribute", "]" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
DeepMindLab.execute
Pass action to universe environment, return reward, next step, terminal state and additional info. :param action: action to execute as numpy array, should have dtype np.intc and should adhere to the specification given in DeepMindLabEnvironment.action_spec(level_id) :return: dict co...
tensorforce/contrib/deepmind_lab.py
def execute(self, action): """ Pass action to universe environment, return reward, next step, terminal state and additional info. :param action: action to execute as numpy array, should have dtype np.intc and should adhere to the specification given in DeepMindLabEnvironment...
def execute(self, action): """ Pass action to universe environment, return reward, next step, terminal state and additional info. :param action: action to execute as numpy array, should have dtype np.intc and should adhere to the specification given in DeepMindLabEnvironment...
[ "Pass", "action", "to", "universe", "environment", "return", "reward", "next", "step", "terminal", "state", "and", "additional", "info", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/deepmind_lab.py#L112-L133
[ "def", "execute", "(", "self", ",", "action", ")", ":", "adjusted_action", "=", "list", "(", ")", "for", "action_spec", "in", "self", ".", "level", ".", "action_spec", "(", ")", ":", "if", "action_spec", "[", "'min'", "]", "==", "-", "1", "and", "act...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
ConjugateGradient.tf_solve
Iteratively solves the system of linear equations $A x = b$. Args: fn_x: A callable returning the left-hand side $A x$ of the system of linear equations. x_init: Initial solution guess $x_0$, zero vector if None. b: The right-hand side $b$ of the system of linear equations. ...
tensorforce/core/optimizers/solvers/conjugate_gradient.py
def tf_solve(self, fn_x, x_init, b): """ Iteratively solves the system of linear equations $A x = b$. Args: fn_x: A callable returning the left-hand side $A x$ of the system of linear equations. x_init: Initial solution guess $x_0$, zero vector if None. b: Th...
def tf_solve(self, fn_x, x_init, b): """ Iteratively solves the system of linear equations $A x = b$. Args: fn_x: A callable returning the left-hand side $A x$ of the system of linear equations. x_init: Initial solution guess $x_0$, zero vector if None. b: Th...
[ "Iteratively", "solves", "the", "system", "of", "linear", "equations", "$A", "x", "=", "b$", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/conjugate_gradient.py#L68-L80
[ "def", "tf_solve", "(", "self", ",", "fn_x", ",", "x_init", ",", "b", ")", ":", "return", "super", "(", "ConjugateGradient", ",", "self", ")", ".", "tf_solve", "(", "fn_x", ",", "x_init", ",", "b", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
ConjugateGradient.tf_initialize
Initialization step preparing the arguments for the first iteration of the loop body: $x_0, 0, p_0, r_0, r_0^2$. Args: x_init: Initial solution guess $x_0$, zero vector if None. b: The right-hand side $b$ of the system of linear equations. Returns: Initial...
tensorforce/core/optimizers/solvers/conjugate_gradient.py
def tf_initialize(self, x_init, b): """ Initialization step preparing the arguments for the first iteration of the loop body: $x_0, 0, p_0, r_0, r_0^2$. Args: x_init: Initial solution guess $x_0$, zero vector if None. b: The right-hand side $b$ of the system of...
def tf_initialize(self, x_init, b): """ Initialization step preparing the arguments for the first iteration of the loop body: $x_0, 0, p_0, r_0, r_0^2$. Args: x_init: Initial solution guess $x_0$, zero vector if None. b: The right-hand side $b$ of the system of...
[ "Initialization", "step", "preparing", "the", "arguments", "for", "the", "first", "iteration", "of", "the", "loop", "body", ":", "$x_0", "0", "p_0", "r_0", "r_0^2$", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/conjugate_gradient.py#L82-L107
[ "def", "tf_initialize", "(", "self", ",", "x_init", ",", "b", ")", ":", "if", "x_init", "is", "None", ":", "# Initial guess is zero vector if not given.", "x_init", "=", "[", "tf", ".", "zeros", "(", "shape", "=", "util", ".", "shape", "(", "t", ")", ")"...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
ConjugateGradient.tf_step
Iteration loop body of the conjugate gradient algorithm. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. conjugate: Current conjugate $c_t$. residual: Current residual $r_t$. squared_residual: Current squared residu...
tensorforce/core/optimizers/solvers/conjugate_gradient.py
def tf_step(self, x, iteration, conjugate, residual, squared_residual): """ Iteration loop body of the conjugate gradient algorithm. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. conjugate: Current conjugate $c_t$. ...
def tf_step(self, x, iteration, conjugate, residual, squared_residual): """ Iteration loop body of the conjugate gradient algorithm. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. conjugate: Current conjugate $c_t$. ...
[ "Iteration", "loop", "body", "of", "the", "conjugate", "gradient", "algorithm", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/conjugate_gradient.py#L109-L157
[ "def", "tf_step", "(", "self", ",", "x", ",", "iteration", ",", "conjugate", ",", "residual", ",", "squared_residual", ")", ":", "x", ",", "next_iteration", ",", "conjugate", ",", "residual", ",", "squared_residual", "=", "super", "(", "ConjugateGradient", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
ConjugateGradient.tf_next_step
Termination condition: max number of iterations, or residual sufficiently small. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. conjugate: Current conjugate $c_t$. residual: Current residual $r_t$. squared_residual...
tensorforce/core/optimizers/solvers/conjugate_gradient.py
def tf_next_step(self, x, iteration, conjugate, residual, squared_residual): """ Termination condition: max number of iterations, or residual sufficiently small. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. conjugate: Cu...
def tf_next_step(self, x, iteration, conjugate, residual, squared_residual): """ Termination condition: max number of iterations, or residual sufficiently small. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. conjugate: Cu...
[ "Termination", "condition", ":", "max", "number", "of", "iterations", "or", "residual", "sufficiently", "small", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/conjugate_gradient.py#L159-L174
[ "def", "tf_next_step", "(", "self", ",", "x", ",", "iteration", ",", "conjugate", ",", "residual", ",", "squared_residual", ")", ":", "next_step", "=", "super", "(", "ConjugateGradient", ",", "self", ")", ".", "tf_next_step", "(", "x", ",", "iteration", ",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
ClippedStep.tf_step
Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. **kwargs: Additional arguments passed on to the internal optimizer. Returns: List of delta tensors corresponding to ...
tensorforce/core/optimizers/clipped_step.py
def tf_step(self, time, variables, **kwargs): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. **kwargs: Additional arguments passed on to the internal optimizer. ...
def tf_step(self, time, variables, **kwargs): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables to optimize. **kwargs: Additional arguments passed on to the internal optimizer. ...
[ "Creates", "the", "TensorFlow", "operations", "for", "performing", "an", "optimization", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/clipped_step.py#L44-L73
[ "def", "tf_step", "(", "self", ",", "time", ",", "variables", ",", "*", "*", "kwargs", ")", ":", "deltas", "=", "self", ".", "optimizer", ".", "step", "(", "time", "=", "time", ",", "variables", "=", "variables", ",", "*", "*", "kwargs", ")", "with...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Layer.from_spec
Creates a layer from a specification dict.
tensorforce/core/networks/layer.py
def from_spec(spec, kwargs=None): """ Creates a layer from a specification dict. """ layer = util.get_object( obj=spec, predefined_objects=tensorforce.core.networks.layers, kwargs=kwargs ) assert isinstance(layer, Layer) return ...
def from_spec(spec, kwargs=None): """ Creates a layer from a specification dict. """ layer = util.get_object( obj=spec, predefined_objects=tensorforce.core.networks.layers, kwargs=kwargs ) assert isinstance(layer, Layer) return ...
[ "Creates", "a", "layer", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/networks/layer.py#L121-L131
[ "def", "from_spec", "(", "spec", ",", "kwargs", "=", "None", ")", ":", "layer", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "core", ".", "networks", ".", "layers", ",", "kwargs", "=", "kw...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
QModel.tf_q_delta
Creates the deltas (or advantage) of the Q values. :return: A list of deltas per action
tensorforce/models/q_model.py
def tf_q_delta(self, q_value, next_q_value, terminal, reward): """ Creates the deltas (or advantage) of the Q values. :return: A list of deltas per action """ for _ in range(util.rank(q_value) - 1): terminal = tf.expand_dims(input=terminal, axis=1) reward...
def tf_q_delta(self, q_value, next_q_value, terminal, reward): """ Creates the deltas (or advantage) of the Q values. :return: A list of deltas per action """ for _ in range(util.rank(q_value) - 1): terminal = tf.expand_dims(input=terminal, axis=1) reward...
[ "Creates", "the", "deltas", "(", "or", "advantage", ")", "of", "the", "Q", "values", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/q_model.py#L137-L154
[ "def", "tf_q_delta", "(", "self", ",", "q_value", ",", "next_q_value", ",", "terminal", ",", "reward", ")", ":", "for", "_", "in", "range", "(", "util", ".", "rank", "(", "q_value", ")", "-", "1", ")", ":", "terminal", "=", "tf", ".", "expand_dims", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
QModel.target_optimizer_arguments
Returns the target optimizer arguments including the time, the list of variables to optimize, and various functions which the optimizer might require to perform an update step. Returns: Target optimizer arguments as dict.
tensorforce/models/q_model.py
def target_optimizer_arguments(self): """ Returns the target optimizer arguments including the time, the list of variables to optimize, and various functions which the optimizer might require to perform an update step. Returns: Target optimizer arguments as dict....
def target_optimizer_arguments(self): """ Returns the target optimizer arguments including the time, the list of variables to optimize, and various functions which the optimizer might require to perform an update step. Returns: Target optimizer arguments as dict....
[ "Returns", "the", "target", "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/q_model.py#L215-L242
[ "def", "target_optimizer_arguments", "(", "self", ")", ":", "variables", "=", "self", ".", "target_network", ".", "get_variables", "(", ")", "+", "[", "variable", "for", "name", "in", "sorted", "(", "self", ".", "target_distributions", ")", "for", "variable", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Environment.from_spec
Creates an environment from a specification dict.
tensorforce/environments/environment.py
def from_spec(spec, kwargs): """ Creates an environment from a specification dict. """ env = tensorforce.util.get_object( obj=spec, predefined_objects=tensorforce.environments.environments, kwargs=kwargs ) assert isinstance(env, Environ...
def from_spec(spec, kwargs): """ Creates an environment from a specification dict. """ env = tensorforce.util.get_object( obj=spec, predefined_objects=tensorforce.environments.environments, kwargs=kwargs ) assert isinstance(env, Environ...
[ "Creates", "an", "environment", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/environments/environment.py#L102-L112
[ "def", "from_spec", "(", "spec", ",", "kwargs", ")", ":", "env", "=", "tensorforce", ".", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "environments", ".", "environments", ",", "kwargs", "=", "kwar...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
setup
When used for spinx extension.
docs/m2r.py
def setup(app): """When used for spinx extension.""" global _is_sphinx _is_sphinx = True app.add_config_value('no_underscore_emphasis', False, 'env') app.add_source_parser('.md', M2RParser) app.add_directive('mdinclude', MdInclude)
def setup(app): """When used for spinx extension.""" global _is_sphinx _is_sphinx = True app.add_config_value('no_underscore_emphasis', False, 'env') app.add_source_parser('.md', M2RParser) app.add_directive('mdinclude', MdInclude)
[ "When", "used", "for", "spinx", "extension", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L539-L545
[ "def", "setup", "(", "app", ")", ":", "global", "_is_sphinx", "_is_sphinx", "=", "True", "app", ".", "add_config_value", "(", "'no_underscore_emphasis'", ",", "False", ",", "'env'", ")", "app", ".", "add_source_parser", "(", "'.md'", ",", "M2RParser", ")", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestInlineLexer.output_image_link
Pass through rest role.
docs/m2r.py
def output_image_link(self, m): """Pass through rest role.""" return self.renderer.image_link( m.group('url'), m.group('target'), m.group('alt'))
def output_image_link(self, m): """Pass through rest role.""" return self.renderer.image_link( m.group('url'), m.group('target'), m.group('alt'))
[ "Pass", "through", "rest", "role", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L146-L149
[ "def", "output_image_link", "(", "self", ",", "m", ")", ":", "return", "self", ".", "renderer", ".", "image_link", "(", "m", ".", "group", "(", "'url'", ")", ",", "m", ".", "group", "(", "'target'", ")", ",", "m", ".", "group", "(", "'alt'", ")", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestInlineLexer.output_eol_literal_marker
Pass through rest link.
docs/m2r.py
def output_eol_literal_marker(self, m): """Pass through rest link.""" marker = ':' if m.group(1) is None else '' return self.renderer.eol_literal_marker(marker)
def output_eol_literal_marker(self, m): """Pass through rest link.""" marker = ':' if m.group(1) is None else '' return self.renderer.eol_literal_marker(marker)
[ "Pass", "through", "rest", "link", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L163-L166
[ "def", "output_eol_literal_marker", "(", "self", ",", "m", ")", ":", "marker", "=", "':'", "if", "m", ".", "group", "(", "1", ")", "is", "None", "else", "''", "return", "self", ".", "renderer", ".", "eol_literal_marker", "(", "marker", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestRenderer.header
Rendering header/heading tags like ``<h1>`` ``<h2>``. :param text: rendered text content for the header. :param level: a number for the header level, for example: 1. :param raw: raw text content of the header.
docs/m2r.py
def header(self, text, level, raw=None): """Rendering header/heading tags like ``<h1>`` ``<h2>``. :param text: rendered text content for the header. :param level: a number for the header level, for example: 1. :param raw: raw text content of the header. """ return '\n{0}...
def header(self, text, level, raw=None): """Rendering header/heading tags like ``<h1>`` ``<h2>``. :param text: rendered text content for the header. :param level: a number for the header level, for example: 1. :param raw: raw text content of the header. """ return '\n{0}...
[ "Rendering", "header", "/", "heading", "tags", "like", "<h1", ">", "<h2", ">", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L213-L220
[ "def", "header", "(", "self", ",", "text", ",", "level", ",", "raw", "=", "None", ")", ":", "return", "'\\n{0}\\n{1}\\n'", ".", "format", "(", "text", ",", "self", ".", "hmarks", "[", "level", "]", "*", "len", "(", "text", ")", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestRenderer.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/m2r.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. """ mark = '#. ' if ordered else '* ' lines = body.splitlines() for i, line in enum...
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. """ mark = '#. ' if ordered else '* ' lines = body.splitlines() for i, line in enum...
[ "Rendering", "list", "tags", "like", "<ul", ">", "and", "<ol", ">", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L226-L238
[ "def", "list", "(", "self", ",", "body", ",", "ordered", "=", "True", ")", ":", "mark", "=", "'#. '", "if", "ordered", "else", "'* '", "lines", "=", "body", ".", "splitlines", "(", ")", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestRenderer.table
Rendering table element. Wrap header and body in it. :param header: header part of the table. :param body: body part of the table.
docs/m2r.py
def table(self, header, body): """Rendering table element. Wrap header and body in it. :param header: header part of the table. :param body: body part of the table. """ table = '\n.. list-table::\n' if header and not header.isspace(): table = (table + self.in...
def table(self, header, body): """Rendering table element. Wrap header and body in it. :param header: header part of the table. :param body: body part of the table. """ table = '\n.. list-table::\n' if header and not header.isspace(): table = (table + self.in...
[ "Rendering", "table", "element", ".", "Wrap", "header", "and", "body", "in", "it", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L248-L261
[ "def", "table", "(", "self", ",", "header", ",", "body", ")", ":", "table", "=", "'\\n.. list-table::\\n'", "if", "header", "and", "not", "header", ".", "isspace", "(", ")", ":", "table", "=", "(", "table", "+", "self", ".", "indent", "+", "':header-ro...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestRenderer.table_row
Rendering a table row. Like ``<tr>``. :param content: content of current table row.
docs/m2r.py
def table_row(self, content): """Rendering a table row. Like ``<tr>``. :param content: content of current table row. """ contents = content.splitlines() if not contents: return '' clist = ['* ' + contents[0]] if len(contents) > 1: for c in...
def table_row(self, content): """Rendering a table row. Like ``<tr>``. :param content: content of current table row. """ contents = content.splitlines() if not contents: return '' clist = ['* ' + contents[0]] if len(contents) > 1: for c in...
[ "Rendering", "a", "table", "row", ".", "Like", "<tr", ">", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L263-L275
[ "def", "table_row", "(", "self", ",", "content", ")", ":", "contents", "=", "content", ".", "splitlines", "(", ")", "if", "not", "contents", ":", "return", "''", "clist", "=", "[", "'* '", "+", "contents", "[", "0", "]", "]", "if", "len", "(", "con...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestRenderer.codespan
Rendering inline `code` text. :param text: text content for inline code.
docs/m2r.py
def codespan(self, text): """Rendering inline `code` text. :param text: text content for inline code. """ if '``' not in text: return '\ ``{}``\ '.format(text) else: # actually, docutils split spaces in literal return self._raw_html( ...
def codespan(self, text): """Rendering inline `code` text. :param text: text content for inline code. """ if '``' not in text: return '\ ``{}``\ '.format(text) else: # actually, docutils split spaces in literal return self._raw_html( ...
[ "Rendering", "inline", "code", "text", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L300-L312
[ "def", "codespan", "(", "self", ",", "text", ")", ":", "if", "'``'", "not", "in", "text", ":", "return", "'\\ ``{}``\\ '", ".", "format", "(", "text", ")", "else", ":", "# actually, docutils split spaces in literal", "return", "self", ".", "_raw_html", "(", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestRenderer.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/m2r.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. """ if title: raise NotImplementedError(...
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. """ if title: raise NotImplementedError(...
[ "Rendering", "a", "given", "link", "with", "content", "and", "title", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L342-L351
[ "def", "link", "(", "self", ",", "link", ",", "title", ",", "text", ")", ":", "if", "title", ":", "raise", "NotImplementedError", "(", "'sorry'", ")", "return", "'\\ `{text} <{target}>`_\\ '", ".", "format", "(", "target", "=", "link", ",", "text", "=", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
RestRenderer.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/m2r.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. """ # rst does not support title option # and I couldn't find title attri...
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. """ # rst does not support title option # and I couldn't find title attri...
[ "Rendering", "a", "image", "with", "title", "and", "text", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L353-L368
[ "def", "image", "(", "self", ",", "src", ",", "title", ",", "text", ")", ":", "# rst does not support title option", "# and I couldn't find title attribute in HTML standard", "return", "'\\n'", ".", "join", "(", "[", "''", ",", "'.. image:: {}'", ".", "format", "(",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MdInclude.run
Most of this method is from ``docutils.parser.rst.Directive``. docutils version: 0.12
docs/m2r.py
def run(self): """Most of this method is from ``docutils.parser.rst.Directive``. docutils version: 0.12 """ if not self.state.document.settings.file_insertion_enabled: raise self.warning('"%s" directive disabled.' % self.name) source = self.state_machine.input_lines....
def run(self): """Most of this method is from ``docutils.parser.rst.Directive``. docutils version: 0.12 """ if not self.state.document.settings.file_insertion_enabled: raise self.warning('"%s" directive disabled.' % self.name) source = self.state_machine.input_lines....
[ "Most", "of", "this", "method", "is", "from", "docutils", ".", "parser", ".", "rst", ".", "Directive", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L486-L536
[ "def", "run", "(", "self", ")", ":", "if", "not", "self", ".", "state", ".", "document", ".", "settings", ".", "file_insertion_enabled", ":", "raise", "self", ".", "warning", "(", "'\"%s\" directive disabled.'", "%", "self", ".", "name", ")", "source", "="...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
WorkerAgentGenerator
Worker Agent generator, receives an Agent class and creates a Worker Agent class that inherits from that Agent.
tensorforce/execution/threaded_runner.py
def WorkerAgentGenerator(agent_class): """ Worker Agent generator, receives an Agent class and creates a Worker Agent class that inherits from that Agent. """ # Support special case where class is given as type-string (AgentsDictionary) or class-name-string. if isinstance(agent_class, str): ...
def WorkerAgentGenerator(agent_class): """ Worker Agent generator, receives an Agent class and creates a Worker Agent class that inherits from that Agent. """ # Support special case where class is given as type-string (AgentsDictionary) or class-name-string. if isinstance(agent_class, str): ...
[ "Worker", "Agent", "generator", "receives", "an", "Agent", "class", "and", "creates", "a", "Worker", "Agent", "class", "that", "inherits", "from", "that", "Agent", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/execution/threaded_runner.py#L297-L329
[ "def", "WorkerAgentGenerator", "(", "agent_class", ")", ":", "# Support special case where class is given as type-string (AgentsDictionary) or class-name-string.", "if", "isinstance", "(", "agent_class", ",", "str", ")", ":", "agent_class", "=", "AgentsDictionary", ".", "get", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
clone_worker_agent
Clones a given Agent (`factor` times) and returns a list of the cloned Agents with the original Agent in the first slot. Args: agent (Agent): The Agent object to clone. factor (int): The length of the final list. environment (Environment): The Environment to use for all cloned agents. ...
tensorforce/execution/threaded_runner.py
def clone_worker_agent(agent, factor, environment, network, agent_config): """ Clones a given Agent (`factor` times) and returns a list of the cloned Agents with the original Agent in the first slot. Args: agent (Agent): The Agent object to clone. factor (int): The length of the final l...
def clone_worker_agent(agent, factor, environment, network, agent_config): """ Clones a given Agent (`factor` times) and returns a list of the cloned Agents with the original Agent in the first slot. Args: agent (Agent): The Agent object to clone. factor (int): The length of the final l...
[ "Clones", "a", "given", "Agent", "(", "factor", "times", ")", "and", "returns", "a", "list", "of", "the", "cloned", "Agents", "with", "the", "original", "Agent", "in", "the", "first", "slot", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/execution/threaded_runner.py#L332-L357
[ "def", "clone_worker_agent", "(", "agent", ",", "factor", ",", "environment", ",", "network", ",", "agent_config", ")", ":", "ret", "=", "[", "agent", "]", "for", "i", "in", "xrange", "(", "factor", "-", "1", ")", ":", "worker", "=", "WorkerAgentGenerato...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
ThreadedRunner.run
Executes this runner by starting all Agents in parallel (each one in one thread). Args: episodes (int): Deprecated; see num_episodes. max_timesteps (int): Deprecated; see max_episode_timesteps.
tensorforce/execution/threaded_runner.py
def run( self, num_episodes=-1, max_episode_timesteps=-1, episode_finished=None, summary_report=None, summary_interval=0, num_timesteps=None, deterministic=False, episodes=None, max_timesteps=None, testing=False, sleep=None ...
def run( self, num_episodes=-1, max_episode_timesteps=-1, episode_finished=None, summary_report=None, summary_interval=0, num_timesteps=None, deterministic=False, episodes=None, max_timesteps=None, testing=False, sleep=None ...
[ "Executes", "this", "runner", "by", "starting", "all", "Agents", "in", "parallel", "(", "each", "one", "in", "one", "thread", ")", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/execution/threaded_runner.py#L88-L186
[ "def", "run", "(", "self", ",", "num_episodes", "=", "-", "1", ",", "max_episode_timesteps", "=", "-", "1", ",", "episode_finished", "=", "None", ",", "summary_report", "=", "None", ",", "summary_interval", "=", "0", ",", "num_timesteps", "=", "None", ",",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
ThreadedRunner._run_single
The target function for a thread, runs an agent and environment until signaled to stop. Adds rewards to shared episode rewards list. Args: thread_id (int): The ID of the thread that's running this target function. agent (Agent): The Agent object that this particular thread uses....
tensorforce/execution/threaded_runner.py
def _run_single(self, thread_id, agent, environment, deterministic=False, max_episode_timesteps=-1, episode_finished=None, testing=False, sleep=None): """ The target function for a thread, runs an agent and environment until signaled to stop. Adds rewards to shared episode re...
def _run_single(self, thread_id, agent, environment, deterministic=False, max_episode_timesteps=-1, episode_finished=None, testing=False, sleep=None): """ The target function for a thread, runs an agent and environment until signaled to stop. Adds rewards to shared episode re...
[ "The", "target", "function", "for", "a", "thread", "runs", "an", "agent", "and", "environment", "until", "signaled", "to", "stop", ".", "Adds", "rewards", "to", "shared", "episode", "rewards", "list", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/execution/threaded_runner.py#L188-L277
[ "def", "_run_single", "(", "self", ",", "thread_id", ",", "agent", ",", "environment", ",", "deterministic", "=", "False", ",", "max_episode_timesteps", "=", "-", "1", ",", "episode_finished", "=", "None", ",", "testing", "=", "False", ",", "sleep", "=", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
OpenAIUniverse._int_to_pos
Returns x, y from flat_position integer. Args: flat_position: flattened position integer Returns: x, y
tensorforce/contrib/openai_universe.py
def _int_to_pos(self, flat_position): """Returns x, y from flat_position integer. Args: flat_position: flattened position integer Returns: x, y """ return flat_position % self.env.action_space.screen_shape[0],\ flat_position % self.env.action_space.scre...
def _int_to_pos(self, flat_position): """Returns x, y from flat_position integer. Args: flat_position: flattened position integer Returns: x, y """ return flat_position % self.env.action_space.screen_shape[0],\ flat_position % self.env.action_space.scre...
[ "Returns", "x", "y", "from", "flat_position", "integer", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/openai_universe.py#L86-L96
[ "def", "_int_to_pos", "(", "self", ",", "flat_position", ")", ":", "return", "flat_position", "%", "self", ".", "env", ".", "action_space", ".", "screen_shape", "[", "0", "]", ",", "flat_position", "%", "self", ".", "env", ".", "action_space", ".", "screen...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
OpenAIUniverse._wait_state
Wait until there is a state.
tensorforce/contrib/openai_universe.py
def _wait_state(self, state, reward, terminal): """ Wait until there is a state. """ while state == [None] or not state: state, terminal, reward = self._execute(dict(key=0)) return state, terminal, reward
def _wait_state(self, state, reward, terminal): """ Wait until there is a state. """ while state == [None] or not state: state, terminal, reward = self._execute(dict(key=0)) return state, terminal, reward
[ "Wait", "until", "there", "is", "a", "state", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/openai_universe.py#L110-L117
[ "def", "_wait_state", "(", "self", ",", "state", ",", "reward", ",", "terminal", ")", ":", "while", "state", "==", "[", "None", "]", "or", "not", "state", ":", "state", ",", "terminal", ",", "reward", "=", "self", ".", "_execute", "(", "dict", "(", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Optimizer.apply_step
Applies the given (and already calculated) step deltas to the variable values. Args: variables: List of variables. deltas: List of deltas of same length. Returns: The step-applied operation. A tf.group of tf.assign_add ops.
tensorforce/core/optimizers/optimizer.py
def apply_step(self, variables, deltas): """ Applies the given (and already calculated) step deltas to the variable values. Args: variables: List of variables. deltas: List of deltas of same length. Returns: The step-applied operation. A tf.group of ...
def apply_step(self, variables, deltas): """ Applies the given (and already calculated) step deltas to the variable values. Args: variables: List of variables. deltas: List of deltas of same length. Returns: The step-applied operation. A tf.group of ...
[ "Applies", "the", "given", "(", "and", "already", "calculated", ")", "step", "deltas", "to", "the", "variable", "values", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/optimizer.py#L75-L90
[ "def", "apply_step", "(", "self", ",", "variables", ",", "deltas", ")", ":", "if", "len", "(", "variables", ")", "!=", "len", "(", "deltas", ")", ":", "raise", "TensorForceError", "(", "\"Invalid variables and deltas lists.\"", ")", "return", "tf", ".", "gro...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Optimizer.minimize
Performs an optimization step. Args: time: Time tensor. variables: List of variables to optimize. **kwargs: Additional optimizer-specific arguments. The following arguments are used by some optimizers: - arguments: Dict of arguments for callables,...
tensorforce/core/optimizers/optimizer.py
def minimize(self, time, variables, **kwargs): """ Performs an optimization step. Args: time: Time tensor. variables: List of variables to optimize. **kwargs: Additional optimizer-specific arguments. The following arguments are used by some op...
def minimize(self, time, variables, **kwargs): """ Performs an optimization step. Args: time: Time tensor. variables: List of variables to optimize. **kwargs: Additional optimizer-specific arguments. The following arguments are used by some op...
[ "Performs", "an", "optimization", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/optimizer.py#L92-L146
[ "def", "minimize", "(", "self", ",", "time", ",", "variables", ",", "*", "*", "kwargs", ")", ":", "# # Add training variable gradient histograms/scalars to summary output", "# # if 'gradients' in self.summary_labels:", "# if any(k in self.summary_labels for k in ['gradients', 'gradie...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Optimizer.from_spec
Creates an optimizer from a specification dict.
tensorforce/core/optimizers/optimizer.py
def from_spec(spec, kwargs=None): """ Creates an optimizer from a specification dict. """ optimizer = util.get_object( obj=spec, predefined_objects=tensorforce.core.optimizers.optimizers, kwargs=kwargs ) assert isinstance(optimizer, Opt...
def from_spec(spec, kwargs=None): """ Creates an optimizer from a specification dict. """ optimizer = util.get_object( obj=spec, predefined_objects=tensorforce.core.optimizers.optimizers, kwargs=kwargs ) assert isinstance(optimizer, Opt...
[ "Creates", "an", "optimizer", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/optimizer.py#L158-L168
[ "def", "from_spec", "(", "spec", ",", "kwargs", "=", "None", ")", ":", "optimizer", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "core", ".", "optimizers", ".", "optimizers", ",", "kwargs", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
np_dtype
Translates dtype specifications in configurations to numpy data types. Args: dtype: String describing a numerical type (e.g. 'float') or numerical type primitive. Returns: Numpy data type
tensorforce/util.py
def np_dtype(dtype): """Translates dtype specifications in configurations to numpy data types. Args: dtype: String describing a numerical type (e.g. 'float') or numerical type primitive. Returns: Numpy data type """ if dtype == 'float' or dtype == float or dtype == np.float32 or dtype == t...
def np_dtype(dtype): """Translates dtype specifications in configurations to numpy data types. Args: dtype: String describing a numerical type (e.g. 'float') or numerical type primitive. Returns: Numpy data type """ if dtype == 'float' or dtype == float or dtype == np.float32 or dtype == t...
[ "Translates", "dtype", "specifications", "in", "configurations", "to", "numpy", "data", "types", ".", "Args", ":", "dtype", ":", "String", "describing", "a", "numerical", "type", "(", "e", ".", "g", ".", "float", ")", "or", "numerical", "type", "primitive", ...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/util.py#L61-L84
[ "def", "np_dtype", "(", "dtype", ")", ":", "if", "dtype", "==", "'float'", "or", "dtype", "==", "float", "or", "dtype", "==", "np", ".", "float32", "or", "dtype", "==", "tf", ".", "float32", ":", "return", "np", ".", "float32", "elif", "dtype", "==",...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
get_tensor_dependencies
Utility method to get all dependencies (including placeholders) of a tensor (backwards through the graph). Args: tensor (tf.Tensor): The input tensor. Returns: Set of all dependencies (including needed placeholders) for the input tensor.
tensorforce/util.py
def get_tensor_dependencies(tensor): """ Utility method to get all dependencies (including placeholders) of a tensor (backwards through the graph). Args: tensor (tf.Tensor): The input tensor. Returns: Set of all dependencies (including needed placeholders) for the input tensor. """ dep...
def get_tensor_dependencies(tensor): """ Utility method to get all dependencies (including placeholders) of a tensor (backwards through the graph). Args: tensor (tf.Tensor): The input tensor. Returns: Set of all dependencies (including needed placeholders) for the input tensor. """ dep...
[ "Utility", "method", "to", "get", "all", "dependencies", "(", "including", "placeholders", ")", "of", "a", "tensor", "(", "backwards", "through", "the", "graph", ")", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/util.py#L133-L146
[ "def", "get_tensor_dependencies", "(", "tensor", ")", ":", "dependencies", "=", "set", "(", ")", "dependencies", ".", "update", "(", "tensor", ".", "op", ".", "inputs", ")", "for", "sub_op", "in", "tensor", ".", "op", ".", "inputs", ":", "dependencies", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
get_object
Utility method to map some kind of object specification to its content, e.g. optimizer or baseline specifications to the respective classes. Args: obj: A specification dict (value for key 'type' optionally specifies the object, options as follows), a module path (e.g., m...
tensorforce/util.py
def get_object(obj, predefined_objects=None, default_object=None, kwargs=None): """ Utility method to map some kind of object specification to its content, e.g. optimizer or baseline specifications to the respective classes. Args: obj: A specification dict (value for key 'type' optionally speci...
def get_object(obj, predefined_objects=None, default_object=None, kwargs=None): """ Utility method to map some kind of object specification to its content, e.g. optimizer or baseline specifications to the respective classes. Args: obj: A specification dict (value for key 'type' optionally speci...
[ "Utility", "method", "to", "map", "some", "kind", "of", "object", "specification", "to", "its", "content", "e", ".", "g", ".", "optimizer", "or", "baseline", "specifications", "to", "the", "respective", "classes", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/util.py#L149-L198
[ "def", "get_object", "(", "obj", ",", "predefined_objects", "=", "None", ",", "default_object", "=", "None", ",", "kwargs", "=", "None", ")", ":", "args", "=", "(", ")", "kwargs", "=", "dict", "(", ")", "if", "kwargs", "is", "None", "else", "kwargs", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
prepare_kwargs
Utility method to convert raw string/diction input into a dictionary to pass into a function. Always returns a dictionary. Args: raw: string or dictionary, string is assumed to be the name of the activation activation function. Dictionary will be passed through unchanged. Returns...
tensorforce/util.py
def prepare_kwargs(raw, string_parameter='name'): """ Utility method to convert raw string/diction input into a dictionary to pass into a function. Always returns a dictionary. Args: raw: string or dictionary, string is assumed to be the name of the activation activation functi...
def prepare_kwargs(raw, string_parameter='name'): """ Utility method to convert raw string/diction input into a dictionary to pass into a function. Always returns a dictionary. Args: raw: string or dictionary, string is assumed to be the name of the activation activation functi...
[ "Utility", "method", "to", "convert", "raw", "string", "/", "diction", "input", "into", "a", "dictionary", "to", "pass", "into", "a", "function", ".", "Always", "returns", "a", "dictionary", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/util.py#L201-L220
[ "def", "prepare_kwargs", "(", "raw", ",", "string_parameter", "=", "'name'", ")", ":", "kwargs", "=", "dict", "(", ")", "if", "isinstance", "(", "raw", ",", "dict", ")", ":", "kwargs", ".", "update", "(", "raw", ")", "elif", "isinstance", "(", "raw", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SavableComponent.register_saver_ops
Registers the saver operations to the graph in context.
tensorforce/util.py
def register_saver_ops(self): """ Registers the saver operations to the graph in context. """ variables = self.get_savable_variables() if variables is None or len(variables) == 0: self._saver = None return base_scope = self._get_base_variable_sco...
def register_saver_ops(self): """ Registers the saver operations to the graph in context. """ variables = self.get_savable_variables() if variables is None or len(variables) == 0: self._saver = None return base_scope = self._get_base_variable_sco...
[ "Registers", "the", "saver", "operations", "to", "the", "graph", "in", "context", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/util.py#L235-L263
[ "def", "register_saver_ops", "(", "self", ")", ":", "variables", "=", "self", ".", "get_savable_variables", "(", ")", "if", "variables", "is", "None", "or", "len", "(", "variables", ")", "==", "0", ":", "self", ".", "_saver", "=", "None", "return", "base...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SavableComponent.save
Saves this component's managed variables. Args: sess: The session for which to save the managed variables. save_path: The path to save data to. timestep: Optional, the timestep to append to the file name. Returns: Checkpoint path where the model was save...
tensorforce/util.py
def save(self, sess, save_path, timestep=None): """ Saves this component's managed variables. Args: sess: The session for which to save the managed variables. save_path: The path to save data to. timestep: Optional, the timestep to append to the file name. ...
def save(self, sess, save_path, timestep=None): """ Saves this component's managed variables. Args: sess: The session for which to save the managed variables. save_path: The path to save data to. timestep: Optional, the timestep to append to the file name. ...
[ "Saves", "this", "component", "s", "managed", "variables", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/util.py#L275-L296
[ "def", "save", "(", "self", ",", "sess", ",", "save_path", ",", "timestep", "=", "None", ")", ":", "if", "self", ".", "_saver", "is", "None", ":", "raise", "TensorForceError", "(", "\"register_saver_ops should be called before save\"", ")", "return", "self", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
SavableComponent.restore
Restores the values of the managed variables from disk location. Args: sess: The session for which to save the managed variables. save_path: The path used to save the data to.
tensorforce/util.py
def restore(self, sess, save_path): """ Restores the values of the managed variables from disk location. Args: sess: The session for which to save the managed variables. save_path: The path used to save the data to. """ if self._saver is None: ...
def restore(self, sess, save_path): """ Restores the values of the managed variables from disk location. Args: sess: The session for which to save the managed variables. save_path: The path used to save the data to. """ if self._saver is None: ...
[ "Restores", "the", "values", "of", "the", "managed", "variables", "from", "disk", "location", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/util.py#L298-L309
[ "def", "restore", "(", "self", ",", "sess", ",", "save_path", ")", ":", "if", "self", ".", "_saver", "is", "None", ":", "raise", "TensorForceError", "(", "\"register_saver_ops should be called before restore\"", ")", "self", ".", "_saver", ".", "restore", "(", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PreprocessorStack.reset
Calls `reset` on all our Preprocessor objects. Returns: A list of tensors to be fetched.
tensorforce/core/preprocessors/preprocessor.py
def reset(self): """ Calls `reset` on all our Preprocessor objects. Returns: A list of tensors to be fetched. """ fetches = [] for processor in self.preprocessors: fetches.extend(processor.reset() or []) return fetches
def reset(self): """ Calls `reset` on all our Preprocessor objects. Returns: A list of tensors to be fetched. """ fetches = [] for processor in self.preprocessors: fetches.extend(processor.reset() or []) return fetches
[ "Calls", "reset", "on", "all", "our", "Preprocessor", "objects", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/preprocessors/preprocessor.py#L113-L123
[ "def", "reset", "(", "self", ")", ":", "fetches", "=", "[", "]", "for", "processor", "in", "self", ".", "preprocessors", ":", "fetches", ".", "extend", "(", "processor", ".", "reset", "(", ")", "or", "[", "]", ")", "return", "fetches" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PreprocessorStack.process
Process state. Args: tensor: tensor to process Returns: processed state
tensorforce/core/preprocessors/preprocessor.py
def process(self, tensor): """ Process state. Args: tensor: tensor to process Returns: processed state """ for processor in self.preprocessors: tensor = processor.process(tensor=tensor) return tensor
def process(self, tensor): """ Process state. Args: tensor: tensor to process Returns: processed state """ for processor in self.preprocessors: tensor = processor.process(tensor=tensor) return tensor
[ "Process", "state", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/preprocessors/preprocessor.py#L125-L137
[ "def", "process", "(", "self", ",", "tensor", ")", ":", "for", "processor", "in", "self", ".", "preprocessors", ":", "tensor", "=", "processor", ".", "process", "(", "tensor", "=", "tensor", ")", "return", "tensor" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PreprocessorStack.processed_shape
Shape of preprocessed state given original shape. Args: shape: original state shape Returns: processed state shape
tensorforce/core/preprocessors/preprocessor.py
def processed_shape(self, shape): """ Shape of preprocessed state given original shape. Args: shape: original state shape Returns: processed state shape """ for processor in self.preprocessors: shape = processor.processed_shape(shape=shape) ...
def processed_shape(self, shape): """ Shape of preprocessed state given original shape. Args: shape: original state shape Returns: processed state shape """ for processor in self.preprocessors: shape = processor.processed_shape(shape=shape) ...
[ "Shape", "of", "preprocessed", "state", "given", "original", "shape", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/preprocessors/preprocessor.py#L139-L150
[ "def", "processed_shape", "(", "self", ",", "shape", ")", ":", "for", "processor", "in", "self", ".", "preprocessors", ":", "shape", "=", "processor", ".", "processed_shape", "(", "shape", "=", "shape", ")", "return", "shape" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
PreprocessorStack.from_spec
Creates a preprocessing stack from a specification dict.
tensorforce/core/preprocessors/preprocessor.py
def from_spec(spec, kwargs=None): """ Creates a preprocessing stack from a specification dict. """ if isinstance(spec, dict): spec = [spec] stack = PreprocessorStack() for preprocessor_spec in spec: # need to deep copy, otherwise will add first pr...
def from_spec(spec, kwargs=None): """ Creates a preprocessing stack from a specification dict. """ if isinstance(spec, dict): spec = [spec] stack = PreprocessorStack() for preprocessor_spec in spec: # need to deep copy, otherwise will add first pr...
[ "Creates", "a", "preprocessing", "stack", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/preprocessors/preprocessor.py#L156-L175
[ "def", "from_spec", "(", "spec", ",", "kwargs", "=", "None", ")", ":", "if", "isinstance", "(", "spec", ",", "dict", ")", ":", "spec", "=", "[", "spec", "]", "stack", "=", "PreprocessorStack", "(", ")", "for", "preprocessor_spec", "in", "spec", ":", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Iterative.tf_solve
Iteratively solves an equation/optimization for $x$ involving an expression $f(x)$. Args: fn_x: A callable returning an expression $f(x)$ given $x$. x_init: Initial solution guess $x_0$. *args: Additional solver-specific arguments. Returns: A solution $x...
tensorforce/core/optimizers/solvers/iterative.py
def tf_solve(self, fn_x, x_init, *args): """ Iteratively solves an equation/optimization for $x$ involving an expression $f(x)$. Args: fn_x: A callable returning an expression $f(x)$ given $x$. x_init: Initial solution guess $x_0$. *args: Additional solver-sp...
def tf_solve(self, fn_x, x_init, *args): """ Iteratively solves an equation/optimization for $x$ involving an expression $f(x)$. Args: fn_x: A callable returning an expression $f(x)$ given $x$. x_init: Initial solution guess $x_0$. *args: Additional solver-sp...
[ "Iteratively", "solves", "an", "equation", "/", "optimization", "for", "$x$", "involving", "an", "expression", "$f", "(", "x", ")", "$", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/solvers/iterative.py#L49-L81
[ "def", "tf_solve", "(", "self", ",", "fn_x", ",", "x_init", ",", "*", "args", ")", ":", "self", ".", "fn_x", "=", "fn_x", "# Initialization step", "args", "=", "self", ".", "initialize", "(", "x_init", ",", "*", "args", ")", "# args = util.map_tensors(fn=t...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
OpenAIRetro.execute
Executes action, observes next state and reward. Args: actions: Actions to execute. Returns: Tuple of (next state, bool indicating terminal, reward)
tensorforce/contrib/openai_retro.py
def execute(self, action): """ Executes action, observes next state and reward. Args: actions: Actions to execute. Returns: Tuple of (next state, bool indicating terminal, reward) """ next_state, rew, done, _ = self.env.step(action) retur...
def execute(self, action): """ Executes action, observes next state and reward. Args: actions: Actions to execute. Returns: Tuple of (next state, bool indicating terminal, reward) """ next_state, rew, done, _ = self.env.step(action) retur...
[ "Executes", "action", "observes", "next", "state", "and", "reward", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/contrib/openai_retro.py#L69-L80
[ "def", "execute", "(", "self", ",", "action", ")", ":", "next_state", ",", "rew", ",", "done", ",", "_", "=", "self", ".", "env", ".", "step", "(", "action", ")", "return", "next_state", ",", "rew", ",", "done" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.as_local_model
Makes sure our optimizer is wrapped into the global_optimizer meta. This is only relevant for distributed RL.
tensorforce/models/memory_model.py
def as_local_model(self): """ Makes sure our optimizer is wrapped into the global_optimizer meta. This is only relevant for distributed RL. """ super(MemoryModel, self).as_local_model() self.optimizer_spec = dict( type='global_optimizer', optimizer=self.op...
def as_local_model(self): """ Makes sure our optimizer is wrapped into the global_optimizer meta. This is only relevant for distributed RL. """ super(MemoryModel, self).as_local_model() self.optimizer_spec = dict( type='global_optimizer', optimizer=self.op...
[ "Makes", "sure", "our", "optimizer", "is", "wrapped", "into", "the", "global_optimizer", "meta", ".", "This", "is", "only", "relevant", "for", "distributed", "RL", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L117-L125
[ "def", "as_local_model", "(", "self", ")", ":", "super", "(", "MemoryModel", ",", "self", ")", ".", "as_local_model", "(", ")", "self", ".", "optimizer_spec", "=", "dict", "(", "type", "=", "'global_optimizer'", ",", "optimizer", "=", "self", ".", "optimiz...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.setup_components_and_tf_funcs
Constructs the memory and the optimizer objects. Generates and stores all template functions.
tensorforce/models/memory_model.py
def setup_components_and_tf_funcs(self, custom_getter=None): """ Constructs the memory and the optimizer objects. Generates and stores all template functions. """ custom_getter = super(MemoryModel, self).setup_components_and_tf_funcs(custom_getter) # Memory self....
def setup_components_and_tf_funcs(self, custom_getter=None): """ Constructs the memory and the optimizer objects. Generates and stores all template functions. """ custom_getter = super(MemoryModel, self).setup_components_and_tf_funcs(custom_getter) # Memory self....
[ "Constructs", "the", "memory", "and", "the", "optimizer", "objects", ".", "Generates", "and", "stores", "all", "template", "functions", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L127-L188
[ "def", "setup_components_and_tf_funcs", "(", "self", ",", "custom_getter", "=", "None", ")", ":", "custom_getter", "=", "super", "(", "MemoryModel", ",", "self", ")", ".", "setup_components_and_tf_funcs", "(", "custom_getter", ")", "# Memory", "self", ".", "memory...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.tf_discounted_cumulative_reward
Creates and returns the TensorFlow operations for calculating the sequence of discounted cumulative rewards for a given sequence of single rewards. Example: single rewards = 2.0 1.0 0.0 0.5 1.0 -1.0 terminal = False, False, False, False True False gamma = 0.95 final_rewa...
tensorforce/models/memory_model.py
def tf_discounted_cumulative_reward(self, terminal, reward, discount=None, final_reward=0.0, horizon=0): """ Creates and returns the TensorFlow operations for calculating the sequence of discounted cumulative rewards for a given sequence of single rewards. Example: single reward...
def tf_discounted_cumulative_reward(self, terminal, reward, discount=None, final_reward=0.0, horizon=0): """ Creates and returns the TensorFlow operations for calculating the sequence of discounted cumulative rewards for a given sequence of single rewards. Example: single reward...
[ "Creates", "and", "returns", "the", "TensorFlow", "operations", "for", "calculating", "the", "sequence", "of", "discounted", "cumulative", "rewards", "for", "a", "given", "sequence", "of", "single", "rewards", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L227-L317
[ "def", "tf_discounted_cumulative_reward", "(", "self", ",", "terminal", ",", "reward", ",", "discount", "=", "None", ",", "final_reward", "=", "0.0", ",", "horizon", "=", "0", ")", ":", "# By default -> take Model's gamma value", "if", "discount", "is", "None", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.tf_reference
Creates the TensorFlow operations for obtaining the reference tensor(s), in case of a comparative loss. Args: states: Dict of state tensors. internals: List of prior internal state tensors. actions: Dict of action tensors. terminal: Terminal boolean tenso...
tensorforce/models/memory_model.py
def tf_reference(self, states, internals, actions, terminal, reward, next_states, next_internals, update): """ Creates the TensorFlow operations for obtaining the reference tensor(s), in case of a comparative loss. Args: states: Dict of state tensors. internals: ...
def tf_reference(self, states, internals, actions, terminal, reward, next_states, next_internals, update): """ Creates the TensorFlow operations for obtaining the reference tensor(s), in case of a comparative loss. Args: states: Dict of state tensors. internals: ...
[ "Creates", "the", "TensorFlow", "operations", "for", "obtaining", "the", "reference", "tensor", "(", "s", ")", "in", "case", "of", "a", "comparative", "loss", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L319-L337
[ "def", "tf_reference", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ",", "next_states", ",", "next_internals", ",", "update", ")", ":", "return", "None" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.tf_loss_per_instance
Creates the TensorFlow operations for calculating the loss per batch instance. Args: states: Dict of state tensors. internals: Dict of prior internal state tensors. actions: Dict of action tensors. terminal: Terminal boolean tensor. reward: Reward ten...
tensorforce/models/memory_model.py
def tf_loss_per_instance(self, states, internals, actions, terminal, reward, next_states, next_internals, update, reference=None): """ Creates the TensorFlow operations for calculating the loss per batch instance. Args: states: Dict of state tensors. ...
def tf_loss_per_instance(self, states, internals, actions, terminal, reward, next_states, next_internals, update, reference=None): """ Creates the TensorFlow operations for calculating the loss per batch instance. Args: states: Dict of state tensors. ...
[ "Creates", "the", "TensorFlow", "operations", "for", "calculating", "the", "loss", "per", "batch", "instance", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L339-L358
[ "def", "tf_loss_per_instance", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ",", "next_states", ",", "next_internals", ",", "update", ",", "reference", "=", "None", ")", ":", "raise", "NotImplementedError" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.tf_loss
Creates the TensorFlow operations for calculating the full loss of a batch. Args: states: Dict of state tensors. internals: List of prior internal state tensors. actions: Dict of action tensors. terminal: Terminal boolean tensor. reward: Reward tensor...
tensorforce/models/memory_model.py
def tf_loss(self, states, internals, actions, terminal, reward, next_states, next_internals, update, reference=None): """ Creates the TensorFlow operations for calculating the full loss of a batch. Args: states: Dict of state tensors. internals: List of prior internal st...
def tf_loss(self, states, internals, actions, terminal, reward, next_states, next_internals, update, reference=None): """ Creates the TensorFlow operations for calculating the full loss of a batch. Args: states: Dict of state tensors. internals: List of prior internal st...
[ "Creates", "the", "TensorFlow", "operations", "for", "calculating", "the", "full", "loss", "of", "a", "batch", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L374-L426
[ "def", "tf_loss", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ",", "next_states", ",", "next_internals", ",", "update", ",", "reference", "=", "None", ")", ":", "# Mean loss per instance", "loss_per_instance", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.optimizer_arguments
Returns the 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): Dict of state tensors. internals (dict): Dict of prior internal state tensors. ...
tensorforce/models/memory_model.py
def optimizer_arguments(self, states, internals, actions, terminal, reward, next_states, next_internals): """ Returns the 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: ...
def optimizer_arguments(self, states, internals, actions, terminal, reward, next_states, next_internals): """ Returns the 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: ...
[ "Returns", "the", "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/memory_model.py#L428-L463
[ "def", "optimizer_arguments", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ",", "next_states", ",", "next_internals", ")", ":", "arguments", "=", "dict", "(", "time", "=", "self", ".", "global_timestep", ",", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.tf_optimization
Creates the TensorFlow operations for performing an optimization update step based on the given input states and actions batch. Args: states: Dict of state tensors. internals: List of prior internal state tensors. actions: Dict of action tensors. terminal...
tensorforce/models/memory_model.py
def tf_optimization(self, states, internals, actions, terminal, reward, next_states=None, next_internals=None): """ Creates the TensorFlow operations for performing an optimization update step based on the given input states and actions batch. Args: states: Dict of state ten...
def tf_optimization(self, states, internals, actions, terminal, reward, next_states=None, next_internals=None): """ Creates the TensorFlow operations for performing an optimization update step based on the given input states and actions batch. Args: states: Dict of state ten...
[ "Creates", "the", "TensorFlow", "operations", "for", "performing", "an", "optimization", "update", "step", "based", "on", "the", "given", "input", "states", "and", "actions", "batch", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L465-L491
[ "def", "tf_optimization", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ",", "next_states", "=", "None", ",", "next_internals", "=", "None", ")", ":", "arguments", "=", "self", ".", "optimizer_arguments", "(", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.tf_observe_timestep
Creates and returns the op that - if frequency condition is hit - pulls a batch from the memory and does one optimization step.
tensorforce/models/memory_model.py
def tf_observe_timestep(self, states, internals, actions, terminal, reward): """ Creates and returns the op that - if frequency condition is hit - pulls a batch from the memory and does one optimization step. """ # Store timestep in memory stored = self.memory.store( ...
def tf_observe_timestep(self, states, internals, actions, terminal, reward): """ Creates and returns the op that - if frequency condition is hit - pulls a batch from the memory and does one optimization step. """ # Store timestep in memory stored = self.memory.store( ...
[ "Creates", "and", "returns", "the", "op", "that", "-", "if", "frequency", "condition", "is", "hit", "-", "pulls", "a", "batch", "from", "the", "memory", "and", "does", "one", "optimization", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L493-L573
[ "def", "tf_observe_timestep", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ")", ":", "# Store timestep in memory", "stored", "=", "self", ".", "memory", ".", "store", "(", "states", "=", "states", ",", "intern...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.tf_import_experience
Imports experiences into the TensorFlow memory structure. Can be used to import off-policy data. :param states: Dict of state values to import with keys as state names and values as values to set. :param internals: Internal values to set, can be fetched from agent via agent.current_internals ...
tensorforce/models/memory_model.py
def tf_import_experience(self, states, internals, actions, terminal, reward): """ Imports experiences into the TensorFlow memory structure. Can be used to import off-policy data. :param states: Dict of state values to import with keys as state names and values as values to set. ...
def tf_import_experience(self, states, internals, actions, terminal, reward): """ Imports experiences into the TensorFlow memory structure. Can be used to import off-policy data. :param states: Dict of state values to import with keys as state names and values as values to set. ...
[ "Imports", "experiences", "into", "the", "TensorFlow", "memory", "structure", ".", "Can", "be", "used", "to", "import", "off", "-", "policy", "data", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L575-L593
[ "def", "tf_import_experience", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ")", ":", "return", "self", ".", "memory", ".", "store", "(", "states", "=", "states", ",", "internals", "=", "internals", ",", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
MemoryModel.import_experience
Stores experiences.
tensorforce/models/memory_model.py
def import_experience(self, states, internals, actions, terminal, reward): """ Stores experiences. """ fetches = self.import_experience_output feed_dict = self.get_feed_dict( states=states, internals=internals, actions=actions, ter...
def import_experience(self, states, internals, actions, terminal, reward): """ Stores experiences. """ fetches = self.import_experience_output feed_dict = self.get_feed_dict( states=states, internals=internals, actions=actions, ter...
[ "Stores", "experiences", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/memory_model.py#L635-L649
[ "def", "import_experience", "(", "self", ",", "states", ",", "internals", ",", "actions", ",", "terminal", ",", "reward", ")", ":", "fetches", "=", "self", ".", "import_experience_output", "feed_dict", "=", "self", ".", "get_feed_dict", "(", "states", "=", "...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
OptimizedStep.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/optimized_step.py
def tf_step( self, time, variables, arguments, fn_loss, fn_reference, **kwargs ): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables ...
def tf_step( self, time, variables, arguments, fn_loss, fn_reference, **kwargs ): """ Creates the TensorFlow operations for performing an optimization step. Args: time: Time tensor. variables: List of variables ...
[ "Creates", "the", "TensorFlow", "operations", "for", "performing", "an", "optimization", "step", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/optimizers/optimized_step.py#L65-L134
[ "def", "tf_step", "(", "self", ",", "time", ",", "variables", ",", "arguments", ",", "fn_loss", ",", "fn_reference", ",", "*", "*", "kwargs", ")", ":", "# Set reference to compare with at each optimization step, in case of a comparative loss.", "arguments", "[", "'refer...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Distribution.from_spec
Creates a distribution from a specification dict.
tensorforce/core/distributions/distribution.py
def from_spec(spec, kwargs=None): """ Creates a distribution from a specification dict. """ distribution = util.get_object( obj=spec, predefined_objects=tensorforce.core.distributions.distributions, kwargs=kwargs ) assert isinstance(dis...
def from_spec(spec, kwargs=None): """ Creates a distribution from a specification dict. """ distribution = util.get_object( obj=spec, predefined_objects=tensorforce.core.distributions.distributions, kwargs=kwargs ) assert isinstance(dis...
[ "Creates", "a", "distribution", "from", "a", "specification", "dict", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/core/distributions/distribution.py#L184-L194
[ "def", "from_spec", "(", "spec", ",", "kwargs", "=", "None", ")", ":", "distribution", "=", "util", ".", "get_object", "(", "obj", "=", "spec", ",", "predefined_objects", "=", "tensorforce", ".", "core", ".", "distributions", ".", "distributions", ",", "kw...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Agent.reset
Resets the agent to its initial state (e.g. on experiment start). Updates the Model's internal episode and time step counter, internal states, and resets preprocessors.
tensorforce/agents/agent.py
def reset(self): """ Resets the agent to its initial state (e.g. on experiment start). Updates the Model's internal episode and time step counter, internal states, and resets preprocessors. """ self.episode, self.timestep, self.next_internals = self.model.reset() self.cur...
def reset(self): """ Resets the agent to its initial state (e.g. on experiment start). Updates the Model's internal episode and time step counter, internal states, and resets preprocessors. """ self.episode, self.timestep, self.next_internals = self.model.reset() self.cur...
[ "Resets", "the", "agent", "to", "its", "initial", "state", "(", "e", ".", "g", ".", "on", "experiment", "start", ")", ".", "Updates", "the", "Model", "s", "internal", "episode", "and", "time", "step", "counter", "internal", "states", "and", "resets", "pr...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/agents/agent.py#L96-L102
[ "def", "reset", "(", "self", ")", ":", "self", ".", "episode", ",", "self", ".", "timestep", ",", "self", ".", "next_internals", "=", "self", ".", "model", ".", "reset", "(", ")", "self", ".", "current_internals", "=", "self", ".", "next_internals" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Agent.act
Return action(s) for given state(s). States preprocessing and exploration are applied if configured accordingly. Args: states (any): One state (usually a value tuple) or dict of states if multiple states are expected. deterministic (bool): If true, no exploration and sampling is...
tensorforce/agents/agent.py
def act(self, states, deterministic=False, independent=False, fetch_tensors=None, buffered=True, index=0): """ Return action(s) for given state(s). States preprocessing and exploration are applied if configured accordingly. Args: states (any): One state (usually a value tupl...
def act(self, states, deterministic=False, independent=False, fetch_tensors=None, buffered=True, index=0): """ Return action(s) for given state(s). States preprocessing and exploration are applied if configured accordingly. Args: states (any): One state (usually a value tupl...
[ "Return", "action", "(", "s", ")", "for", "given", "state", "(", "s", ")", ".", "States", "preprocessing", "and", "exploration", "are", "applied", "if", "configured", "accordingly", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/agents/agent.py#L104-L164
[ "def", "act", "(", "self", ",", "states", ",", "deterministic", "=", "False", ",", "independent", "=", "False", ",", "fetch_tensors", "=", "None", ",", "buffered", "=", "True", ",", "index", "=", "0", ")", ":", "self", ".", "current_internals", "=", "s...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Agent.observe
Observe experience from the environment to learn from. Optionally pre-processes rewards Child classes should call super to get the processed reward EX: terminal, reward = super()... Args: terminal (bool): boolean indicating if the episode terminated after the observation. ...
tensorforce/agents/agent.py
def observe(self, terminal, reward, index=0): """ Observe experience from the environment to learn from. Optionally pre-processes rewards Child classes should call super to get the processed reward EX: terminal, reward = super()... Args: terminal (bool): boolean indi...
def observe(self, terminal, reward, index=0): """ Observe experience from the environment to learn from. Optionally pre-processes rewards Child classes should call super to get the processed reward EX: terminal, reward = super()... Args: terminal (bool): boolean indi...
[ "Observe", "experience", "from", "the", "environment", "to", "learn", "from", ".", "Optionally", "pre", "-", "processes", "rewards", "Child", "classes", "should", "call", "super", "to", "get", "the", "processed", "reward", "EX", ":", "terminal", "reward", "=",...
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/agents/agent.py#L166-L197
[ "def", "observe", "(", "self", ",", "terminal", ",", "reward", ",", "index", "=", "0", ")", ":", "self", ".", "current_terminal", "=", "terminal", "self", ".", "current_reward", "=", "reward", "if", "self", ".", "batched_observe", ":", "# Batched observe for...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Agent.atomic_observe
Utility method for unbuffered observing where each tuple is inserted into TensorFlow via a single session call, thus avoiding race conditions in multi-threaded mode. Observe full experience tuplefrom the environment to learn from. Optionally pre-processes rewards Child classes should call supe...
tensorforce/agents/agent.py
def atomic_observe(self, states, actions, internals, reward, terminal): """ Utility method for unbuffered observing where each tuple is inserted into TensorFlow via a single session call, thus avoiding race conditions in multi-threaded mode. Observe full experience tuplefrom the enviro...
def atomic_observe(self, states, actions, internals, reward, terminal): """ Utility method for unbuffered observing where each tuple is inserted into TensorFlow via a single session call, thus avoiding race conditions in multi-threaded mode. Observe full experience tuplefrom the enviro...
[ "Utility", "method", "for", "unbuffered", "observing", "where", "each", "tuple", "is", "inserted", "into", "TensorFlow", "via", "a", "single", "session", "call", "thus", "avoiding", "race", "conditions", "in", "multi", "-", "threaded", "mode", "." ]
tensorforce/tensorforce
python
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/agents/agent.py#L199-L230
[ "def", "atomic_observe", "(", "self", ",", "states", ",", "actions", ",", "internals", ",", "reward", ",", "terminal", ")", ":", "# TODO probably unnecessary here.", "self", ".", "current_terminal", "=", "terminal", "self", ".", "current_reward", "=", "reward", ...
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Agent.save_model
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/agents/agent.py
def save_model(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...
def save_model(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...
[ "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/agents/agent.py#L244-L264
[ "def", "save_model", "(", "self", ",", "directory", "=", "None", ",", "append_timestep", "=", "True", ")", ":", "return", "self", ".", "model", ".", "save", "(", "directory", "=", "directory", ",", "append_timestep", "=", "append_timestep", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb
valid
Agent.restore_model
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/agents/agent.py
def restore_model(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_model(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/agents/agent.py#L266-L276
[ "def", "restore_model", "(", "self", ",", "directory", "=", "None", ",", "file", "=", "None", ")", ":", "self", ".", "model", ".", "restore", "(", "directory", "=", "directory", ",", "file", "=", "file", ")" ]
520a8d992230e382f08e315ede5fc477f5e26bfb