(self)
| 192 | |
| 193 | # create model |
| 194 | def _create_model(self): |
| 195 | with tf.variable_scope('user_input_layer', |
| 196 | partitioner=self._input_layer_partitioner, |
| 197 | reuse=tf.AUTO_REUSE): |
| 198 | if not self._tf and self._adaptive_emb: |
| 199 | '''Adaptive Embedding Feature Part 1 of 2''' |
| 200 | adaptive_mask_tensors = {} |
| 201 | for col in USER_COLUMN: |
| 202 | adaptive_mask_tensors[col] = tf.ones([self._batch_size], |
| 203 | tf.int32) |
| 204 | user_emb = tf.feature_column.input_layer( |
| 205 | self.feature, |
| 206 | self._user_column, |
| 207 | adaptive_mask_tensors=adaptive_mask_tensors) |
| 208 | else: |
| 209 | user_emb = tf.feature_column.input_layer(self.feature, |
| 210 | self._user_column) |
| 211 | with tf.variable_scope('item_input_layer', |
| 212 | partitioner=self._input_layer_partitioner, |
| 213 | reuse=tf.AUTO_REUSE): |
| 214 | if not self._tf and self._adaptive_emb: |
| 215 | '''Adaptive Embedding Feature Part 1 of 2''' |
| 216 | adaptive_mask_tensors = {} |
| 217 | for col in ITEM_COLUMN: |
| 218 | adaptive_mask_tensors[col] = tf.ones([self._batch_size], |
| 219 | tf.int32) |
| 220 | item_emb = tf.feature_column.input_layer( |
| 221 | self.feature, |
| 222 | self._item_column, |
| 223 | adaptive_mask_tensors=adaptive_mask_tensors) |
| 224 | else: |
| 225 | item_emb = tf.feature_column.input_layer(self.feature, |
| 226 | self._item_column) |
| 227 | with tf.variable_scope('combo_input_layer', |
| 228 | partitioner=self._input_layer_partitioner, |
| 229 | reuse=tf.AUTO_REUSE): |
| 230 | if not self._tf and self._adaptive_emb: |
| 231 | '''Adaptive Embedding Feature Part 1 of 2''' |
| 232 | adaptive_mask_tensors = {} |
| 233 | for col in COMBO_COLUMN: |
| 234 | adaptive_mask_tensors[col] = tf.ones([self._batch_size], |
| 235 | tf.int32) |
| 236 | combo_emb = tf.feature_column.input_layer( |
| 237 | self.feature, |
| 238 | self._combo_column, |
| 239 | adaptive_mask_tensors=adaptive_mask_tensors) |
| 240 | else: |
| 241 | for key in TAG_COLUMN: |
| 242 | self.feature[key] = tf.strings.split(self.feature[key], '|') |
| 243 | combo_emb = tf.feature_column.input_layer(self.feature, |
| 244 | self._combo_column) |
| 245 | |
| 246 | with self._make_scope('ESMM', self._bf16): |
| 247 | if self._bf16: |
| 248 | user_emb = tf.cast(user_emb, dtype=tf.bfloat16) |
| 249 | item_emb = tf.cast(item_emb, dtype=tf.bfloat16) |
| 250 | combo_emb = tf.cast(combo_emb, dtype=tf.bfloat16) |
| 251 |
no test coverage detected