Skip to content

Instantly share code, notes, and snippets.

@vedraiyani
vedraiyani / how-to-develop-a-1d-generative-adversarial-network-from-scratch-in-keras.ipynb
Created September 24, 2019 09:30
How to Develop a 1D Generative Adversarial Network From Scratch in Keras.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
from hyperopt import hp, tpe, fmin
# Single line bayesian optimization of polynomial function
best = fmin(fn = lambda x: np.poly1d([1, -2, -28, 28, 12, -26, 100])(x),
space = hp.normal('x', 4.9, 0.5), algo=tpe.suggest,
max_evals = 2000)
@geffy
geffy / stacking_example.py
Created October 7, 2017 17:33
Stacking example
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 23 23:16:44 2017
@author: Marios Michailidis
This is an example that performs stacking to improve mean squared error
This examples uses 2 bases learners (a linear regression and a random forest)
and linear regression (again) as a meta learner to achieve the best score.
The initial train data are split in 2 halves to commence the stacking.
@geffy
geffy / bagging.py
Created October 7, 2017 17:21
Example of bagging
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 23 23:16:44 2017
@author: Marios Michailidis
This is an example of a simple method that performs bagging
"""
@macromaniac
macromaniac / regression.py
Created September 17, 2016 18:47
simple linear regression example using keras
import numpy as np
from keras.layers import Dense, Input
from keras.models import Model
x = Input((1,))
y = Dense(1, activation ='linear')(x)
m = Model(x,y)
m.compile(loss = 'mse', optimizer='sgd')
_x = np.linspace(1,2, num = 1e3)
@captainsafia
captainsafia / pe_019.py
Created August 18, 2012 21:56
Solution to Project Euler Problem 19 in Python
from datetime import date
sundays=0
for year in range(1901,2001):
for month in range(1,13):
if date(year,month,1).weekday()==6:
sundays+=1
print sundays