本文整理汇总了Python中syntaxnet.sparse_pb2.SparseFeatures方法的典型用法代码示例。如果您正苦于以下问题:Python sparse_pb2.SparseFeatures方法的具体用法?Python sparse_pb2.SparseFeatures怎么用?Python sparse_pb2.SparseFeatures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类syntaxnet.sparse_pb2
的用法示例。
在下文中一共展示了sparse_pb2.SparseFeatures方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GetMaxId
# 需要导入模块: from syntaxnet import sparse_pb2 [as 别名]
# 或者: from syntaxnet.sparse_pb2 import SparseFeatures [as 别名]
def GetMaxId(self, sparse_features):
max_id = 0
for x in sparse_features:
for y in x:
f = sparse_pb2.SparseFeatures()
f.ParseFromString(y)
for i in f.id:
max_id = max(i, max_id)
return max_id
示例2: MakeSparseFeatures
# 需要导入模块: from syntaxnet import sparse_pb2 [as 别名]
# 或者: from syntaxnet.sparse_pb2 import SparseFeatures [as 别名]
def MakeSparseFeatures(self, ids, weights):
f = sparse_pb2.SparseFeatures()
for i, w in zip(ids, weights):
f.id.append(i)
f.weight.append(w)
return f.SerializeToString()