Skip to content

Commit

Permalink
Merge 945e7cd into 5c314fd
Browse files Browse the repository at this point in the history
  • Loading branch information
tabergma authored Sep 3, 2020
2 parents 5c314fd + 945e7cd commit 96a529d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 21 deletions.
1 change: 1 addition & 0 deletions changelog/6555.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not set the output dimension of the ´sparse-to-dense´ layers to the same dimension as the dense features.
3 changes: 0 additions & 3 deletions docs/docs/components/intent-classifiers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,6 @@ Intent classifiers assign one of the intents defined in the domain file to incom
+---------------------------------+------------------+--------------------------------------------------------------+
| embedding_dimension | 20 | Dimension size of embedding vectors. |
+---------------------------------+------------------+--------------------------------------------------------------+
| dense_dimension | text: 512 | Dense dimension for sparse features to use if no dense |
| | label: 20 | features are present. |
+---------------------------------+------------------+--------------------------------------------------------------+
| concat_dimension | text: 512 | Concat dimension for sequence and sentence features. |
| | label: 20 | |
+---------------------------------+------------------+--------------------------------------------------------------+
Expand Down
3 changes: 0 additions & 3 deletions docs/docs/components/selectors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ Selectors predict a bot response from a set of candidate responses.
+---------------------------------+-------------------+--------------------------------------------------------------+
| embedding_dimension | 20 | Dimension size of embedding vectors. |
+---------------------------------+-------------------+--------------------------------------------------------------+
| dense_dimension | text: 512 | Dense dimension for sparse features to use if no dense |
| | label: 512 | features are present. |
+---------------------------------+-------------------+--------------------------------------------------------------+
| concat_dimension | text: 512 | Concat dimension for sequence and sentence features. |
| | label: 512 | |
+---------------------------------+-------------------+--------------------------------------------------------------+
Expand Down
16 changes: 4 additions & 12 deletions rasa/nlu/classifiers/diet_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
EPOCHS,
RANDOM_SEED,
LEARNING_RATE,
DENSE_DIMENSION,
RANKING_LENGTH,
LOSS_TYPE,
SIMILARITY_TYPE,
Expand Down Expand Up @@ -102,6 +101,7 @@
LABEL_SEQUENCE_LENGTH = f"{LABEL}_{SEQUENCE}_lengths"
LABEL_IDS = f"{LABEL}_ids"
TAG_IDS = "tag_ids"
DEFAULT_DENSE_DIMENSION = 100

POSSIBLE_TAGS = [ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_ROLE, ENTITY_ATTRIBUTE_GROUP]

Expand Down Expand Up @@ -172,8 +172,6 @@ def required_components(cls) -> List[Type[Component]]:
# ## Parameters for embeddings
# Dimension size of embedding vectors
EMBEDDING_DIMENSION: 20,
# Default dense dimension to use if no dense features are present.
DENSE_DIMENSION: {TEXT: 512, LABEL: 20},
# Default dimension to use for concatenating sequence and sentence features.
CONCAT_DIMENSION: {TEXT: 512, LABEL: 20},
# The number of incorrect labels. The algorithm will minimize
Expand Down Expand Up @@ -1331,22 +1329,17 @@ def _prepare_layers(self) -> None:
self._prepare_entity_recognition_layers()

def _prepare_sparse_dense_layers(
self,
feature_signatures: List[FeatureSignature],
name: Text,
reg_lambda: float,
dense_dim: int,
self, feature_signatures: List[FeatureSignature], name: Text, reg_lambda: float
) -> None:
sparse = False
dense = False
dense_dim = DEFAULT_DENSE_DIMENSION
for is_sparse, feature_dimension in feature_signatures:
if is_sparse:
sparse = True
dense_dim = min(dense_dim, feature_dimension)
else:
dense = True
# if dense features are present
# use the feature dimension of the dense features
dense_dim = feature_dimension

if sparse:
self._tf_layers[f"sparse_to_dense.{name}"] = layers.DenseForSparse(
Expand Down Expand Up @@ -1380,7 +1373,6 @@ def _prepare_input_layers(self, name: Text) -> None:
self.data_signature[f"{name}_{feature_type}_features"],
f"{name}_{feature_type}",
self.config[REGULARIZATION_CONSTANT],
self.config[DENSE_DIMENSION][name],
)
self._tf_layers[f"concat_layer.{name}_{feature_type}"] = layers.Ffnn(
[self.config[CONCAT_DIMENSION][name]],
Expand Down
3 changes: 0 additions & 3 deletions rasa/nlu/selectors/response_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
EPOCHS,
RANDOM_SEED,
LEARNING_RATE,
DENSE_DIMENSION,
RANKING_LENGTH,
LOSS_TYPE,
SIMILARITY_TYPE,
Expand Down Expand Up @@ -156,8 +155,6 @@ def required_components(cls) -> List[Type[Component]]:
# ## Parameters for embeddings
# Dimension size of embedding vectors
EMBEDDING_DIMENSION: 20,
# Default dense dimension to use if no dense features are present.
DENSE_DIMENSION: {TEXT: 512, LABEL: 512},
# Default dimension to use for concatenating sequence and sentence features.
CONCAT_DIMENSION: {TEXT: 512, LABEL: 512},
# The number of incorrect labels. The algorithm will minimize
Expand Down

0 comments on commit 96a529d

Please sign in to comment.