예제 #1
0
 def __call__(self, annotion_list, back_word_list, p):
     """
     Calculate the annotion and back word value
     :param annotion_list:
     :param back_word_list:
     :param p: hidden value
     :return:
     """
     batch_size = p.data.shape[0]
     exponential_list = []
     sum_exponential = XP.fzeros((batch_size, 1))
     # Calculate the total value list and total value
     # Prepare the Convoluation
     for annotion, back_word in zip(annotion_list, back_word_list):
         weight = functions.tanh(
             self.annotion_weight(annotion) + self.back_weight(back_word) +
             self.pw(p))
         exponential = functions.exp(self.weight_exponential(weight))
         exponential_list.append(exponential)
         sum_exponential += exponential
     ZEROS = XP.fzeros((batch_size, self.hidden_size))
     annotion_value = ZEROS
     back_word_value = ZEROS
     # Calculate the Convolution Value each annotion and back word
     for annotion, back_word, exponential in zip(annotion_list,
                                                 back_word_list,
                                                 exponential_list):
         exponential /= sum_exponential
         annotion_value += functions.reshape(
             functions.batch_matmul(annotion, exponential),
             (batch_size, self.hidden_size))
         back_word_value += functions.reshape(
             functions.batch_matmul(back_word, exponential),
             (batch_size, self.hidden_size))
     return annotion_value, back_word_value
예제 #2
0
 def __init__(self, data_model):
     """
     Iniital Setting
     :param data_model: Setting Slack Model. Slack Model has the a lot of paramater
     """
     self.slack_channel = data_model.slack_channel
     self.data = ""
     self.parameter = data_model.parameter_dict
     self.model_name = "../model_word_match/ChainerDialogue"
     self.generation_limit = 200
     """
     We confirm channel number
     https://api.slack.com/methods/channels.list
     """
     self.chan = data_model.chan
     self.usr = data_model.user
     self.mecab_dict = data_model.mecab_dict
     self.Mecab = MeCab.Tagger("-Owakati -d %s" % self.mecab_dict)
     XP.set_library(False, 0)
     self.XP = XP
     wn_summary_list = APP_ROOT + '/../Data/wn_total_summary_51519_limit05_out_put_list.txt'
     self.input_module = InputFileCython(wn_summary_list)
     self.input_module.input_special_format_file()
     file_list = self.input_module.get_file_data()
     self.class_word_vector = self.__make_class_word_vector(file_list)
     self.sqlite_twitter_summary = SqliteTwitterSummary(
         self.class_word_vector)
     self.word_class_dict = self.sqlite_twitter_summary.make_class_word_dict(
     )
     self.word_class = ""
     self.multi_train_execute = ExecuteAttentionDialogue()
     self.elastic_search = GetAnswer()
 def __call__(self, annotion_list, back_word_list, p):
     """
     Calculate the annotion and back word value
     :param annotion_list:
     :param back_word_list:
     :param p: hidden value
     :return:
     """
     batch_size = p.data.shape[0]
     exponential_list = []
     sum_exponential = XP.fzeros((batch_size, 1))
     # Calculate the total value list and total value
     # Prepare the Convoluation
     for annotion, back_word in zip(annotion_list, back_word_list):
         weight = functions.tanh(self.annotion_weight(annotion) + self.back_weight(back_word) + self.pw(p))
         exponential = functions.exp(self.weight_exponential(weight))
         exponential_list.append(exponential)
         sum_exponential += exponential
     ZEROS = XP.fzeros((batch_size, self.hidden_size))
     annotion_value = ZEROS
     back_word_value = ZEROS
     # Calculate the Convolution Value each annotion and back word
     for annotion, back_word, exponential in zip(annotion_list, back_word_list, exponential_list):
         exponential /= sum_exponential
         annotion_value += functions.reshape(functions.batch_matmul(annotion, exponential), (batch_size, self.hidden_size))
         back_word_value += functions.reshape(functions.batch_matmul(back_word, exponential), (batch_size, self.hidden_size))
     return annotion_value, back_word_value
 def __init__(self, data_model):
     """
     Iniital Setting
     :param data_model: Setting Slack Model. Slack Model has the a lot of paramater
     """
     self.slack_channel = data_model.slack_channel
     self.data = ""
     self.parameter = data_model.parameter_dict
     self.model_name = "../model/ChainerDialogue"
     self.generation_limit = 200
     """
     We confirm channel number
     https://api.slack.com/methods/channels.list
     """
     self.chan = data_model.chan
     self.usr = data_model.user
     self.mecab_dict = data_model.mecab_dict
     self.Mecab = MeCab.Tagger("-Owakati -d %s" % self.mecab_dict)
     XP.set_library(False, 0)
     self.XP = XP
 def __init__(self, data_model):
     """
     Iniital Setting
     :param data_model: Setting Slack Model. Slack Model has the a lot of paramater
     """
     self.slack_channel = data_model.slack_channel
     self.data = ""
     self.parameter = data_model.parameter_dict
     self.model_name = "../model/ChainerDialogue"
     self.generation_limit = 200
     """
     We confirm channel number
     https://api.slack.com/methods/channels.list
     """
     self.chan = data_model.chan
     self.usr = data_model.user
     self.mecab_dict = data_model.mecab_dict
     self.Mecab = MeCab.Tagger("-Owakati -d %s" % self.mecab_dict)
     XP.set_library(False, 0)
     self.XP = XP
 def __init__(self, parameter_dict):
     """
     Initial Paramater Setting
     :param parameter_dict: setting the a varity of paramater
     If you use gpu, you setting the bellow paramater
         XP.set_library(True, {your gpu id})
     """
     self.parameter_dict = parameter_dict
     self.source = parameter_dict["source"]
     self.target = parameter_dict["target"]
     self.test_source = parameter_dict["test_source"]
     self.test_target = parameter_dict["test_target"]
     self.vocab = parameter_dict["vocab"]
     self.embed = parameter_dict["embed"]
     self.hidden = parameter_dict["hidden"]
     self.epoch = parameter_dict["epoch"]
     self.minibatch = parameter_dict["minibatch"]
     self.generation_limit = parameter_dict["generation_limit"]
     self.word2vec = parameter_dict["word2vec"]
     self.word2vecFlag = parameter_dict["word2vecFlag"]
     self.model = parameter_dict["model"]
     self.attention_dialogue = parameter_dict["attention_dialogue"]
     XP.set_library(False, 0)
     self.XP = XP
 def __init__(self, parameter_dict):
     """
     Initial Paramater Setting
     :param parameter_dict: setting the a varity of paramater
     If you use gpu, you setting the bellow paramater
         XP.set_library(True, {your gpu id})
     """
     self.parameter_dict = parameter_dict
     self.source = parameter_dict["source"]
     self.target = parameter_dict["target"]
     self.test_source = parameter_dict["test_source"]
     self.test_target = parameter_dict["test_target"]
     self.vocab = parameter_dict["vocab"]
     self.embed = parameter_dict["embed"]
     self.hidden = parameter_dict["hidden"]
     self.epoch = parameter_dict["epoch"]
     self.minibatch = parameter_dict["minibatch"]
     self.generation_limit = parameter_dict["generation_limit"]
     self.word2vec = parameter_dict["word2vec"]
     self.word2vecFlag = parameter_dict["word2vecFlag"]
     self.model = parameter_dict["model"]
     self.attention_dialogue = parameter_dict["attention_dialogue"]
     XP.set_library(False, 0)
     self.XP = XP