Skip to content

Instantly share code, notes, and snippets.

View zaccharieramzi's full-sized avatar
🛠️
undecimated

Zaccharie Ramzi zaccharieramzi

🛠️
undecimated
View GitHub Profile
@endolith
endolith / DFT_ANN.py
Last active June 12, 2024 18:25
Training neural network to implement discrete Fourier transform (DFT/FFT)
"""
Train a neural network to implement the discrete Fourier transform
"""
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
import numpy as np
import matplotlib.pyplot as plt
N = 32
batch = 10000
@arthurmensch
arthurmensch / lbfgs.py
Last active October 20, 2023 06:33
LBFGS wrapper for Pytorch
"""
Copyright (c) 2017 Arthur Mensch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@jovianlin
jovianlin / get_available_gpus.py
Created October 3, 2016 09:58
Get List of Devices in TensorFlow
from tensorflow.python.client import device_lib
def get_available_gpus():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']
get_available_gpus()
@cameronp98
cameronp98 / human_format.py
Created January 9, 2014 22:09
Generate suffixes for large numbers in Python (e.g. 1,000,000 = "1M", 10,000 = "10K" etc.)
from random import randint
from math import log10, floor
def human_format(num, ends=["", "K", "M", "B", "T"]):
# divides by 3 to separate into thousands (...000)
return ends[int(floor(log10(num))/3)]
if __name__ == '__main__':
for i in range(10):
x = randint(1,10**i)
@yong27
yong27 / apply_df_by_multiprocessing.py
Last active April 12, 2023 04:35
pandas DataFrame apply multiprocessing
import multiprocessing
import pandas as pd
import numpy as np
def _apply_df(args):
df, func, kwargs = args
return df.apply(func, **kwargs)
def apply_by_multiprocessing(df, func, **kwargs):
workers = kwargs.pop('workers')
@rxaviers
rxaviers / gist:7360908
Last active July 1, 2024 07:56
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@rday
rday / numpy_ma.py
Created June 5, 2013 18:53
Numpy moving average
import numpy as np
def moving_average(data_set, periods=3):
weights = np.ones(periods) / periods
return np.convolve(data_set, weights, mode='valid')
data = [1, 2, 3, 6, 9, 12, 20, 28, 30, 25, 22, 20, 15, 12, 10]
ma = moving_average(np.asarray(data), 3)
assert (np.around(ma, decimals=2)==np.array([2.0, 3.67, 6.0, 9.0, 13.67, 20.0, 26.0, 27.67, 25.67, 22.33, 19.0, 15.67, 12.33])).all() == True