This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Python code to generate M-splines and I-splines. | |
References | |
---------- | |
Ramsay, J. O. (1988). Monotone regression splines in action. | |
Statistical science, 3(4), 425-441. | |
""" | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
from torchtext.experimental.datasets import TextClassificationDataset | |
from torchtext.vocab import build_vocab_from_iterator | |
from torchtext.experimental.functional import sequential_transforms | |
from torchtext.experimental.datasets import IMDB | |
from torchtext.data.utils import get_tokenizer | |
from torch.nn.utils.rnn import pack_padded_sequence | |
def build_char_vocab(data, index, bow="<w>", eow="</w>"): |