注意:本文内容适用于 Tmux 2.3 及以上的版本,不计划兼容低版本。
启动新会话:
tmux [new -s 会话名 -n 窗口名]
恢复会话:
import numpy as np | |
from sklearn.manifold import TSNE | |
from matplotlib import pyplot as plt | |
def draw_tsne(X, y, save_fig=None, show=False): | |
""" | |
T-SNE visualization by `sklearn.manifold.TSNE`. | |
Reference: https://www.scipy-lectures.org/packages/scikit-learn/auto_examples/plot_tsne.html | |
:param X: data to be projected |
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
# ~/.profile: executed by the command interpreter for login shells. | |
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login | |
# exists. | |
# see /usr/share/doc/bash/examples/startup-files for examples. | |
# the files are located in the bash-doc package. | |
# the default umask is set in /etc/profile; for setting the umask | |
# for ssh logins, install and configure the libpam-umask package. | |
#umask 022 |
TOTAL_VARIATION_SMOOTHING = 1.5 | |
# Compute total variation regularization loss term given a variable image (x) and its shape | |
def get_total_variation(x, shape): | |
with tf.name_scope('get_total_variation'): | |
# Get the dimensions of the variable image | |
height = shape[1] | |
width = shape[2] | |
size = reduce(lambda a, b: a * b, shape) ** 2 |
#################### MS_SSIM Loss ##################### | |
## ref code: https://stackoverflow.com/questions/39051451/ssim-ms-ssim-for-tensorflow | |
def _tf_fspecial_gauss(size, sigma): | |
"""Function to mimic the 'fspecial' gaussian MATLAB function | |
""" | |
x_data, y_data = np.mgrid[-size//2 + 1:size//2 + 1, -size//2 + 1:size//2 + 1] | |
x_data = np.expand_dims(x_data, axis=-1) | |
x_data = np.expand_dims(x_data, axis=-1) |
n02119789 1 kit_fox | |
n02100735 2 English_setter | |
n02110185 3 Siberian_husky | |
n02096294 4 Australian_terrier | |
n02102040 5 English_springer | |
n02066245 6 grey_whale | |
n02509815 7 lesser_panda | |
n02124075 8 Egyptian_cat | |
n02417914 9 ibex | |
n02123394 10 Persian_cat |
import numpy as np | |
from sklearn.manifold import TSNE | |
from matplotlib import pyplot as plt | |
def draw_tsne(X, y, save_fig=None, show=False): | |
""" | |
T-SNE visualization by `sklearn.manifold.TSNE`. | |
Reference: https://www.scipy-lectures.org/packages/scikit-learn/auto_examples/plot_tsne.html | |
:param X: data to be projected | |
:param y: data labels |
# Convert an numpy array image to bytes and decode it with tensorflow. | |
# Refers to https://stackoverflow.com/questions/50630045/how-to-turn-numpy-array-image-to-bytes/50630390 | |
import numpy as np | |
import cv2 | |
import tensorflow as tf | |
# img_bgr is an 16-bit BGR image | |
img_bgr = (np.random.rand(50, 50, 3)*65536).astype(np.uint16) | |
cv2.imwrite('demo.png', img_bgr, params=[cv2.CV_16U]) |
# | |
# A simple makefile for managing build of project composed of C source files. | |
# References: https://web.stanford.edu/class/cs107/resources/make | |
# | |
# It is likely that default C compiler is already gcc, but explicitly | |
# set, just to be sure | |
CC = gcc |