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
#include <vector> | |
// the two define below must be before #include <eigen/Dense> | |
#define COMPILER_MSVC | |
#define NOMINMAX | |
#include <eigen/Dense> | |
#include "tensorflow/core/public/session.h" | |
#include "tensorflow/cc/ops/standard_ops.h" |
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 numpy as np | |
import _pickle as pkl | |
# activation functions | |
def linear(x, derivative=False): | |
return np.ones_like(x) if derivative else x | |
def sigmoid(x, derivative=False): | |
if derivative: | |
y = sigmoid(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
echo "#################### create environment ####################" | |
conda create -n bootcamp python=3.6.5 numpy=1.14.3 pandas=0.23.0 matplotlib=2.2.2 scikit-learn=0.19.1 jupyter=1.0.0 | |
source activate bootcamp | |
jupyter nbextension enable --py widgetsnbextension --sys-prefix | |
jupyter notebook |
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
model = Sequential() | |
model.add(Dense(units=20, activation='relu', kernel_regularizer='l2', input_dim=x.shape[1])) | |
model.add(Dense(units=10, activation='relu', kernel_regularizer='l2')) | |
model.add(Dense(units=3, activation='linear')) |
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 numpy as np | |
import tensorflow as tf | |
from os import path | |
from glob import glob | |
from tensorflow.python.platform import gfile | |
def load_graph(model_file): | |
graph = tf.Graph() | |
graph_def = tf.GraphDef() |
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
``` | |
extracted from: https://stats.stackexchange.com/questions/134282/relationship-between-svd-and-pca-how-to-use-svd-to-perform-pca | |
``` | |
import numpy as np | |
from numpy import linalg as la | |
np.random.seed(42) | |
def flip_signs(A, B): |
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 keras.utils.data_utils import Sequence | |
from imblearn.over_sampling import RandomOverSampler | |
from imblearn.keras import balanced_batch_generator | |
class BalancedDataGenerator(Sequence): | |
"""ImageDataGenerator + RandomOversampling""" | |
def __init__(self, x, y, datagen, batch_size=32): | |
self.datagen = datagen | |
self.batch_size = min(batch_size, x.shape[0]) | |
datagen.fit(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
import numpy as np | |
import tensorflow as tf | |
from keras import backend as K | |
def recall(y_true, y_pred): | |
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) | |
possible_positives = K.sum(K.round(K.clip(y_true, 0, 1))) | |
recall_keras = true_positives / (possible_positives + K.epsilon()) | |
return recall_keras |
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
# Windows (Cmder) | |
;= @echo off | |
;= rem Call DOSKEY and use this file as the macrofile | |
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0% | |
;= rem In batch mode, jump to the end of the file | |
;= goto:eof | |
;= Add aliases below here | |
e.=explorer . | |
gl=git log --oneline --all --graph --decorate $* | |
ls=ls --show-control-chars -F --color $* |
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
#pragma once | |
#ifndef TENSORFLOW_GRAPH_H | |
#define TENSORFLOW_GRAPH_H | |
#include "TensorflowUtils.h" | |
#include "TensorflowPlaceholder.h" | |
using namespace tensorflow; | |
using deeplearning::TensorflowUtils; |
OlderNewer