Skip to content

Instantly share code, notes, and snippets.

View guillefix's full-sized avatar

Guillermo Valle guillefix

View GitHub Profile
{
"description": "Basic client-server edition",
"plugins": [
"tiddlywiki/tiddlyweb",
"tiddlywiki/filesystem",
"tiddlywiki/highlight"
],
"themes": [
"tiddlywiki/vanilla",
"tiddlywiki/snowwhite",
@guillefix
guillefix / dydt.m
Created November 24, 2016 16:07
Model for DTC matlab course
function res = dydt(t,y,S, w)
indices2={[1,5], [11], [11], [2,5], [12], [12], [5,13], [12,6], [3,9], [14], [14], [4,9], [15], [15], [7,7], [12], [2,6], [13], [10,6], [16], [10,13], [17], [17], [8], [7], [6], [4], [3]};
% w=ones(28,1);
% w=randn(28,1);
v = w;
for j=1:28
for i=indices2{j}
v(j) = v(j) * y(i);
end
end
import numpy as np
import gym
import matplotlib.pyplot
from math import *
import tensorflow as tf
from keras.layers import Input, Dense, concatenate
from keras.models import Sequential, Model
env = gym.make('CartPole-v1')
@guillefix
guillefix / sandbox.py
Last active January 11, 2018 16:20
Neuroevolution in 50 lines of code
import random
from deap import creator, base, tools, algorithms
from scoop import futures
toolbox = base.Toolbox()
toolbox.register("map", futures.map)
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
number_of_parameters = 100
size_of_population = 100
@guillefix
guillefix / folding.py
Created March 1, 2018 13:21
Simulation of the folding of the decision boundary by a ReLU neural networks with 2-neurons-per-layer (2-dimensional)
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.collections import LineCollection
%matplotlib inline
def find_intersection(p1,p2,coord):
if coord == 1: coord2 = 2
if coord == 2: coord2 = 1
@guillefix
guillefix / lc.py
Last active May 10, 2020 14:00
temporal workaround to get Conv2dLocal to work in PyTorch
# coding: utf-8
# In[1]:
import math
import torch
from torch.nn.parameter import Parameter
import torch.nn.functional as F
@guillefix
guillefix / pyspark_boilerplate.py
Created February 27, 2019 23:48
Pyspark boilerplate
import os
import sys
# os.environ["PYSPARK_PYTHON"]="/usr/local/shared/python/3.6.3/bin/python3"
# os.environ["PYSPARK_DRIVER_PYTHON"]="/usr/local/shared/python/3.6.3/bin/python3"
#pip3 install pyspark
from pyspark import SparkContext
sc = SparkContext.getOrCreate()
print(sc._jsc.sc().getExecutorMemoryStatus())
#!/bin/bash
comp=$(hostname)
url=$(curl -s 127.0.0.1:4040/api/tunnels | jq -r '.tunnels[0].public_url')
curl -X POST -H "Content-Type: application/json" -d '{"value1":"'${url}'","value2":"'${comp}'"}' https://maker.ifttt.com/trigger/ngrok_url/with/key/[iftt key]
echo
@guillefix
guillefix / get_furs.py
Last active February 27, 2020 02:36
scrape621
import os
import sys
import pandas as pd
if not os.path.exists("floofs"):
os.mkdir("floofs")
d = pd.read_csv("e621_"+sys.argv[1]+".csv")
d=d[d["rating"]=="s"]
import urllib.request
@guillefix
guillefix / setitup.sh
Last active February 28, 2020 00:20
setup thing for nn-pacbayes
sudo apt-get update
sudo apt-get install libcr-dev mpich
#apt install python3-pip
#pip3 install tensorflow
pip3 install mpi4py pandas torch torchvision GPy matplotlib tensorflow_probability==0.7 keras
sudo apt-get install htop
#then edit the GPy file. should send them a pull request..