@@ -33,31 +33,30 @@ def calculate_linear_classifier_output_shapes(operator):
3333 N = operator .inputs [0 ].type .shape [0 ]
3434
3535 class_labels = operator .raw_operator .classes_
36- number_of_classes = len (class_labels )
3736 if all (isinstance (i , np .ndarray ) for i in class_labels ):
3837 class_labels = np .concatenate (class_labels )
3938 if all (isinstance (i , (six .string_types , six .text_type )) for i in class_labels ):
4039 operator .outputs [0 ].type = StringTensorType (shape = [N ])
41- if number_of_classes > 2 or operator .type != 'SklearnLinearSVC' :
40+ if len ( class_labels ) > 2 or operator .type != 'SklearnLinearSVC' :
4241 # For multi-class classifier, we produce a map for encoding the probabilities of all classes
4342 if operator .target_opset < 7 :
4443 operator .outputs [1 ].type = DictionaryType (StringTensorType ([1 ]), FloatTensorType ([1 ]))
4544 else :
4645 operator .outputs [1 ].type = SequenceType (DictionaryType (StringTensorType ([]), FloatTensorType ([])), N )
4746 else :
48- # For binary LinearSVC, we produce the probability tensor
49- operator .outputs [1 ].type = FloatTensorType (shape = [N , number_of_classes ])
47+ # For binary LinearSVC, we produce probability of the positive class
48+ operator .outputs [1 ].type = FloatTensorType (shape = [N , 1 ])
5049 elif all (isinstance (i , (numbers .Real , bool , np .bool_ )) for i in class_labels ):
5150 operator .outputs [0 ].type = Int64TensorType (shape = [N ])
52- if number_of_classes > 2 or operator .type != 'SklearnLinearSVC' :
51+ if len ( class_labels ) > 2 or operator .type != 'SklearnLinearSVC' :
5352 # For multi-class classifier, we produce a map for encoding the probabilities of all classes
5453 if operator .target_opset < 7 :
5554 operator .outputs [1 ].type = DictionaryType (Int64TensorType ([1 ]), FloatTensorType ([1 ]))
5655 else :
5756 operator .outputs [1 ].type = SequenceType (DictionaryType (Int64TensorType ([]), FloatTensorType ([])), N )
5857 else :
59- # For binary LinearSVC, we produce the probability tensor
60- operator .outputs [1 ].type = FloatTensorType (shape = [N , number_of_classes ])
58+ # For binary LinearSVC, we produce probability of the positive class
59+ operator .outputs [1 ].type = FloatTensorType (shape = [N , 1 ])
6160 else :
6261 raise ValueError ('Unsupported or mixed label types' )
6362
0 commit comments