You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
############################ScoreModel#############################
import paddle as paddle
import paddle.fluid as fluid
import paddle.fluid.layers as layers
Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the API,FAQ,Github Issue and AI community to get the answer.Have a nice day!
Since you haven't replied for more than a year, we have closed this issue/pr.
If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up.
由于您超过一年未回复,我们将关闭这个issue/pr。
若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。
版本、环境信息:
1)PaddlePaddle版本:1.7.1
3)GPU:P40
4)系统环境:Linux yq01-inf-nmg01-hlan1.yq01.baidu.com 3.10.0_3-0-0-7 Support numpy dense #207 SMP Wed Jul 26 13:22:55 CST 2017 x86_64 x86_64 x86_64 GNU/Linux
训练信息
1)单机单卡
2)显存信息
3)Operator信息
复现信息:如为报错,请给出复现环境、复现步骤
问题描述:请详细描述您的问题,同步贴出报错信息、日志、可复现的代码片段
`#########################################################
Embedding + MatchMatrix + CNN
############################ScoreModel#############################
import paddle as paddle
import paddle.fluid as fluid
import paddle.fluid.layers as layers
def EmbeddingLayer(input_ids, conf, name="Embedding"):
num_voc = conf['num_voc']
num_emb = conf['num_emb']
emb = layers.embedding(input=input_ids,
size=[num_voc, num_emb],
param_attr = fluid.ParamAttr(name=name, learning_rate=0.5),
padding_idx = 0)
return emb
def ConvPoolLayer(input_matrix, config, name='ConvPoolLayer'):
"""Convolution Layer."""
num_filters = config['num_filters']
filter_size = config['filter_size']
def Matrix_ExactMatch(x_ids, y_ids):
"""Matrix based on exact match."""
x_ids_expand = layers.expand(x_ids, [1, 1, y_ids.shape[1]])
y_ids_expand = layers.expand(y_ids, [1, 1, x_ids.shape[1]])
match_matrix = layers.equal(x_ids_expand, layers.transpose(y_ids_expand, [0, 2, 1]))
match_matrix = layers.cast(match_matrix, 'float32')
return match_matrix
def Matrix_EmbDot(x_emb, y_emb):
"""Matrix based on embeddings"""
match_matrix = layers.matmul(x_emb, y_emb, transpose_y = True)
return match_matrix
def Matrix_LSTM(x_emb, y_emb, x_mask, y_mask, config):
"""Matrix based on LSTM representations."""
RnnCell = fluid.layers.LSTMCell(hidden_size = config['LSTM_n_hidden'],
param_attr = fluid.ParamAttr(name = 'RnnCell.w'),
bias_attr = fluid.ParamAttr(name = 'RnnCell.b'),
name = "RnnCell")
def CNN_Layer(match_matrix, x_mask, y_mask, config):
"""CNN & topk & LSTM."""
x_mask = layers.unsqueeze(x_mask, axes = [1, 3])
y_mask = layers.unsqueeze(y_mask, axes = [1, 2])
conv_pool_1 = ConvPoolLayer(input_matrix = match_matrix,
config = config['ConvPoolConfig'],
name = 'conv_pool')
def Matrix_Layer(x_ids, y_ids, x_emb, y_emb, x_mask, y_mask, config):
"""Construct matching matrix."""
if "ExeactMatch" in config['match_matrix_type']:
matrix_ExeactMatch=Matrix_ExactMatch(x_ids, y_ids)
##################################### RE2 ########################################################################
def CovEmbLayer(input_emb, config, name="CovEmbedding"):
input_emb = layers.unsqueeze(input_emb, axes = [1])
num_filters = config['num_filters']
filter_size = config['filter_size']
def Matrix_RE2(x_emb, y_emb, x_mask, y_mask):
def Fusion_Layer(x_emb, y_emb, x_feature, y_feature, config):
def Predict_Layer(x_repr, y_repr, config):
reprs = layers.concat([x_repr, y_repr, x_repr * y_repr, y_repr - x_repr],
axis = -1)
reprs = layers.fc(input = reprs,
size = 64,
act = 'relu',
param_attr = fluid.ParamAttr(name = 'predict_fc1.w'),
bias_attr = fluid.ParamAttr(name = 'predict_fc1.b'))
#########################################################################################################################
class ScoreModel(object):
"""Calc score for query title and content."""
def init(self, query_input_ids, title_input_ids, content_input_ids, config, is_training=True):
self._build_model(query_input_ids, title_input_ids, content_input_ids, config, is_training=is_training)
class LossModel(object):
The text was updated successfully, but these errors were encountered: