[Model][2/N] Automatic conversion of CrossEncoding model (#19978)
Signed-off-by: wang.yuqi <noooop@126.com>
This commit is contained in:
+5
-1
@@ -453,6 +453,7 @@ class ClassificationOutput:
|
||||
|
||||
@staticmethod
|
||||
def from_base(pooling_output: PoolingOutput):
|
||||
# pooling_output shape: (num_classes)
|
||||
pooled_data = pooling_output.data
|
||||
if pooled_data.ndim != 1:
|
||||
raise ValueError("pooled_data should be a 1-D probability vector")
|
||||
@@ -490,7 +491,10 @@ class ScoringOutput:
|
||||
|
||||
@staticmethod
|
||||
def from_base(pooling_output: PoolingOutput):
|
||||
pooled_data = pooling_output.data
|
||||
# pooling_output shape:
|
||||
# classify task: (num_classes) num_classes == 1
|
||||
# embed task: a scalar value
|
||||
pooled_data = pooling_output.data.squeeze()
|
||||
if pooled_data.ndim != 0:
|
||||
raise ValueError("pooled_data should be a scalar score")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user