This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections.abc import Sequence | |
from copy import deepcopy | |
from functools import wraps | |
from typing import Callable | |
import numpy | |
MAXIMIZE = 1.0 | |
MINIMIZE = -1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import factorial | |
from pymoo.optimize import minimize | |
from pymoo.util import plotting | |
from pymoo.util.reference_direction import UniformReferenceDirectionFactory | |
from pymop.factory import get_problem | |
from pymoo.algorithms.nsga3 import nsga3 | |
import matplotlib.pyplot as plt | |
import numpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import numpy | |
from deap import cma | |
class CovarianceConditionError(Exception): | |
pass | |
class StrategyMixedInteger(cma.Strategy): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is part of DEAP. | |
# | |
# DEAP is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Lesser General Public License as | |
# published by the Free Software Foundation, either version 3 of | |
# the License, or (at your option) any later version. | |
# | |
# DEAP is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def inflate(d, sep="_"): | |
items = dict() | |
for k, v in d.items(): | |
keys = k.split(sep) | |
sub_items = items | |
for ki in keys[:-1]: | |
try: | |
sub_items = sub_items[ki] | |
except KeyError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
End of evolution after 80 generations | |
MU = 10, LAMBDA = 100 | |
Population of the generation number 79 : | |
(array('d', [0.3384816385414553, 0.2913862946297661, 0.6391631079035605, 99.78019922362375, 0.9999999999999991]), (100.78019922362375, 102.04923026469854)) | |
(array('d', [0.12725983751030595, 0.06852642494740502, 0.2944790143036873, -80.78193202686674, 0.9999999999999988]), (-79.78193202686674, -79.29166675010535)) | |
(array('d', [0.32497537960481293, 0.30232682417375684, 0.6611237261340428, 34.76077835597124, 0.999999999999999]), (35.76077835597124, 37.04920428588385)) | |
(array('d', [0.12518823446474206, 0.05982068209343572, 0.2846256754372451, -24.98563318764257, 0.9999999999999986]), (-23.98563318764257, -23.515998595647147)) | |
(array('d', [0.16447172340744912, -0.37862460917923624, 0.2425460722676009, -0.8978315694776402, 0.9999999999999983]), (0.10216843052235813, 0.13056161701817193)) | |
(array('d', [0.17269510499090013, -0.3647635822434079, 0.27057986499062364, 8.828981876870646, 0.9999999999999986]), (9.828981876 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def shuffled_iterator(iterator, look_ahead=5000, skip=0, seed=None): | |
"""Return an iterator on the shuffled (part) of the provided *iterator*. | |
This iterator consumes the provided iterator to turn it into a shuffled | |
version. The cunsumption can be limited by the *lookahead* argument that | |
limits the view of the operator. The *skip* argument flushes the first n | |
items of the provided *iterator* and the *seed* allow for repetability. | |
""" | |
rng = numpy.random.RandomState(seed) | |
batch = list(itertools.islice(iterator, skip, skip+look_ahead)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lasagne.layers import * | |
from lasagne.nonlinearities import sigmoid | |
import lasagne | |
import numpy | |
import theano | |
import theano.tensor as T | |
def build_network(input_shape, input_var, num_units): | |
nnet = dict() | |
nnet["input"] = InputLayer(input_shape, input_var, name="input") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lasagne | |
import numpy | |
import theano | |
import theano.tensor as T | |
def get_data(): | |
return numpy.random.randn(200, 32, 32), numpy.random.randint(2, size=(200, 1)) | |
def build_ae(input_shape, input_var): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from scipy.ndimage.interpolation import map_coordinates | |
from scipy.ndimage.filters import gaussian_filter | |
def elastic_transform(image, alpha, sigma, random_state=None): | |
"""Elastic deformation of images as described in [Simard2003]_. | |
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for | |
Convolutional Neural Networks applied to Visual Document Analysis", in |
NewerOlder