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
""" | |
Based on the model from: | |
https://github.com/kuangliu/pytorch-cifar | |
""" | |
import tensorflow as tf | |
import tensorflow.keras as keras | |
import tensorflow.keras.layers as kl | |
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
Downloading tensorflow-2.2.1-cp38-cp38-manylinux2010_x86_64.whl (516.3 MB) | |
Downloading tensorflow-2.2.0-cp38-cp38-manylinux2010_x86_64.whl (516.3 MB) | |
INFO: pip is looking at multiple versions of decorator to determine which version is compatible with other requirements. This could take a while. | |
Collecting decorator | |
Downloading decorator-5.0.5-py3-none-any.whl (8.8 kB) | |
Downloading decorator-4.4.2-py2.py3-none-any.whl (9.2 kB) | |
Downloading decorator-4.4.1-py2.py3-none-any.whl (9.2 kB) | |
Downloading decorator-4.4.0-py2.py3-none-any.whl (8.3 kB) | |
Downloading decorator-4.3.2-py2.py3-none-any.whl (9.1 kB) | |
Downloading decorator-4.3.1-py2.py3-none-any.whl (8.8 kB) |
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
#! sh | |
set -e | |
target="$1" | |
if [ -z "$target" ] | |
then | |
echo "Please provide the target directory." | |
exit -1 |
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 torch | |
PATH = 'model.pth' | |
ckpt = torch.load(PATH) | |
# `ckpt` will likely be a nested dictionary with nested `state_dict` | |
ckpt['state_dict'] = { | |
key.replace('old_name', 'new_name'): value | |
for key, value in ckpt['state_dict'].items() | |
} |
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 time | |
from collections import deque | |
class Timer: | |
def __init__(self, buffer_size=10_000): | |
self.times = deque(maxlen=buffer_size) | |
self.__start = None | |
def __enter__(self): |
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
#! python3 | |
import datetime | |
from PySide2.QtCore import Qt, QPoint, QSize, QRect, QTimer | |
from PySide2.QtGui import QScreen | |
from PySide2.QtWidgets import QApplication, QLabel, QHBoxLayout, QFrame | |
from bspwm import State |
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
<scheme name="Better Darcula" version="142" parent_scheme="Darcula"> | |
<metaInfo> | |
<property name="created">2018-11-14T23:00:57</property> | |
<property name="ide">Python</property> | |
<property name="ideVersion">2018.2.4.0.0</property> | |
<property name="modified">2018-11-14T23:01:13</property> | |
<property name="originalScheme">Better Darcula</property> | |
</metaInfo> | |
<colors> | |
<option name="DOCUMENTATION_COLOR" value="3c3f41" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 re | |
from collections import defaultdict | |
UNKNOWN_WORD_CODE = 1 | |
SEQUENCE_LENGTH_LIMIT = 500 # just to protect from crashing the training process by too large example | |
def encode_text(text: str, encoding: dict, default=UNKNOWN_WORD_CODE): | |
clean_text = re.sub(r'([^\w-]+)', ' \g<0> ', text).strip() | |
tokens = clean_text.split() | |
tokens = ['#' if t.isnumeric() else t for t in tokens] |
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
from enum import Enum | |
from queue import PriorityQueue | |
class PathMeta: | |
def __init__(self, pre: int, post: int): | |
""" | |
Metadata of the path passing through given edge | |
`pre` + `post` + 1 == length of the whole path |