You have to already have these in your system:
- Python. Version 3.6+ is highly recommended.
- Official CPython from python.org
- Anaconda
- (Recommended) Miniconda
from torchvision import transforms | |
from PIL import ImageOps | |
class ResizeAndPad(object): | |
def __init__(self, size, interpolation=Image.BILINEAR): | |
assert isinstance(size, int) | |
self.size = size | |
self.interpolation = interpolation | |
def __call__(self, img): |
class STLR(torch.optim.lr_scheduler._LRScheduler): | |
def __init__(self, optimizer, max_mul, ratio, steps_per_cycle, decay=1, last_epoch=-1): | |
self.max_mul = max_mul - 1 | |
self.turning_point = steps_per_cycle // (ratio + 1) | |
self.steps_per_cycle = steps_per_cycle | |
self.decay = decay | |
super().__init__(optimizer, last_epoch) | |
def get_lr(self): | |
residual = self.last_epoch % self.steps_per_cycle |
"""A Simple Strategy Trading Two Stocks | |
Original code: https://blog.csdn.net/qq_26948675/article/details/80016633 | |
Modified based on: https://www.backtrader.com/blog/posts/2018-04-22-improving-code/improving-code.html | |
Replaced the local CSV files with online data from IEX. | |
Unfortunately, this strategy is not profitable for the two stocks picked. | |
""" |
You have to already have these in your system:
library(ggplot2) | |
library(ggthemes) | |
dat <- data.frame( | |
name = c("CPU", "GPU", "TPU"), | |
time = c(3 * 3600 + 6 * 60 + 4, 3 * 60 + 16, 1 * 60 + 42) | |
) | |
dat$log_time = log(dat$time) | |
ggplot(data=dat, aes(x=name, y=log_time)) + |
# WARNING: this script is out-dated since the last update of the Tourism Bureau website. | |
from pathlib import Path | |
import pandas as pd | |
SCHEMAS = [ | |
(201201, "schema/residence-2012-01.csv"), | |
(201101, "schema/residence-2011-01.csv") | |
] | |
DATA_FILE_PATTERN = "raw_data/{year}-{month}.xls" |