Skip to content

Instantly share code, notes, and snippets.

View alecGraves's full-sized avatar
🌵

Alec Graves alecGraves

🌵
View GitHub Profile
@alecGraves
alecGraves / .vimrc
Created May 20, 2018 22:48
My vim setup commands
" Note, to set this up, run ':PluginInstall' in vim
" Then to set up autocomplete,
"
" cd ~/.vim/bundle/YouCompleteMe && python install.py
"
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
@alecGraves
alecGraves / hw9.m
Last active March 15, 2018 17:38
software of programming, graphing numerical derivative
clear
clc
hold('on');
x = 0:0.01:5;
y = x.^2;
p = plot(x, y, 'LineWidth', 2, 'Color', [.2, .5, 1]);
axis([0, 5, 0, 25])
tangent = 2*x-1;
import tensorflow as tf
def prelu(x, scope, decoder=False):
'''
Performs the parametric relu operation. This implementation is based on:
https://stackoverflow.com/questions/39975676/how-to-implement-prelu-activation-in-tensorflow
For the decoder portion, prelu becomes just a normal prelu
INPUTS:
- x(Tensor): a 4D Tensor that undergoes prelu
- scope(str): the string to name your prelu operation's alpha variable.
import tensorflow as tf
from tensorflow.contrib.layers.python.layers import initializers
slim = tf.contrib.slim
'''
============================================================================
ENet: A Deep Neural Network Architecture for Real-Time Semantic Segmentation
============================================================================
Based on the paper: https://arxiv.org/pdf/1606.02147.pdf
'''
const int MPIN = 2; //motor pwm out pin
const int DPIN = A0; // voltage distance sensor pin
float steady_state_error;
float voltage;
float target;
float accumulate;
void setup()
{
@alecGraves
alecGraves / resnet.m
Created November 1, 2017 15:51
matlab function for building resnet with nn toolbox
function net = resnet(input_shape)
%RESNET Creates a resnet model with imput_size
n = imageInputLayer(input_shape,'Name','input');
n = layerGraph(n);
n = bottleneck(256, ['bottleneck_' char(string(1))], n)
end
function graph = bottleneck(depth, name, graph)
head = graph.Layers(end).Name;
@alecGraves
alecGraves / ti84pce.inc
Created September 11, 2017 04:02
ti-84 inc
;TI-84 Plus CE Include File
;Various Parts Contributed by
;- BrandonW
;- calc84
;- MateoConLechuga
;- Runer112
;- tr1p1ea
;- Kerm Martian
;- Texas Instruments (ti83plus.inc)
@alecGraves
alecGraves / Rational.h
Last active August 24, 2017 15:27
Tiny Rational Class MTRE 2610
#include <cstdio>
class Rational{
int n, d; //numerator, denominator
int gcf(int x, int y, int z){ return y&&(z=x%y) ? gcf(y,z,0) : y;}
void r(){int f=gcf(n, d, 0); n/=f; d/=f;} //reduce
public:
Rational operator+(Rational R){return Rational(n*R.d+d*R.n, d*R.d);}
Rational operator-(Rational R){return Rational(n*R.d-d*R.n, d*R.d);}
Rational operator*(Rational R){return Rational(n*R.n, d*R.d);}
Rational operator/(Rational R){return Rational(n*R.d, d*R.n);}
@alecGraves
alecGraves / Student.h
Created August 24, 2017 04:29
Tiny Student Struct for MTRE 2610
struct Student {
int n, c[9], g[9];
void SetGrades(int *C, char *G, int N){
for (int i(0); i < N; ++i){
AddGrade(C[i], G[i]);
}
}
void AddGrade(int C, char G){
c[n] = C;
g[n++] = G;
@alecGraves
alecGraves / fscore.py
Created June 9, 2017 23:14
Fscore2 Metric for Keras
import keras.backend as K
def FScore2(y_true, y_pred):
'''
The F score, beta=2
'''
B2 = K.variable(4)
OnePlusB2 = K.variable(5)
pred = K.round(y_pred)
tp = K.sum(K.cast(K.less(K.abs(pred - K.clip(y_true, .5, 1.)), 0.01), 'float32'), -1)