Skip to content

Instantly share code, notes, and snippets.

View arnaldog12's full-sized avatar
🤖
Training models...

Arnaldo Gualberto arnaldog12

🤖
Training models...
View GitHub Profile
@arnaldog12
arnaldog12 / catalog.yml
Created August 17, 2021 16:29
Kedro question on stackoverflow
train_x:
type: pandas.CSVDataSet
filepath: data/01_raw/x_train.csv
test_x:
type: pandas.CSVDataSet
filepath: data/01_raw/x_test.csv
autoencoder_scaler:
type: pickle.PickleDataSet
@arnaldog12
arnaldog12 / TensorflowGraph.h
Last active July 13, 2020 12:31
TensorFlow in C++
#pragma once
#ifndef TENSORFLOW_GRAPH_H
#define TENSORFLOW_GRAPH_H
#include "TensorflowUtils.h"
#include "TensorflowPlaceholder.h"
using namespace tensorflow;
using deeplearning::TensorflowUtils;
# 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 $*
@arnaldog12
arnaldog12 / custom_metrics.py
Last active January 9, 2023 17:34
Custom Metrics for Keras and TensorFlow
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
@arnaldog12
arnaldog12 / BalancedDataGenerator.py
Last active July 9, 2022 03:32
BalancedDataGenerator
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)
@arnaldog12
arnaldog12 / pca_svd.py
Created March 2, 2019 23:36
Machine Learning
```
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):
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()
@arnaldog12
arnaldog12 / model.py
Last active October 13, 2018 20:26
Medium Posts
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'))
@arnaldog12
arnaldog12 / environment.sh
Last active August 2, 2018 17:32 — forked from DiogoDantas/environment.sh
Manual Pratico de Deep Learning
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
@arnaldog12
arnaldog12 / neural_network.py
Last active July 24, 2020 20:24
Manual Prático do Deep Learning - Rede Neural
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)