Chau Tung Lam Nguyen
Scrapy project - Python Software Foundation
Code Repository: https://github.com/scrapy/scurl
| """ | |
| The most atomic way to train and inference a GPT in pure, dependency-free Python. | |
| This file is the complete algorithm. | |
| Everything else is just efficiency. | |
| @karpathy | |
| """ | |
| import os # os.path.exists | |
| import math # math.log, math.exp |
| $ pip install torch==1.1.0 torchvision==0.3.0 | |
| $ OMP_NUM_THREADS=1 ipython | |
| Python 3.6.7 (default, Oct 22 2018, 11:32:17) | |
| In [1]: import torch | |
| ...: from torchvision.models import resnet50 | |
| In [2]: def forward(m, x): | |
| ...: """ resnet without average pooling """ | |
| ...: x = m.conv1(x) |
Chau Tung Lam Nguyen
Scrapy project - Python Software Foundation
Code Repository: https://github.com/scrapy/scurl
| import numpy as np | |
| import marisa_trie | |
| from sklearn.feature_extraction.text import CountVectorizer | |
| from sklearn.externals import six | |
| class MarisaCountVectorizer(CountVectorizer): | |
| # ``CountVectorizer.fit`` method calls ``fit_transform`` so | |
| # ``fit`` is not provided | |
| def fit_transform(self, raw_documents, y=None): |