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
import copy | |
import itertools | |
from typing import List, Callable | |
import numpy as np; np.random.seed(seed=42) | |
from sklearn.preprocessing import StandardScaler, minmax_scale | |
# https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html#sklearn.preprocessing.StandardScaler | |
# https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.minmax_scale.html#sklearn.preprocessing.minmax_scale | |
def check_result(y1, y2, eps=1e-11): | |
print(f'[y1] max: {np.round(np.max(y1), 4)}, min: {np.round(np.min(y1), 4)}, mean: {np.round(np.mean(y1), 4)}, std: {np.round(np.std(y1), 4)}') |
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
print('tf.__version__', tf.__version__) | |
z_1 = [_*2 for _ in range(10)] | |
z_2 = [_*2+1 for _ in range(10)] | |
z_1 = tf.convert_to_tensor(z_1, dtype=tf.float32) | |
z_2 = tf.convert_to_tensor(z_2, dtype=tf.float32) | |
@tf.function |
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
class AllVariablesNamePrinter: | |
def __init__(self): | |
self.a = 10 | |
self.b = { | |
"ba": 1, | |
"bb": 2, | |
} | |
self.c = 20 | |
def __call__(self): |
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
! pip install -q termcolor==1.1.0 | |
from termcolor import colored | |
print(colored('hello', 'red'), colored('world', 'green')) | |
print(colored("hello red world", 'red')) | |
# --- | |
red = "\x1b[31m" | |
red_ = "\x1b[0m" | |
print(f"{red}red{red_}a") |
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
echo "[loading] ~/.zprofile" | |
# ========================================= | |
## hook command: cd -> cd + ls | |
cdls () | |
{ | |
\cd "$@" && ls | |
} | |
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
# 色を使用 | |
autoload -Uz colors | |
colors | |
# scp needs locate this | |
echo "[loading] ~/.zshrc" | |
# 補完 | |
# autoload -Uz compinit | |
# compinit |
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 skimage import io | |
import matplotlib.pyplot as plt | |
def imshow(img, dpi=150): | |
if(len(img.shape)==2):#grayscale | |
plt.figure(dpi) | |
plt.imshow(img) | |
plt.gray() | |
plt.show() | |
else: |
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
def unet(x, ch, depth, cut_path=False): | |
conv_kwargs = {'kernel_size': (3, 3), 'strides'=(1, 1), 'dilation_rate'=(1, 1), | |
'padding'='same', 'use_bias'=True, 'bias_initializer'='zeros', 'kernel_initializer'='he_normal'} | |
for _ in range(2): | |
x = tf.keras.layers.Convolution2D(ch, **conv_kwargs)(x) | |
x = tf.keras.layers.BatchNormalization()(x) | |
x = tf.keras.layers.Activation('relu')(x) | |
if(depth != 0): | |
path = x |
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
touch Makefile | |
touch Dockerfile | |
touch .gitignore | |
touch .dockerignore | |
touch requirements.txt | |
# gigignore | |
echo '.ipynb_checkoints' >> .gitignore | |
echo '__pycache__' >> .gitignore |
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
# for docker inside, "ls ./ && ls ../" | |
import os; print(os.listdir('./'), os.listdir('../')) | |
# ===== | |
# images | |
# ===== | |
'''read tif''' | |
!pip install tifffile==2020.9.3 | |
import tifffile | |
tifffile.imread('filename.tif') |
NewerOlder