Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input dropout #5636

Merged
merged 12 commits into from
Apr 21, 2020
1 change: 1 addition & 0 deletions changelog/5636.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add dropout before FFNN after sparse for dense layer in ``DIETClassifier``
6 changes: 5 additions & 1 deletion rasa/nlu/classifiers/diet_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,9 @@ def _prepare_input_layers(self, name: Text) -> None:
self._tf_layers[f"sparse_dropout.{name}"] = layers.SparseDropout(
rate=self.config[DROP_RATE]
)
self._tf_layers[f"dropout.{name}"] = tf.keras.layers.Dropout(
rate=self.config[DROP_RATE]
)
self._prepare_sparse_dense_layers(
self.data_signature[f"{name}_features"],
name,
Expand Down Expand Up @@ -1185,7 +1188,8 @@ def _combine_sparse_dense_features(
else:
dense_features.append(f)

return tf.concat(dense_features, axis=-1) * mask
outputs = tf.concat(dense_features, axis=-1) * mask
return self._tf_layers[f"dropout.{name}"](outputs, self._training)

def _features_as_seq_ids(
self, features: List[Union[np.ndarray, tf.Tensor, tf.SparseTensor]], name: Text
Expand Down