Skip to content

Instantly share code, notes, and snippets.

View SherazKhan's full-sized avatar

Sheraz Khan SherazKhan

  • Massachusetts General Hospital (MGH), Harvard Medical School and Massachusetts Institute of Technology (MIT)
  • Boston
  • X @dr_sheraz
View GitHub Profile
import keras
from keras.layers import Conv2D, Dense, Dropout, Flatten, MaxPooling2D, GlobalAveragePooling2D, BatchNormalization
from keras.models import Sequential
from keras.optimizers import Adam
from keras import regularizers
def model_cnn_reg(input_shape):
model=Sequential()
model.add(Conv2D(filters=64,kernel_size=(3,3), input_shape=input_shape, activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
import numpy as np
import tensorflow.keras as keras
def build_model(input_shape):
"""Generates RNN-LSTM model
:param input_shape (tuple): Shape of input set
:return model: RNN-LSTM model
"""
import numpy as np
import tensorflow.keras as keras
def build_model(input_shape):
"""Generates RNN-LSTM model
:param input_shape (tuple): Shape of input set
:return model: RNN-LSTM model
"""
# build network topology
import numpy as np
import tensorflow.keras as keras
def build_model(input_shape):
"""Generates CNN model
:param input_shape (tuple): Shape of input set
:return model: CNN model
"""
# build network topology
@SherazKhan
SherazKhan / Audio Feature Extraction.py
Created April 25, 2022 15:42 — forked from gvyshnya/Audio Feature Extraction.py
Audio Feature Extraction from Audio Files using Librosa
def extract_feature_means(audio_file_path: str) -> pd.DataFrame:
# config settings
number_of_mfcc = c.NUMBER_OF_MFCC
# 1. Importing 1 file
y, sr = librosa.load(audio_file_path)
# Trim leading and trailing silence from an audio signal (silence before and after the actual audio)
signal, _ = librosa.effects.trim(y)
import matplotlib
matplotlib.use('Qt5Agg')
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.feature_selection import f_classif, mutual_info_classif
from sklearn.preprocessing import MinMaxScaler
from itertools import cycle
from numpy import interp
from imblearn.ensemble import BalancedRandomForestClassifier
from sklearn.datasets import make_classification
from imblearn.pipeline import Pipeline
from sklearn.model_selection import train_test_split
from sklearn import metrics
X, y = make_classification(n_samples=1000, n_classes=3,
n_informative=4, weights=[0.2, 0.3, 0.5],
random_state=0)
import matplotlib
matplotlib.use('TkAgg')
import mne
import h5py
import numpy as np
import matplotlib.pyplot as plt
import numpy.typing as npt
plt.ion()
def zero_detector(arr: npt.NDArray[np.uint]) -> list([npt.NDArray[np.uint],
#/bin/sh
# PostgreSQL database backup script
DB_USERNAME=''
DB_NAME=''
DB_PASSWORD=''
DB_HOST=''
TIMESTAMP=`date +%Y%m%d-%H%M`
BACKUP_DIR='/Vast/pg_backup'
import numpy as np
import matplotlib.pyplot as plt
def rectified(x):
return max(0.0, x)
X = np.arange(-100, 100)
y = np.array([rectified(x) for x in X])
for index in range(1, 10):
yy = y ** index