本文整理匯總了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()