Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

fairseq_encoder.py 760 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  1. # Copyright (c) 2017-present, Facebook, Inc.
  2. # All rights reserved.
  3. #
  4. # This source code is licensed under the license found in the LICENSE file in
  5. # the root directory of this source tree. An additional grant of patent rights
  6. # can be found in the PATENTS file in the same directory.
  7. import torch.nn as nn
  8. class FairseqEncoder(nn.Module):
  9. """Base class for encoders."""
  10. def __init__(self, dictionary):
  11. super().__init__()
  12. self.dictionary = dictionary
  13. def forward(self, src_tokens, src_lengths):
  14. raise NotImplementedError
  15. def max_positions(self):
  16. """Maximum input length supported by the encoder."""
  17. raise NotImplementedError
  18. def upgrade_state_dict(self, state_dict):
  19. return state_dict
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...