def dumps(self): return u'group stats:\n{}\nsample counts:\n{}'.format( indent('\n'.join('{}: {}'.format(trace.dumps(), label) for label, trace in self._group_traces.items())), indent('\n'.join('{:<5}: {}'.format(c, k) for k, c in self._group_counts.items())), )
def dumps(self): action = self.experience.action return u'utterance: {}\nfields:\n{}\nstate:\n{}\njustification:\n{}\naction:\n{}\nreward: {}\nmetadata: {}'.format( self.experience.state.utterance, indent(str(self.experience.state.fields)), indent(self._state_str), indent(action.justification.dumps() if action. justification else 'None'), indent(str(action)), self.experience.undiscounted_reward, self.experience.metadata, )
def dumps(self): items = [] for program, prob in self.program_probs: select_marker = '>' if program == self.selected else ' ' s = '{} [{:.3f}] {}'.format(select_marker, prob, program) items.append(s) probs_str = '\n'.join(items) elems_str = '\n'.join(str(elem) for elem in self.element_set.elements) state_value = None if self.state_value is None \ else round(self.state_value, 3) return 'state value: {}\nprogram probs:\n{}\nelement set:\n{}'.format( state_value, indent(probs_str), indent(elems_str))
def dumps(self): weighted_episodes = zip(self._scored_episodes, self._importance_weights, self._model_probs) weighted_episodes.sort(key=lambda x: -x[1]) # sort by importance weight episodes_str = u'\n\n'.join( u'===== EPISODE {i} (importance weight = {importance:.3f}, model prob = {model:.3f}) =====\n\n{episode}' .format(i=i, importance=importance, model=model_prob, episode=indent(MiniWoBEpisodeTrace(ep).dumps())) for i, (ep, importance, model_prob) in enumerate(weighted_episodes) ) return u'Replay buffer:\n{samples}\n\nImportance weights:\n{weights}\n\n{episodes}'.format( samples=indent(self._sample_trace.dumps() if self._sample_trace else None), weights=sorted([round(w, 3) for w in self._importance_weights], reverse=True), episodes=episodes_str, )
def dumps(self): items = [] for i, x in enumerate(self._justifications): items.append('step {} / {}:'.format(i + 1, len(self._justifications))) items.append(indent(x.dumps())) return '\n'.join(items)
def __str__(self): s = "" for i, queue in enumerate(self._queues): s += "Queue {} (size={})\n".format(i, len(queue)) s += indent(str(queue)) s += "\n" return s
def dumps(self): values_attn_str = self._pretty_string( self._query_entries, self._fields_attentions[0]) values_attn_str2 = self._pretty_string( self._query_entries, self._fields_attentions[1]) elems_str = self._pretty_string(self.dom_elements, self.element_probs) type_str = self._pretty_string( ["CLICK", "TYPE"], self._click_or_type_probs) values_str = self._pretty_string( self._type_values, self._type_value_probs) return (u"elements:\n{}\nvalue attentions:\n{}\n" u"value attentions 2:\n{}\naction type:\n{}\n" u"typed:\n{}\nstate value: {:.3f}").format( indent(elems_str), indent(values_attn_str), indent(values_attn_str2), indent(type_str), indent(values_str), self._state_value)
def __unicode__(self): ex = self.example base_vocab = self.dynamic_vocab.base_vocab word_to_copy = self.dynamic_vocab.word_to_copy_token copy_idx = lambda copy_token: base_vocab.copy_token_to_index(copy_token ) def render(tokens): new_tokens = [] for w in tokens: #w_lower = w.lower() copy_idx_str = str(copy_idx( word_to_copy[w])) if w in word_to_copy else '?' in_base_str = '' if w in base_vocab else '*' try: v = u'{}[{}]{}'.format( w.decode('utf-8', 'ignore'), copy_idx_str.decode('utf-8', 'ignore'), in_base_str.decode('utf-8', 'ignore')) except: print 'ran into error skipping ...' v = u'' new_tokens.append(v) return u' '.join(new_tokens) try: example_str = u'INPUT:\n{}\nTARGET: {}'.format( '\n'.join([render(words) for words in ex.input_words]), render(ex.target_words)) except: example_str = u'INPUT:\n{}\nTARGET: {}'.format( '\n'.join([render(words) for words in ex.input_words]), render(ex.target_words)) try: return u'\n'.join( [example_str, indent(unicode(self.decoder_trace))]) except: return '\n'.join( [example_str, indent(unicode(self.decoder_trace))])
def __unicode__(self): ex = self.example base_vocab = self.dynamic_vocab.base_vocab word_to_copy = self.dynamic_vocab.word_to_copy_token copy_idx = lambda copy_token: base_vocab.copy_token_to_index(copy_token) def render(tokens): new_tokens = [] for w in tokens: #w_lower = w.lower() copy_idx_str = str(copy_idx(word_to_copy[w])) if w in word_to_copy else '?' in_base_str = '' if w in base_vocab else '*' v = u'{}[{}]{}'.format(w, copy_idx_str, in_base_str) new_tokens.append(v) return u' '.join(new_tokens) example_str = u'INPUT:\n{}\nTARGET: {}'.format('\n'.join([render(words) for words in ex.input_words]), render(ex.target_words)) return u'\n'.join([example_str, indent(unicode(self.decoder_trace))])