Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Add dense feature normalization to Char-LSTM TorchScript model. #986

Closed
wants to merge 1 commit into from

Conversation

snisarg
Copy link
Contributor

@snisarg snisarg commented Sep 17, 2019

Summary:
In D16357113 we added dense feature tokenisation to the DocModel architecture. As the ByteTokensDocumentModel extends the DocModel class and uses the FloatListTensorizer class, feature normalisation was already supported at training time after this diff was landed, however it was not supported at production time because the normalisation was not performed during the torchscriptify forward function. This presents a problem because the model can be trained on normalized data, but then won't be able to normalize fresh data at inference time, producing unusual results.

This diff adds normalisation in the torchscriptify forward function so that it can be used at inference time on Char-LSTM models.

Just like with the DocModel, if normalize is set to false in the config, then the normalization method just becomes the identity function, this is useful because we don't need to add any extra control flow directly in the forward function.

Reviewed By: snisarg

Differential Revision: D17358479

Summary:
In D16357113 we added dense feature tokenisation to the `DocModel` architecture. As the `ByteTokensDocumentModel` extends the `DocModel` class and uses the `FloatListTensorizer` class, feature normalisation was already supported at training time after this diff was landed, however it was not supported at production time because the normalisation was not performed during the `torchscriptify` forward function. This presents a problem because the model can be trained on normalized data, but then won't be able to normalize fresh data at inference time, producing unusual results.

This diff adds normalisation in the `torchscriptify` forward function so that it can be used at inference time on Char-LSTM models.

Just like with the `DocModel`, if `normalize` is set to `false` in the config, then the normalization method just becomes the identity function, this is useful because we don't need to add any extra control flow directly in the forward function.

Reviewed By: snisarg

Differential Revision: D17358479

fbshipit-source-id: 4a92444963f52290d538377070bf872c9b42aba9
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Sep 17, 2019
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in d2f3d21.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants