rasa/core/policies/embedding_policy.py
def persist(self, path: Text) -> None:
        """Persists the policy to a storage."""

        if self.session is None:
            warnings.warn("Method `persist(...)` was called "
                          "without a trained model present. "
                          "Nothing to persist then!")
            return

        self.featurizer.persist(path)

        meta = {"priority": self.priority}

        meta_file = os.path.join(path, 'embedding_policy.json')
        utils.dump_obj_as_json_to_file(meta_file, meta)

        file_name = 'tensorflow_embedding.ckpt'
        checkpoint = os.path.join(path, file_name)
        utils.create_dir_for_file(checkpoint)

        with self.graph.as_default():
            self._persist_tensor('intent_placeholder',
                                 self.a_in)
            self._persist_tensor('action_placeholder',
                                 self.b_in)
            self._persist_tensor('slots_placeholder',
                                 self.c_in)
            self._persist_tensor('prev_act_placeholder',
                                 self.b_prev_in)
            self._persist_tensor('dialogue_len',
                                 self._dialogue_len)
            self._persist_tensor('x_for_no_intent',
                                 self._x_for_no_intent_in)
            self._persist_tensor('y_for_no_action',
                                 self._y_for_no_action_in)
            self._persist_tensor('y_for_action_listen',
                                 self._y_for_action_listen_in)

            self._persist_tensor('similarity_op', self.sim_op)

            self._persist_tensor('alignment_history',
                                 self.alignment_history)

            self._persist_tensor('user_embed', self.user_embed)
            self._persist_tensor('bot_embed', self.bot_embed)
            self._persist_tensor('slot_embed', self.slot_embed)
            self._persist_tensor('dial_embed', self.dial_embed)

            self._persist_tensor('rnn_embed', self.rnn_embed)
            self._persist_tensor('attn_embed', self.attn_embed)
            self._persist_tensor('copy_attn_debug', self.copy_attn_debug)

            self._persist_tensor('all_time_masks', self.all_time_masks)

            saver = tf.train.Saver()
            saver.save(self.session, checkpoint)

        encoded_actions_file = os.path.join(
            path, file_name + ".encoded_all_actions.pkl")
        with open(encoded_actions_file, 'wb') as f:
            pickle.dump(self.encoded_all_actions, f)

        tf_config_file = os.path.join(path, file_name + ".tf_config.pkl")
        with open(tf_config_file, 'wb') as f:
            pickle.dump(self._tf_config, f)
Persists the policy to a storage.
Persists the policy to a storage.
Persists the policy to a storage .
def persist(self, path: Text) -> None:
        if self.session is None:
            warnings.warn("Method `persist(...)` was called "
                          "without a trained model present. "
                          "Nothing to persist then!")
            return
        self.featurizer.persist(path)
        meta = {"priority": self.priority}
        meta_file = os.path.join(path, 'embedding_policy.json')
        utils.dump_obj_as_json_to_file(meta_file, meta)
        file_name = 'tensorflow_embedding.ckpt'
        checkpoint = os.path.join(path, file_name)
        utils.create_dir_for_file(checkpoint)
        with self.graph.as_default():
            self._persist_tensor('intent_placeholder',
                                 self.a_in)
            self._persist_tensor('action_placeholder',
                                 self.b_in)
            self._persist_tensor('slots_placeholder',
                                 self.c_in)
            self._persist_tensor('prev_act_placeholder',
                                 self.b_prev_in)
            self._persist_tensor('dialogue_len',
                                 self._dialogue_len)
            self._persist_tensor('x_for_no_intent',
                                 self._x_for_no_intent_in)
            self._persist_tensor('y_for_no_action',
                                 self._y_for_no_action_in)
            self._persist_tensor('y_for_action_listen',
                                 self._y_for_action_listen_in)
            self._persist_tensor('similarity_op', self.sim_op)
            self._persist_tensor('alignment_history',
                                 self.alignment_history)
            self._persist_tensor('user_embed', self.user_embed)
            self._persist_tensor('bot_embed', self.bot_embed)
            self._persist_tensor('slot_embed', self.slot_embed)
            self._persist_tensor('dial_embed', self.dial_embed)
            self._persist_tensor('rnn_embed', self.rnn_embed)
            self._persist_tensor('attn_embed', self.attn_embed)
            self._persist_tensor('copy_attn_debug', self.copy_attn_debug)
            self._persist_tensor('all_time_masks', self.all_time_masks)
            saver = tf.train.Saver()
            saver.save(self.session, checkpoint)
        encoded_actions_file = os.path.join(
            path, file_name + ".encoded_all_actions.pkl")
        with open(encoded_actions_file, 'wb') as f:
            pickle.dump(self.encoded_all_actions, f)
        tf_config_file = os.path.join(path, file_name + ".tf_config.pkl")
        with open(tf_config_file, 'wb') as f:
            pickle.dump(self._tf_config, f)
def persist ( self , path : Text ) -> None : if self . session is None : warnings . warn ( "Method `persist(...)` was called " "without a trained model present. " "Nothing to persist then!" ) return self . featurizer . persist ( path ) meta = { "priority" : self . priority } meta_file = os . path . join ( path , 'embedding_policy.json' ) utils . dump_obj_as_json_to_file ( meta_file , meta ) file_name = 'tensorflow_embedding.ckpt' checkpoint = os . path . join ( path , file_name ) utils . create_dir_for_file ( checkpoint ) with self . graph . as_default ( ) : self . _persist_tensor ( 'intent_placeholder' , self . a_in ) self . _persist_tensor ( 'action_placeholder' , self . b_in ) self . _persist_tensor ( 'slots_placeholder' , self . c_in ) self . _persist_tensor ( 'prev_act_placeholder' , self . b_prev_in ) self . _persist_tensor ( 'dialogue_len' , self . _dialogue_len ) self . _persist_tensor ( 'x_for_no_intent' , self . _x_for_no_intent_in ) self . _persist_tensor ( 'y_for_no_action' , self . _y_for_no_action_in ) self . _persist_tensor ( 'y_for_action_listen' , self . _y_for_action_listen_in ) self . _persist_tensor ( 'similarity_op' , self . sim_op ) self . _persist_tensor ( 'alignment_history' , self . alignment_history ) self . _persist_tensor ( 'user_embed' , self . user_embed ) self . _persist_tensor ( 'bot_embed' , self . bot_embed ) self . _persist_tensor ( 'slot_embed' , self . slot_embed ) self . _persist_tensor ( 'dial_embed' , self . dial_embed ) self . _persist_tensor ( 'rnn_embed' , self . rnn_embed ) self . _persist_tensor ( 'attn_embed' , self . attn_embed ) self . _persist_tensor ( 'copy_attn_debug' , self . copy_attn_debug ) self . _persist_tensor ( 'all_time_masks' , self . all_time_masks ) saver = tf . train . Saver ( ) saver . save ( self . session , checkpoint ) encoded_actions_file = os . path . join ( path , file_name + ".encoded_all_actions.pkl" ) with open ( encoded_actions_file , 'wb' ) as f : pickle . dump ( self . encoded_all_actions , f ) tf_config_file = os . path . join ( path , file_name + ".tf_config.pkl" ) with open ( tf_config_file , 'wb' ) as f : pickle . dump ( self . _tf_config , f )
Persists the policy to a storage.
Persists the policy to a storage .
"""Persists the policy to a storage."""
self
path
Text