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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
In D16357113 we added dense feature tokenisation to the
DocModel
architecture. As theByteTokensDocumentModel
extends theDocModel
class and uses theFloatListTensorizer
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 thetorchscriptify
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
, ifnormalize
is set tofalse
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