提交 4c134c7c 编写于 作者: C caoying03

add comments.

上级 30725a07
...@@ -190,7 +190,7 @@ public: ...@@ -190,7 +190,7 @@ public:
std::vector<int> ids; std::vector<int> ids;
/** /**
* @brief idsProb, log probability of each generated words. * @brief idsProb, log probability of each generated word.
*/ */
std::vector<real> idsProb; std::vector<real> idsProb;
...@@ -472,16 +472,42 @@ private: ...@@ -472,16 +472,42 @@ private:
void copyDataOutlinkFrame(size_t machineCur); void copyDataOutlinkFrame(size_t machineCur);
/* /*
* @brief In generation, if the layer group has more than 1 outlink, outlinks * @brief In generation, if the layer group has more than 1 outlink, outlink
* except the first one are data outlinks. This function creates the data * except the first one is a data outlink. In RecurrentLayerGroup, each time
* outlinks. * step is a separate Network, outputs of a layer inside the
* @note In beam search, only one generated sequence with the hightest log * RecurrentLayerGroup are stored in separate Arguments. If one layer is
* probabilites are retained. * specified as an outlink of RecurrentLayerGroup. This function will
* collect outputs in each time step of each generated sequence which are
* dispersed in separate Arguments to form a new single Argument as output of
* RecurrentLayerGroup.
*/ */
void createDataOutlink(); void createDataOutlink();
/*
* @brief decide to select how many rows from the Matrix stored the forward
* pass results from a start position.
*
* @param isSeq: a flag indicating whetehr the layer to be output of the
* RecurrentGradientMachine is a sequence or not
* @param outArgs: all of the the returned Arguments of the forward pass
* during the generation process.
* @param copySize: the returned result, number of rows to select from the
* Matrix stored the forward pass results from a start position.
*/
void createDataOutlinkCopySizeInfo(bool isSeq, void createDataOutlinkCopySizeInfo(bool isSeq,
std::vector<Argument>& outArgs, std::vector<Argument>& outArgs,
std::vector<int>& copySize); std::vector<int>& copySize);
/*
* @brief decide index of the start row for each time step of a generated
* sequence in Matrix stored the entire beam search batch's forward pass
* results.
*
* @param isSeq: a flag indicating whetehr the layer to be output of the
* RecurrentGradientMachine is a sequence or not
* @param outArgs: all of the the returned Arguments of the forward pass
* during the generation process.
*/
void createDataOutlinkSelRowsInfo(bool isSeq, std::vector<Argument>& outArgs); void createDataOutlinkSelRowsInfo(bool isSeq, std::vector<Argument>& outArgs);
/* /*
......
...@@ -352,8 +352,8 @@ void Argument::concat(const std::vector<Argument>& args, ...@@ -352,8 +352,8 @@ void Argument::concat(const std::vector<Argument>& args,
CHECK_GE(args.size(), static_cast<size_t>(endPos - startPos)); CHECK_GE(args.size(), static_cast<size_t>(endPos - startPos));
for (int j = startPos; j < endPos; ++j) { for (int j = startPos; j < endPos; ++j) {
const Argument& arg = args[j - startPos]; const Argument& arg = args[j - startPos];
CHECK_EQ(arg.dataId, dataId) << "Arguments in concat should have the " CHECK_EQ(arg.dataId, dataId) << "Arguments to concatenate should have "
<< "same dataId"; << "the same dataId.";
const int srcStartRow = selectRows[j]; const int srcStartRow = selectRows[j];
copyArg(in, arg.in, desStartRow, srcStartRow, copySize[i], useGpu); copyArg(in, arg.in, desStartRow, srcStartRow, copySize[i], useGpu);
copyArg(value, arg.value, desStartRow, srcStartRow, copySize[i], useGpu); copyArg(value, arg.value, desStartRow, srcStartRow, copySize[i], useGpu);
......
...@@ -1375,9 +1375,9 @@ def simple_attention(encoded_sequence, ...@@ -1375,9 +1375,9 @@ def simple_attention(encoded_sequence,
weight=attention_weight, weight=attention_weight,
input=encoded_sequence, input=encoded_sequence,
name='%s_scaling' % name) name='%s_scaling' % name)
return pooling_layer( return pooling_layer(
input=scaled, pooling_type=SumPooling(), input=scaled, pooling_type=SumPooling(), name="%s_pooling" % name)
name="%s_pooling" % name), attention_weight
def inputs(layers, *args): def inputs(layers, *args):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册