_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q253000
SRE_Match._create_regs
validation
def _create_regs(self, state): """Creates a tuple of index pairs representing matched groups.""" regs = [(state.start, state.string_position)] for group in range(self.re.groups): mark_index = 2 * group if mark_index + 1 < len(state.marks) \ ...
python
{ "resource": "" }
q253001
SRE_Match.group
validation
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:
python
{ "resource": "" }
q253002
_State.fast_search
validation
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...
python
{ "resource": "" }
q253003
_MatchContext.push_new_context
validation
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,
python
{ "resource": "" }
q253004
_OpcodeDispatcher.match
validation
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...
python
{ "resource": "" }
q253005
_OpcodeDispatcher.dispatch
validation
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)] ...
python
{ "resource": "" }
q253006
_OpcodeDispatcher.check_charset
validation
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
python
{ "resource": "" }
q253007
unexpo
validation
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
python
{ "resource": "" }
q253008
roundfrac
validation
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...
python
{ "resource": "" }
q253009
GrumpyRandom._randbelow
validation
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)
python
{ "resource": "" }
q253010
filter
validation
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(...
python
{ "resource": "" }
q253011
fnmatchcase
validation
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)
python
{ "resource": "" }
q253012
translate
validation
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 + '...
python
{ "resource": "" }
q253013
Queue.task_done
validation
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 ...
python
{ "resource": "" }
q253014
Queue.put
validation
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 ...
python
{ "resource": "" }
q253015
calculate_transitive_deps
validation
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...
python
{ "resource": "" }
q253016
_make_future_features
validation
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...
python
{ "resource": "" }
q253017
nested
validation
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...
python
{ "resource": "" }
q253018
Baseline.tf_loss
validation
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...
python
{ "resource": "" }
q253019
Baseline.get_variables
validation
def get_variables(self, include_nontrainable=False): """ Returns the TensorFlow variables used by the baseline. Returns: List of variables """ if include_nontrainable: return
python
{ "resource": "" }
q253020
Baseline.from_spec
validation
def from_spec(spec, kwargs=None): """ Creates a baseline from a specification dict. """ baseline = util.get_object( obj=spec,
python
{ "resource": "" }
q253021
DeepMindLab.reset
validation
def reset(self): """ Resets the environment to its initialization state. This method needs to be called to start a new episode after
python
{ "resource": "" }
q253022
DeepMindLab.execute
validation
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...
python
{ "resource": "" }
q253023
ConjugateGradient.tf_step
validation
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$. ...
python
{ "resource": "" }
q253024
Layer.from_spec
validation
def from_spec(spec, kwargs=None): """ Creates a layer from a specification dict. """ layer = util.get_object( obj=spec,
python
{ "resource": "" }
q253025
QModel.target_optimizer_arguments
validation
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....
python
{ "resource": "" }
q253026
Environment.from_spec
validation
def from_spec(spec, kwargs): """ Creates an environment from a specification dict. """ env = tensorforce.util.get_object( obj=spec,
python
{ "resource": "" }
q253027
setup
validation
def setup(app): """When used for spinx extension.""" global _is_sphinx _is_sphinx = True app.add_config_value('no_underscore_emphasis', False, 'env')
python
{ "resource": "" }
q253028
RestInlineLexer.output_image_link
validation
def output_image_link(self, m): """Pass through rest role.""" return self.renderer.image_link(
python
{ "resource": "" }
q253029
RestInlineLexer.output_eol_literal_marker
validation
def output_eol_literal_marker(self, m): """Pass through rest link."""
python
{ "resource": "" }
q253030
RestRenderer.table
validation
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...
python
{ "resource": "" }
q253031
MdInclude.run
validation
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....
python
{ "resource": "" }
q253032
WorkerAgentGenerator
validation
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): ...
python
{ "resource": "" }
q253033
ThreadedRunner._run_single
validation
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...
python
{ "resource": "" }
q253034
OpenAIUniverse._int_to_pos
validation
def _int_to_pos(self, flat_position): """Returns x, y from flat_position integer. Args: flat_position: flattened position integer
python
{ "resource": "" }
q253035
OpenAIUniverse._wait_state
validation
def _wait_state(self, state, reward, terminal): """ Wait until there is a state. """
python
{ "resource": "" }
q253036
Optimizer.from_spec
validation
def from_spec(spec, kwargs=None): """ Creates an optimizer from a specification dict. """ optimizer = util.get_object( obj=spec,
python
{ "resource": "" }
q253037
SavableComponent.register_saver_ops
validation
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...
python
{ "resource": "" }
q253038
SavableComponent.save
validation
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. ...
python
{ "resource": "" }
q253039
SavableComponent.restore
validation
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. """
python
{ "resource": "" }
q253040
PreprocessorStack.reset
validation
def reset(self): """ Calls `reset` on all our Preprocessor objects. Returns: A list of tensors to be fetched. """ fetches = [] for processor in
python
{ "resource": "" }
q253041
PreprocessorStack.process
validation
def process(self, tensor): """ Process state. Args: tensor: tensor to process
python
{ "resource": "" }
q253042
PreprocessorStack.processed_shape
validation
def processed_shape(self, shape): """ Shape of preprocessed state given original shape. Args: shape: original state
python
{ "resource": "" }
q253043
PreprocessorStack.from_spec
validation
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...
python
{ "resource": "" }
q253044
MemoryModel.as_local_model
validation
def as_local_model(self): """ Makes sure our optimizer is wrapped into the global_optimizer meta. This is only relevant for distributed RL. """
python
{ "resource": "" }
q253045
MemoryModel.setup_components_and_tf_funcs
validation
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....
python
{ "resource": "" }
q253046
MemoryModel.tf_discounted_cumulative_reward
validation
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...
python
{ "resource": "" }
q253047
MemoryModel.tf_loss_per_instance
validation
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. ...
python
{ "resource": "" }
q253048
MemoryModel.tf_loss
validation
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...
python
{ "resource": "" }
q253049
MemoryModel.optimizer_arguments
validation
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: ...
python
{ "resource": "" }
q253050
MemoryModel.tf_optimization
validation
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...
python
{ "resource": "" }
q253051
MemoryModel.tf_import_experience
validation
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. ...
python
{ "resource": "" }
q253052
MemoryModel.import_experience
validation
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,
python
{ "resource": "" }
q253053
Distribution.from_spec
validation
def from_spec(spec, kwargs=None): """ Creates a distribution from a specification dict. """ distribution = util.get_object(
python
{ "resource": "" }
q253054
Agent.atomic_observe
validation
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...
python
{ "resource": "" }
q253055
Agent.from_spec
validation
def from_spec(spec, kwargs): """ Creates an agent from a specification dict. """ agent = util.get_object( obj=spec,
python
{ "resource": "" }
q253056
Network.get_named_tensor
validation
def get_named_tensor(self, name): """ Returns a named tensor if available. Returns: valid: True if named tensor found, False otherwise tensor: If valid, will be a tensor, otherwise None """
python
{ "resource": "" }
q253057
Network.from_spec
validation
def from_spec(spec, kwargs=None): """ Creates a network from a specification dict. """ network = util.get_object( obj=spec, default_object=LayeredNetwork,
python
{ "resource": "" }
q253058
SumTree.put
validation
def put(self, item, priority=None): """ Stores a transition in replay memory. If the memory is full, the oldest entry is replaced. """ if not self._isfull(): self._memory.append(None) position = self._next_position_then_increment() old_priority = 0 if...
python
{ "resource": "" }
q253059
SumTree.move
validation
def move(self, external_index, new_priority): """ Change the priority of a leaf node """
python
{ "resource": "" }
q253060
SumTree._move
validation
def _move(self, index, new_priority): """ Change the priority of a leaf node. """ item, old_priority = self._memory[index] old_priority = old_priority or 0
python
{ "resource": "" }
q253061
SumTree._next_position_then_increment
validation
def _next_position_then_increment(self): """ Similar to position++. """ start = self._capacity - 1 position = start + self._position
python
{ "resource": "" }
q253062
SumTree._sample_with_priority
validation
def _sample_with_priority(self, p): """ Sample random element with priority greater than p. """ parent = 0 while True: left = 2 * parent + 1 if left >= len(self._memory): # parent points to a leaf node already. return parent...
python
{ "resource": "" }
q253063
SumTree.sample_minibatch
validation
def sample_minibatch(self, batch_size): """ Sample minibatch of size batch_size. """ pool_size = len(self) if pool_size == 0: return [] delta_p = self._memory[0] / batch_size chosen_idx = [] # if all priorities sum to ~0 choose randomly other...
python
{ "resource": "" }
q253064
PrioritizedReplay.update_batch
validation
def update_batch(self, loss_per_instance): """ Computes priorities according to loss. Args: loss_per_instance: """ if self.batch_indices is None: raise TensorForceError("Need to call get_batch before each update_batch call.") # if len(loss_per_in...
python
{ "resource": "" }
q253065
LearningAgent.import_experience
validation
def import_experience(self, experiences): """ Imports experiences. Args: experiences: """ if isinstance(experiences, dict): if self.unique_state: experiences['states'] = dict(state=experiences['states']) if self.unique_action:...
python
{ "resource": "" }
q253066
RemoteEnvironment.disconnect
validation
def disconnect(self): """ Ends our server tcp connection. """ # If we are not connected, return error.
python
{ "resource": "" }
q253067
MsgPackNumpyProtocol.recv
validation
def recv(self, socket_, encoding=None): """ Receives a message as msgpack-numpy encoded byte-string from the given socket object. Blocks until something was received. Args: socket_: The python socket object to use. encoding (str): The encoding to use for unpackin...
python
{ "resource": "" }
q253068
Game2048.is_action_available
validation
def is_action_available(self, action): """Determines whether action is available. That is, executing it would change the state. """
python
{ "resource": "" }
q253069
Game2048._is_action_available_left
validation
def _is_action_available_left(self, state): """Determines whether action 'Left' is available.""" # True if any field is 0 (empty) on the left of a tile or two tiles can # be merged. for row in range(4): has_empty = False for col in range(4): has_e...
python
{ "resource": "" }
q253070
Game2048.do_action
validation
def do_action(self, action): """Execute action, add a new tile, update the score & return the reward.""" temp_state = np.rot90(self._state, action) reward = self._do_action_left(temp_state)
python
{ "resource": "" }
q253071
Game2048._do_action_left
validation
def _do_action_left(self, state): """Executes action 'Left'.""" reward = 0 for row in range(4): # Always the rightmost tile in the current row that was already moved merge_candidate = -1 merged = np.zeros((4,), dtype=np.bool) for col in range(4)...
python
{ "resource": "" }
q253072
Game2048.add_random_tile
validation
def add_random_tile(self): """Adds a random tile to the grid. Assumes that it has empty fields.""" x_pos, y_pos = np.where(self._state == 0)
python
{ "resource": "" }
q253073
Game2048.print_state
validation
def print_state(self): """Prints the current state.""" def tile_string(value): """Concert value to string.""" if value > 0: return '% 5d' % (2 ** value,) return " " separator_line
python
{ "resource": "" }
q253074
Model.setup_saver
validation
def setup_saver(self): """ Creates the tf.train.Saver object and stores it in self.saver. """ if self.execution_type == "single": global_variables = self.get_variables(include_submodules=True, include_nontrainable=True) else: global_variables = self.global...
python
{ "resource": "" }
q253075
Model.setup_scaffold
validation
def setup_scaffold(self): """ Creates the tf.train.Scaffold object and assigns it to self.scaffold. Other fields of the Scaffold are generated automatically. """ if self.execution_type == "single": global_variables = self.get_variables(include_submodules=True, include...
python
{ "resource": "" }
q253076
Model.setup_hooks
validation
def setup_hooks(self): """ Creates and returns a list of hooks to use in a session. Populates self.saver_directory. Returns: List of hooks to use in a session. """ hooks = list() # Checkpoint saver hook if self.saver_spec is not None and (self.execution_type == ...
python
{ "resource": "" }
q253077
Model.create_atomic_observe_operations
validation
def create_atomic_observe_operations(self, states, actions, internals, terminal, reward, index): """ Returns the tf op to fetch when unbuffered observations are passed in. Args: states (any): One state (usually a value tuple) or dict of states if multiple states are expected. ...
python
{ "resource": "" }
q253078
Model.get_savable_components
validation
def get_savable_components(self): """ Returns the list of all of the components this model consists of that can be individually saved and restored. For instance the network or distribution. Returns: List of util.SavableComponent """
python
{ "resource": "" }
q253079
Model.save_component
validation
def save_component(self, component_name, save_path): """ Saves a component of this model to the designated location. Args: component_name: The component to save. save_path: The location to save to. Returns: Checkpoint path where the component was save...
python
{ "resource": "" }
q253080
Model.restore_component
validation
def restore_component(self, component_name, save_path): """ Restores a component's parameters from a save location. Args: component_name: The component to restore. save_path: The save location. """ component =
python
{ "resource": "" }
q253081
Model.get_component
validation
def get_component(self, component_name): """ Looks up a component by its name. Args: component_name: The name of the component to look up. Returns: The component for the provided name or None if there is no
python
{ "resource": "" }
q253082
DQFDAgent.import_demonstrations
validation
def import_demonstrations(self, demonstrations): """ Imports demonstrations, i.e. expert observations. Note that for large numbers of observations, set_demonstrations is more appropriate, which directly sets memory contents to an array an expects a different layout. Args: ...
python
{ "resource": "" }
q253083
PLE.states
validation
def states(self): """ Return the state space. Might include subdicts if multiple states are available simultaneously. Returns: dict of state properties (shape and type).
python
{ "resource": "" }
q253084
sanity_check_states
validation
def sanity_check_states(states_spec): """ Sanity checks a states dict, used to define the state space for an MDP. Throws an error or warns if mismatches are found. Args: states_spec (Union[None,dict]): The spec-dict to check (or None). Returns: Tuple of 1) the state space desc and 2) wheth...
python
{ "resource": "" }
q253085
sanity_check_actions
validation
def sanity_check_actions(actions_spec): """ Sanity checks an actions dict, used to define the action space for an MDP. Throws an error or warns if mismatches are found. Args: actions_spec (Union[None,dict]): The spec-dict to check (or None). Returns: Tuple of 1) the action space desc and 2...
python
{ "resource": "" }
q253086
make_game
validation
def make_game(): """Builds and returns an Extraterrestrial Marauders game.""" return ascii_art.ascii_art_to_game( GAME_ART, what_lies_beneath=' ', sprites=dict( [('P', PlayerSprite)] +
python
{ "resource": "" }
q253087
UpwardLaserBoltSprite._fly
validation
def _fly(self, board, layers, things, the_plot): """Handles the behaviour of visible bolts flying toward Marauders.""" # Disappear if we've hit a Marauder or a bunker. if (self.character in the_plot['bunker_hitters'] or
python
{ "resource": "" }
q253088
UpwardLaserBoltSprite._fire
validation
def _fire(self, layers, things, the_plot): """Launches a new bolt from the player.""" # We don't fire if the player fired another bolt just now.
python
{ "resource": "" }
q253089
DownwardLaserBoltSprite._fly
validation
def _fly(self, board, layers, things, the_plot): """Handles the behaviour of visible bolts flying toward the player.""" # Disappear if we've hit a bunker. if self.character in the_plot['bunker_hitters']: return self._teleport((-1, -1))
python
{ "resource": "" }
q253090
DownwardLaserBoltSprite._fire
validation
def _fire(self, layers, the_plot): """Launches a new bolt from a random Marauder.""" # We don't fire if another Marauder fired a bolt just now. if the_plot.get('last_marauder_shot') == the_plot.frame: return the_plot['last_marauder_shot'] = the_plot.frame # Which Marauder should fire the
python
{ "resource": "" }
q253091
DistributionModel.setup_components_and_tf_funcs
validation
def setup_components_and_tf_funcs(self, custom_getter=None): """ Creates and stores Network and Distribution objects. Generates and stores all template functions. """ # Create network before super-call, since non-empty internals_spec attribute (for RNN) is required subsequently. ...
python
{ "resource": "" }
q253092
DistributionModel.create_distributions
validation
def create_distributions(self): """ Creates and returns the Distribution objects based on self.distributions_spec. Returns: Dict of distributions according to self.distributions_spec. """ distributions = dict() for name in sorted(self.actions_spec): action = ...
python
{ "resource": "" }
q253093
Exploration.from_spec
validation
def from_spec(spec): """ Creates an exploration object from a specification dict. """ exploration = util.get_object( obj=spec,
python
{ "resource": "" }
q253094
Memory.from_spec
validation
def from_spec(spec, kwargs=None): """ Creates a memory from a specification dict. """ memory = util.get_object( obj=spec,
python
{ "resource": "" }
q253095
Queue.tf_retrieve_indices
validation
def tf_retrieve_indices(self, indices): """ Fetches experiences for given indices. Args: indices: Index tensor Returns: Batch of experiences """ states = dict() for name in sorted(self.states_memory): states[name] = tf.gather(params=self....
python
{ "resource": "" }
q253096
LineSearch.tf_initialize
validation
def tf_initialize(self, x_init, base_value, target_value, estimated_improvement): """ Initialization step preparing the arguments for the first iteration of the loop body. Args: x_init: Initial solution guess $x_0$. base_value: Value $f(x')$ at $x = x'$. targ...
python
{ "resource": "" }
q253097
LineSearch.tf_step
validation
def tf_step(self, x, iteration, deltas, improvement, last_improvement, estimated_improvement): """ Iteration loop body of the line search algorithm. Args: x: Current solution estimate $x_t$. iteration: Current iteration counter $t$. deltas: Current difference...
python
{ "resource": "" }
q253098
markdown
validation
def markdown(text, escape=True, **kwargs): """Render markdown formatted text to html. :param text: markdown formatted text content. :param escape: if set to False, all html tags will not be escaped.
python
{ "resource": "" }
q253099
BlockLexer.parse_lheading
validation
def parse_lheading(self, m): """Parse setext heading.""" self.tokens.append({ 'type': 'heading',
python
{ "resource": "" }