Download annotations/annotation_38/PreferDiff/base.py from mcy98/RECODE-H: direct link, hf CLI and curl.
- Browser
- Download file 755 Bytes
-
https://huggingface.co/datasets/mcy98/RECODE-H/resolve/main/annotations/annotation_38/PreferDiff/base.py
- Command line
-
hf download hf://datasets/mcy98/RECODE-H/annotations/annotation_38/PreferDiff/base.py
-
curl -L -o base.py https://huggingface.co/datasets/mcy98/RECODE-H/resolve/main/annotations/annotation_38/PreferDiff/base.py
755 Bytes
| import torch.nn as nn | |
| class AbstractModel(nn.Module): | |
| def __init__( | |
| self, | |
| config: dict, | |
| ): | |
| super(AbstractModel, self).__init__() | |
| self.config = config | |
| def n_parameters(self): | |
| total_params = sum(p.numel() for p in self.parameters() if p.requires_grad) | |
| return f'Total number of trainable parameters: {total_params}' | |
| def get_representation(self, batch): | |
| raise NotImplementedError('get representation method must be implemented.') | |
| def get_embeddings(self, items): | |
| raise NotImplementedError('get item_embeddings must be implemented.') | |
| def predict(self, batch, n_return_sequences=1): | |
| raise NotImplementedError('predict method must be implemented.') |