@@ -62,6 +62,7 @@ def __init__(self, config: Dict[str, Any], num_categories_per_col: np.ndarray, n
62
62
# or 0 for numerical data
63
63
self .num_categories_per_col = num_categories_per_col
64
64
self .embed_features = self .num_categories_per_col > 0
65
+ self .num_features_excl_embed = num_features_excl_embed
65
66
66
67
self .num_embed_features = self .num_categories_per_col [self .embed_features ]
67
68
@@ -84,8 +85,8 @@ def get_partial_models(self, subset_features: List[int]) -> "_LearnedEntityEmbed
84
85
partial_model (_LearnedEntityEmbedding)
85
86
a new partial model
86
87
"""
87
- num_input_features = self .num_input_features [subset_features ]
88
- num_numerical_features = sum ([sf < self .num_numerical for sf in subset_features ])
88
+ num_input_features = self .num_categories_per_col [subset_features ]
89
+ num_features_excl_embed = sum ([sf < self .num_features_excl_embed for sf in subset_features ])
89
90
90
91
num_output_dimensions = [self .num_output_dimensions [sf ] for sf in subset_features ]
91
92
embed_features = [self .embed_features [sf ] for sf in subset_features ]
@@ -98,7 +99,7 @@ def get_partial_models(self, subset_features: List[int]) -> "_LearnedEntityEmbed
98
99
ee_layer_tracker += 1
99
100
ee_layers = nn .ModuleList (ee_layers )
100
101
101
- return PartialLearnedEntityEmbedding (num_input_features , num_numerical_features , embed_features ,
102
+ return PartialLearnedEntityEmbedding (num_input_features , num_features_excl_embed , embed_features ,
102
103
num_output_dimensions , ee_layers )
103
104
104
105
def forward (self , x : torch .Tensor ) -> torch .Tensor :
@@ -136,28 +137,27 @@ class PartialLearnedEntityEmbedding(_LearnedEntityEmbedding):
136
137
of the input features. This is applied to forecasting tasks where not all the features might be known beforehand
137
138
"""
138
139
def __init__ (self ,
139
- num_input_features : np .ndarray ,
140
- num_numerical_features : int ,
140
+ num_categories_per_col : np .ndarray ,
141
+ num_features_excl_embed : int ,
141
142
embed_features : List [bool ],
142
143
num_output_dimensions : List [int ],
143
144
ee_layers : nn .Module
144
145
):
145
146
super (_LearnedEntityEmbedding , self ).__init__ ()
146
- self .num_numerical = num_numerical_features
147
+ self .num_features_excl_embed = num_features_excl_embed
147
148
# list of number of categories of categorical data
148
149
# or 0 for numerical data
149
- self .num_input_features = num_input_features
150
- categorical_features : np .ndarray = self .num_input_features > 0
151
-
152
- self .num_categorical_features = self .num_input_features [categorical_features ]
150
+ self .num_categories_per_col = num_categories_per_col
153
151
154
152
self .embed_features = embed_features
155
153
156
154
self .num_output_dimensions = num_output_dimensions
157
- self .num_out_feats = self .num_numerical + sum (self .num_output_dimensions )
155
+ self .num_out_feats = self .num_features_excl_embed + sum (self .num_output_dimensions )
158
156
159
157
self .ee_layers = ee_layers
160
158
159
+ self .num_embed_features = self .num_categories_per_col [self .embed_features ]
160
+
161
161
162
162
class LearnedEntityEmbedding (NetworkEmbeddingComponent ):
163
163
"""
0 commit comments