Skip to content

Instantly share code, notes, and snippets.

Avatar

Markus Frey CYHSM

View GitHub Profile
View XOR_single_neuron.py
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.keras.layers import Dense, Activation, Input
from tensorflow.keras import Model
from tensorflow.keras.optimizers import SGD
# Implement activation function
def dCaAP_activation(x):
@CYHSM
CYHSM / euclidean_distance_nn.py
Last active Nov 23, 2019
Build a neural network to predict euclidean distance to goal object from XY location
View euclidean_distance_nn.py
# Standard imports
import numpy as np
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# Keras
from keras.layers import Dense
from keras.models import Model, Input
@CYHSM
CYHSM / transform_to_template.py
Last active Aug 21, 2019
Register functional MRI images (fMRI) to template
View transform_to_template.py
def transform_to_template(fn_func, fn_template, save=False):
"""
Reads (4D)-functional images and transforms directly to template image
Inputs:
- fn_func : Path to functional images
- fn_template : Path to template brain, e.g. MNI template
- save : Whether to save transformed image to same folder as functional
Outputs:
- func_template : functional images transformed to template brain
"""
View norwegian_swedish_testset.py
# Imports
import numpy as np
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt
plt.xkcd();
import seaborn as sns
sns.set_style('white')
# Set transparency off when exporting / Only if you want to save the figure
from matplotlib import patheffects, rcParams
rcParams['path.effects'] = [patheffects.withStroke(linewidth=0)]
View 3D_animated_surface_plot.py
"""Creates a 3D surface plot, can be used as an example for demonstrating gradient descent
Author: Markus Frey
E-mail: markus.frey1@gmail.com
"""
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt