Skip to content

Instantly share code, notes, and snippets.

View XinyueZ's full-sized avatar
๐Ÿ™Š
Make sense, don't touch

ChrisDEV XinyueZ

๐Ÿ™Š
Make sense, don't touch
View GitHub Profile
@XinyueZ
XinyueZ / rbm-with-hands.ipynb
Created April 9, 2022 20:47
RBM with hands.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@XinyueZ
XinyueZ / generator-of-building-batch-and-data-window-shift-by-1.ipynb
Last active March 10, 2022 23:01
Generator of building batch and data window shift by 1.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@XinyueZ
XinyueZ / ml_tf_cnn_mnist.py
Last active March 5, 2022 20:01
The skeleton of a deep convolutional network
import tensorflow as tf
from IPython.display import Markdown, display
import numpy as np
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
y_train = tf.one_hot(y_train, 10)
@XinyueZ
XinyueZ / ml_tf_mnist.py
Last active March 5, 2022 14:22
TF MNIST, a skeleton for deep learning based on classical MNIST.
import tensorflow as tf
from tensorflow.keras.layers import Flatten
from IPython.display import Markdown, display
import matplotlib.pyplot as plt
%matplotlib inline
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
@XinyueZ
XinyueZ / ml_simple_segmentation_scratch.py
Last active February 18, 2022 14:18
Simple segmentation
import matplotlib.pyplot as plt
import cv2
import numpy as np
!wget https://dl.dropbox.com/s/i1e1brycec3hy3k/pilot-view.jpeg -O pilot-view.png
# For this evalution, we assume that we load image with 3 channels.
def toRGB(img):
@XinyueZ
XinyueZ / ml_simple_segmentation_cv2.py
Last active February 13, 2022 20:13
Simple segmentation(CV)
import matplotlib.pyplot as plt
import cv2
import numpy as np
!wget https://dl.dropbox.com/s/i1e1brycec3hy3k/pilot-view.jpeg -O pilot-view.png
# For this evalution, we assume that we load image with 3 channels.
def toRGB(img):
@XinyueZ
XinyueZ / ml_dropout_inverted_dropout.m
Last active January 15, 2022 11:59
Dropout (inverted dropout)
disp("Dropout, overcome the overfitting in NN....");
function [X] = dropout(X, keep_prob)
% Dropout some units from X.
% (1 - keep_prob) of units will be dropped out.
sz = size(X);
mask = rand(sz);
mask = mask < 0.8; % Element of mask will be set to 1 or 0 with probability ๐‘˜๐‘’๐‘’๐‘_๐‘๐‘Ÿ๐‘œ๐‘
@XinyueZ
XinyueZ / ml_F_Score.py
Last active January 8, 2022 20:01
F_Score
# An approach to do F_Score without np, however, using np is quite effective.
def F_Score(pred_list, true_list):
def bitwise(a, b, core):
return [int(core(pred, true)) for pred, true in zip(pred_list, true_list)]
true_positive = bitwise(pred_list, true_list, lambda pred, true: pred==1 and true==1)
true_positive = sum(true_positive)
false_positive = bitwise(pred_list, true_list, lambda pred, true: pred==1 and true==0)
false_positive = sum(false_positive)
@XinyueZ
XinyueZ / ml_octave_settings.json
Created December 24, 2021 21:45
ml_octave_settings
"terminal.integrated.env.windows": {
"PATH": "/usr/local/lib/octave/6.4.0/bin"
},
"octave-formatter.pythonPath": "/usr/bin/python3",
@XinyueZ
XinyueZ / ml_octave_settings.json
Created December 24, 2021 21:19
ml_octave_settings
{
"octave-formatter.pythonPath": "/usr/bin/python3"
}