Пример #1
0
 def observe(self, observation):
     self.episode_done = observation['episode_done']
     # shallow copy observation (deep copy can be expensive)
     obs = observation.copy()
     obs['text2vec'] = maintain_dialog_history(
         self.history, obs,
         historyLength=self.opt['history_length'],
         useReplies=self.opt['history_replies'],
         dict=self.dict, useStartEndIndices=False)
     self.observation = obs
     return obs
Пример #2
0
 def observe(self, observation):
     self.episode_done = observation['episode_done']
     # shallow copy observation (deep copy can be expensive)
     obs = observation.copy()
     obs['text2vec'] = maintain_dialog_history(
         self.history, obs,
         historyLength=self.opt['history_length'],
         useReplies=self.opt['history_replies'],
         dict=self.dict, useStartEndIndices=False)
     self.observation = obs
     return obs
Пример #3
0
 def observe(self, observation):
     """Save observation for act.
     If multiple observations are from the same episode, concatenate them.
     """
     self.episode_done = observation['episode_done']
     # shallow copy observation (deep copy can be expensive)
     obs = observation.copy()
     batch_idx = self.opt.get('batchindex', 0)
     obs['text2vec'] = maintain_dialog_history(
         self.history,
         obs,
         reply=self.answers[batch_idx],
         historyLength=self.opt['history_length'],
         useReplies=self.opt['history_replies'],
         dict=self.dict)
     self.observation = obs
     self.answers[batch_idx] = None
     return obs
Пример #4
0
 def observe(self, observation):
     """Save observation for act.
     If multiple observations are from the same episode, concatenate them.
     """
     # shallow copy observation (deep copy can be expensive)
     obs = observation.copy()
     if not obs.get('preprocessed', False):
         obs['text2vec'] = maintain_dialog_history(
             self.history, obs,
             reply=self.answers[self.batch_idx],
             historyLength=self.truncate,
             useReplies=self.opt.get('history_replies'),
             dict=self.dict,
             useStartEndIndices=False)
     else:
         obs['text2vec'] = deque(obs['text2vec'], maxlen=self.truncate)
     self.observation = obs
     self.answers[self.batch_idx] = None
     return obs
Пример #5
0
 def observe(self, observation):
     """Save observation for act.
     If multiple observations are from the same episode, concatenate them.
     """
     self.episode_done = observation['episode_done']
     # shallow copy observation (deep copy can be expensive)
     obs = observation.copy()
     batch_idx = self.opt.get('batchindex', 0)
     
     obs['text'] = '\n'.join(maintain_dialog_history(
         self.history, obs,
         reply=self.answers[batch_idx] if self.answers[batch_idx] is not None else '',
         historyLength=self.opt['history_length'],
         useReplies=self.opt['history_replies'],
         dict=None, useStartEndIndices=False))
     
     self.observation = obs
     self.answers[batch_idx] = None
     return obs
Пример #6
0
    def observe(self, observation):
        """Save observation for act.
        If multiple observations are from the same episode, concatenate them.
        """
        self.episode_done = observation['episode_done']
        # shallow copy observation (deep copy can be expensive)
        obs = observation.copy()
        batch_idx = self.opt.get('batchindex', 0)

        obs['text'] = (maintain_dialog_history(
        self.history, obs,
        reply=self.answers[batch_idx] if self.answers[batch_idx] is not None else '',
        historyLength=self.opt['mem_size'] + 1,
        useReplies=self.opt['history_replies'],
        dict=self.dict, useStartEndIndices=False, splitSentences=True))

        self.observation = obs
        self.answers[batch_idx] = None
        return obs
Пример #7
0
 def observe(self, observation):
     """Save observation for act.
     If multiple observations are from the same episode, concatenate them.
     """
     # shallow copy observation (deep copy can be expensive)
     obs = observation.copy()
     batch_idx = self.opt.get('batchindex', 0)
     if not obs.get('preprocessed', False):
         obs['text2vec'] = maintain_dialog_history(
             self.history, obs,
             reply=self.answers[batch_idx],
             historyLength=self.opt['history_length'],
             useReplies=self.opt['history_replies'],
             dict=self.dict,
             useStartEndIndices=False)
     else:
         obs['text2vec'] = deque(obs['text2vec'], self.opt['history_length'])
     self.observation = obs
     self.answers[batch_idx] = None
     return obs
Пример #8
0
 def observe(self, observation):
     """Save observation for act.
     If multiple observations are from the same episode, concatenate them.
     """
     # shallow copy observation (deep copy can be expensive)
     obs = observation.copy()
     obs['persona'], obs['text'] = self.extract_persona(obs.get('text', ''))
     # obs['persona'], _ = self.extract_persona(obs.get('text', ''))
     batch_idx = self.opt.get('batchindex', 0)
     if not obs.get('preprocessed', False):
         obs['text2vec'] = maintain_dialog_history(
             self.history,
             obs,
             reply=self.answers[batch_idx],
             historyLength=self.truncate,
             useReplies=self.opt['include_labels'],
             dict=self.dict,
             useStartEndIndices=True)
     else:
         obs['text2vec'] = deque(obs['text2vec'], maxlen=self.truncate)
     self.observation = obs
     self.answers[batch_idx] = None
     return obs