MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _create_model

Method _create_model

modelzoo/dlrm/train.py:135–234  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

133
134 # create model
135 def _create_model(self):
136 # input dense feature and embedding of sparse features
137 with tf.variable_scope('input_layer', reuse=tf.AUTO_REUSE):
138 with tf.variable_scope('dense_input_layer',
139 partitioner=self._input_layer_partitioner,
140 reuse=tf.AUTO_REUSE):
141 dense_inputs = tf.feature_column.input_layer(
142 self._feature, self._dense_column)
143 with tf.variable_scope('sparse_input_layer', reuse=tf.AUTO_REUSE):
144 column_tensors = {}
145 if self._adaptive_emb and not self.tf:
146 '''Adaptive Embedding Feature Part 1 of 2'''
147 adaptive_mask_tensors = {}
148 for col in CATEGORICAL_COLUMNS:
149 adaptive_mask_tensors[col] = tf.ones([args.batch_size],
150 tf.int32)
151 sparse_inputs = tf.feature_column.input_layer(
152 features=self._feature,
153 feature_columns=self._sparse_column,
154 cols_to_output_tensors=column_tensors,
155 adaptive_mask_tensors=adaptive_mask_tensors)
156 else:
157 sparse_inputs = tf.feature_column.input_layer(
158 features=self._feature,
159 feature_columns=self._sparse_column,
160 cols_to_output_tensors=column_tensors)
161
162 # MLP behind dense inputs
163 mlp_bot_scope = tf.variable_scope(
164 'mlp_bot_layer',
165 partitioner=self._dense_layer_partitioner,
166 reuse=tf.AUTO_REUSE)
167 with mlp_bot_scope.keep_weights(dtype=tf.float32) if self.bf16 \
168 else mlp_bot_scope:
169 if self.bf16:
170 dense_inputs = tf.cast(dense_inputs, dtype=tf.bfloat16)
171
172 for layer_id, num_hidden_units in enumerate(self._mlp_bot):
173 with tf.variable_scope(
174 'mlp_bot_hiddenlayer_%d' % layer_id,
175 reuse=tf.AUTO_REUSE) as mlp_bot_hidden_layer_scope:
176 dense_inputs = tf.layers.dense(
177 dense_inputs,
178 units=num_hidden_units,
179 activation=tf.nn.relu,
180 name=mlp_bot_hidden_layer_scope)
181 dense_inputs = tf.layers.batch_normalization(
182 dense_inputs,
183 training=self.is_training,
184 trainable=True)
185 self._add_layer_summary(dense_inputs,
186 mlp_bot_hidden_layer_scope.name)
187 if self.bf16:
188 dense_inputs = tf.cast(dense_inputs, dtype=tf.float32)
189
190 # interaction_op
191 if self.interaction_op == 'dot':
192 # dot op

Callers 1

__init__Method · 0.95

Calls 9

_add_layer_summaryMethod · 0.95
_dot_opMethod · 0.95
variable_scopeMethod · 0.80
onesMethod · 0.80
keep_weightsMethod · 0.80
castMethod · 0.45
appendMethod · 0.45
stackMethod · 0.45
concatMethod · 0.45

Tested by

no test coverage detected