First things first !
sudo apt update
sudo apt upgrade
sudo apt-get install build-essential git
bind R source-file ~/.tmux.conf ; display-message "Config reloaded.." | |
# Use vim keybindings in copy mode | |
setw -g mode-keys vi | |
bind-key -t vi-copy v begin-selection | |
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy" | |
# 状态栏 | |
# 颜色 | |
set -g status-bg black | |
set -g status-fg white |
"""想要继承JsonMixin类,类需要包含名为to_dict的方法;__init__方法需要接受关键字参数""" | |
import json | |
class JsonMixin(object): | |
@classmethod | |
def from_json(cls, data): | |
kwargs = json.loads(data) | |
return cls(**kwargs) | |
def to_json(self): |
class ToDictMixin(object): | |
def to_dict(self): | |
return self._traverse_dict(self.__dict__) | |
def _traverse_dict(self, instance_dict): | |
output = {} | |
for key, value in instance_dict.items(): | |
output[key] = self._traverse(key, value) | |
return output | |
# pip install progressbar | |
import progressbar | |
import time | |
progress = progressbar.ProgressBar(widgets=[progressbar.Bar('=', '[', ']'), ' ', | |
progressbar.Percentage(), ' ', | |
progressbar.ETA()]) | |
for i in progress(range(100)): | |
# do something here |
from collections import Counter | |
import numpy | |
def _bleu_stats(hypothesis, reference): | |
yield len(hypothesis) | |
yield len(reference) | |
for n in xrange(1, 5): | |
s_ngrams = Counter([tuple(hypothesis[i:i + n]) for i in xrange(len(hypothesis) + 1 - n)]) | |
r_ngrams = Counter([tuple(reference[i:i + n]) for i in xrange(len(reference) + 1 - n)]) | |
yield sum((s_ngrams & r_ngrams).values()) |
def vgg16_symbol(): | |
data = mx.sym.Variable('data') | |
# conv1 | |
conv1_1 = mx.sym.Convolution(data=data, kernel=(3, 3), pad=(1, 1), num_filter=64, name="conv1_1") | |
relu1_1 = mx.sym.Activation(data=conv1_1, act_type="relu", name="relu1_1") | |
conv1_2 = mx.sym.Convolution(data=relu1_1, kernel=(3, 3), pad=(1, 1), num_filter=64, name="conv1_2") | |
relu1_2 = mx.sym.Activation(data=conv1_2, act_type="relu", name="relu1_2") | |
pool1 = mx.sym.Pooling(data=relu1_2, kernel=(2, 2), stride=(2, 2), pool_type="max", name="pool1") | |
ssh -qTfNn -D 7070 username@remotehost |
As configured in my dotfiles.
start new:
tmux
start new with session name: