@@ -14,7 +14,7 @@ def fisher(data, num_instances: list, top_k_features=2):
1414 assert len (num_instances ) == 2 , "Fisher selection method can be performed for two-class problems."
1515
1616 data = tf .convert_to_tensor (data )
17- _ , num_features = data .get_shape ().as_list ()
17+ num_features = data .get_shape ().as_list ()[ - 1 ]
1818 if top_k_features > num_features :
1919 top_k_features = num_features
2020 class1 , class2 = tf .split (data , num_instances )
@@ -35,7 +35,7 @@ def feature_correlation_with_class(data, num_instances: list, top_k_features=10)
3535 :return: the list of most significant features.
3636 """
3737 data = tf .convert_to_tensor (data )
38- _ , num_features = data .get_shape ().as_list ()
38+ num_features = data .get_shape ().as_list ()[ - 1 ]
3939 if top_k_features > num_features :
4040 top_k_features = num_features
4141 class1 , class2 = tf .split (data , num_instances )
@@ -57,7 +57,7 @@ def t_test(data, num_instances: list, top_k_features=10):
5757 :return: the list of most significant features.
5858 """
5959 data = tf .convert_to_tensor (data )
60- _ , num_features = data .get_shape ().as_list ()
60+ num_features = data .get_shape ().as_list ()[ - 1 ]
6161 if top_k_features > num_features :
6262 top_k_features = num_features
6363 class1 , class2 = tf .split (data , num_instances )
@@ -74,16 +74,10 @@ def t_test(data, num_instances: list, top_k_features=10):
7474
7575def random (data , num_instances : list , top_k_features = 10 ):
7676 data = tf .convert_to_tensor (data )
77- _ , num_features = data .get_shape ().as_list ()
77+ num_features = data .get_shape ().as_list ()[ - 1 ]
7878 if top_k_features > num_features :
7979 top_k_features = num_features
8080 class1 , class2 = tf .split (data , num_instances )
8181
8282 with tf .name_scope ('random_selection' ):
83- mean1 , std1 = tf .nn .moments (class1 , axes = 0 )
84- mean2 , std2 = tf .nn .moments (class2 , axes = 0 )
85- t_test_coeffs = tf .abs (mean1 - mean2 ) / tf .sqrt (
86- tf .square (std1 ) / num_instances [0 ] + tf .square (std2 ) / num_instances [1 ])
87- selected_features = tf .nn .top_k (t_test_coeffs , k = top_k_features )
88-
89- return selected_features
83+ pass
0 commit comments