Skip to content

Instantly share code, notes, and snippets.

View fedden's full-sized avatar
🤖
Training deep audio models

Leon Fedden fedden

🤖
Training deep audio models
View GitHub Profile
@fedden
fedden / test.cpp
Created March 20, 2017 12:45
Maxi Object Timing Check
#include <iostream>
#include "/home/tollie/Development/Maximilian/maximilian.h"
#include <vector>
#include <algorithm>
#include <chrono>
size_t amount = 1;
std::vector<maxiOsc> maxiObjects;
void process()
@fedden
fedden / frequency_modulation_visualisation.py
Last active December 1, 2020 10:54
Frequency modulation Python matplotlib visualisation
import numpy as np
import matplotlib.pyplot as plt
modulator_frequency = 4.0
carrier_frequency = 40.0
modulation_index = 1.0
time = np.arange(44100.0) / 44100.0
modulator = np.sin(2.0 * np.pi * modulator_frequency * time) * modulation_index
carrier = np.sin(2.0 * np.pi * carrier_frequency * time)
@fedden
fedden / dfo.py
Created October 10, 2017 16:34
Toy DFO Problem
# Possibly the best Machine Learning library ever
import numpy as np
# Let's print the output nicely
np.set_printoptions(precision=3, suppress=True)
# Population Size
size = 100
# How regularily the flies are dispersed
@fedden
fedden / DFOGym.ipynb
Last active October 12, 2017 19:03
Using DFO to Optimise TensorFlow Neural Networks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fedden
fedden / elitism.py
Last active October 12, 2017 17:52
dfo_elitism
for i, p in enumerate(self.population):
if elitism > 0 and i in n_fittest:
pass
@fedden
fedden / decay.py
Created October 12, 2017 18:06
dfo_decay
self.disturbance_threshold *= decay
@fedden
fedden / multi.py
Created October 12, 2017 18:11
multi_dfo
envs = [gym.make(self.env_name) for _ in range(multiprocessing.cpu_count())]
amount_per_thread = int(np.floor(self.population_size / multiprocessing.cpu_count()))
left_over = self.population_size - amount_per_thread * multiprocessing.cpu_count()
fitnesses = np.zeros(len(self.population))
def get_weights_reward(begin, size, env):
for i in range(begin, begin + size):
fitnesses[i] = -self.get_reward(self.population[i],
@fedden
fedden / god_fly.py
Created October 12, 2017 18:15
god fly dfo
swarms_best_index = np.argmin(fitnesses)
self.swarms_best_score = np.amin(fitnesses)
self.swarms_best = self.population[swarms_best_index]
if self.swarms_best_score <= self.all_time_best_score:
self.all_time_best_score = self.swarms_best_score
self.all_time_best = self.swarms_best
@fedden
fedden / original.py
Created October 12, 2017 18:22
original
if self.mode == 'original':
if r[i][x] < self.disturbance_threshold:
p[x] = np.random.normal(dev, mean)
else:
leader_rate = np.random.uniform(0.0, 1.0)
update = self.swarms_best[x] - best_neighbour[x]
p[x] = best_neighbour[x] + leader_rate * update
@fedden
fedden / hybrid.py
Created October 12, 2017 18:28
hybrid
elif self.mode == 'hybrid':
if r[i][x] < self.disturbance_threshold:
p[x] = np.random.normal(dev, mean)
else:
leader_rate = np.random.uniform(0.0, 1.0)
update = (best_neighbour[x] + self.swarms_best[x]) / 2.0 - p[x]
p[x] = p[x] + leader_rate * update