- s / n / c
- u / d
- p
- l
This file contains 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
re1 = re.compile(r' +') | |
def fixup(x): | |
x = x.replace('#39;', "'").replace('amp;', '&').replace('#146;', "'").replace( | |
'nbsp;', ' ').replace('#36;', '$').replace('\\n', "\n").replace('quot;', "'").replace( | |
'<br />', "\n").replace('\\"', '"').replace('<unk>','u_n').replace(' @.@ ','.').replace( | |
' @-@ ','-').replace('\\', ' \\ ') | |
return re1.sub(' ', html.unescape(x)) | |
# https://github.com/fastai/fastai/blob/master/courses/dl2/imdb.ipynb |
This file contains 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
# https://stackoverflow.com/questions/6910641/how-to-get-indices-of-n-maximum-values-in-a-numpy-array | |
import numpy as np | |
top_n = 3 | |
arr = np.array([1, 3, 2, 4, 5]) | |
arr.argsort()[-top_n:][::-1] | |
# array([4, 3, 1]) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
As configured in my dotfiles.
start new:
tmux
start new with session name:
As configured in my dotfiles.
start new:
tmux
start new with session name:
This file contains 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
dict_ = {'001.jpg': 'dog', '002.jpg': 'cat', } | |
df = pd.DataFrame.from_dict(dict_, orient='index').reset_index() | |
df.columns = ['image_name', 'tags'] |
while else # nobreak
ModuleList
: https://pytorch.org/docs/stable/nn.html#torch.nn.ParameterListclass MyModule(nn.Module): def __init__(self): super(MyModule, self).__init__() self.linears = nn.ModuleList([nn.Linear(10, 10) for i in range(10)]) def forward(self, x): # ModuleList can act as an iterable, or be indexed using ints
for i, l in enumerate(self.linears):