當前位置: 首頁>>代碼示例>>Python>>正文


Python functions.hstack方法代碼示例

本文整理匯總了Python中chainer.functions.hstack方法的典型用法代碼示例。如果您正苦於以下問題:Python functions.hstack方法的具體用法?Python functions.hstack怎麽用?Python functions.hstack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在chainer.functions的用法示例。


在下文中一共展示了functions.hstack方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: forward

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def forward(self, x, y):
        y1 = F.hstack((x, y))
        return y1 
開發者ID:pfnet-research,項目名稱:chainer-compiler,代碼行數:5,代碼來源:Hstack.py

示例2: forward

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def forward(self, inputs, device):
        y = functions.hstack(inputs)
        return y, 
開發者ID:chainer,項目名稱:chainer,代碼行數:5,代碼來源:test_hstack.py

示例3: forward_expected

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def forward_expected(self, inputs):
        y = numpy.hstack(inputs)
        return y, 
開發者ID:chainer,項目名稱:chainer,代碼行數:5,代碼來源:test_hstack.py

示例4: check_value_check

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def check_value_check(self):
        if self.valid:
            # Check if it throws nothing
            functions.hstack(self.xs)
        else:
            with self.assertRaises(type_check.InvalidType):
                functions.hstack(self.xs) 
開發者ID:chainer,項目名稱:chainer,代碼行數:9,代碼來源:test_hstack.py

示例5: flatten_graph_data

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def flatten_graph_data(adj, x):
    return F.hstack((F.reshape(adj,[adj.shape[0], -1]),
                     F.reshape(x, [x.shape[0], -1]))) 
開發者ID:pfnet-research,項目名稱:graph-nvp,代碼行數:5,代碼來源:utils.py

示例6: greedy_actions

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def greedy_actions(self):
        actions = []

        for branch in self.branches:
            actions.append(branch.q_values.array.argmax(axis=1).reshape(-1, 1))

        return F.hstack(actions) 
開發者ID:minerllabs,項目名稱:baselines,代碼行數:9,代碼來源:branched_action_values.py

示例7: max

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def max(self):
        chosen_q_values = []

        for branch in self.branches:
            chosen_q_values.append(branch.max.reshape(-1, 1))

        return F.hstack(chosen_q_values) 
開發者ID:minerllabs,項目名稱:baselines,代碼行數:9,代碼來源:branched_action_values.py

示例8: evaluate_actions

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def evaluate_actions(self, actions):
        branch_q_values = []

        for i, branch in enumerate(self.branches):
            branch_actions = actions[:, i]
            branch_q_values.append(branch.evaluate_actions(
                branch_actions).reshape(-1, 1))

        return F.hstack(branch_q_values) 
開發者ID:minerllabs,項目名稱:baselines,代碼行數:11,代碼來源:branched_action_values.py

示例9: calculate_all_attentions

# 需要導入模塊: from chainer import functions [as 別名]
# 或者: from chainer.functions import hstack [as 別名]
def calculate_all_attentions(self, hs, ys):
        """Calculate all of attentions.

        Args:
            hs (list of chainer.Variable | N-dimensional array):
                Input variable from encoder.
            ys (list of chainer.Variable | N-dimensional array):
                Input variable of decoder.

        Returns:
            chainer.Variable: List of attention weights.

        """
        # prepare input and output word sequences with sos/eos IDs
        eos = self.xp.array([self.eos], "i")
        sos = self.xp.array([self.sos], "i")
        ys_in = [F.concat([sos, y], axis=0) for y in ys]
        ys_out = [F.concat([y, eos], axis=0) for y in ys]

        # padding for ys with -1
        # pys: utt x olen
        pad_ys_in = F.pad_sequence(ys_in, padding=self.eos)
        pad_ys_out = F.pad_sequence(ys_out, padding=-1)

        # get length info
        olength = pad_ys_out.shape[1]

        # initialization
        c_list = [None]  # list of cell state of each layer
        z_list = [None]  # list of hidden state of each layer
        for _ in six.moves.range(1, self.dlayers):
            c_list.append(None)
            z_list.append(None)
        att_w = None
        att_ws = []
        self.att.reset()  # reset pre-computation of h

        # pre-computation of embedding
        eys = self.embed(pad_ys_in)  # utt x olen x zdim
        eys = F.separate(eys, axis=1)

        # loop for an output sequence
        for i in six.moves.range(olength):
            att_c, att_w = self.att(hs, z_list[0], att_w)
            ey = F.hstack((eys[i], att_c))  # utt x (zdim + hdim)
            z_list, c_list = self.rnn_forward(ey, z_list, c_list, z_list, c_list)
            att_ws.append(att_w)  # for debugging

        att_ws = F.stack(att_ws, axis=1)
        att_ws.to_cpu()

        return att_ws.data 
開發者ID:espnet,項目名稱:espnet,代碼行數:54,代碼來源:decoders.py


注:本文中的chainer.functions.hstack方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。