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
It's pleasant when code lines up. Recording here oft-used-together words have the same length: | |
train | |
valid | |
prediction from | |
actual value in | |
pred | |
resp |
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
(optional) set up pubkey authorization | |
(taken from https://unix.stackexchange.com/questions/23291/how-to-ssh-to-remote-server-using-a-private-key) | |
$ scp -p your_pub_key.pub user@host: | |
$ ssh user@host | |
$ cat id_dsa.pub >> ~/.ssh/authorized_keys | |
make sure this is in ~/.ssh/config on the remote: | |
PubkeyAuthentication yes |
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
from contextlib import contextmanager | |
@contextmanager | |
def optional(condition, context_manager): | |
# taken from https://stackoverflow.com/a/41251962/12558195 | |
if condition: | |
with context_manager: | |
yield | |
else: | |
yield |
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
# Below is a cheeky little utility that helps you | |
# avoid doing all the tedious math by piggy-backing | |
# on torch’s error messages. The assumption is that | |
# net is your Module which is composed of a sequence | |
# of input shape-agnostic layers (such as Conv & ReLU | |
# & BatchNorm & MaxPool layers), followed at some | |
# point by a flattening and a linear layer whose required | |
# size you’re trying to figure out. height and width | |
# refer to your desired input image shape. |