Exemple #1
0
import deap
#import NN
from walker_NN import NNN
from deap import base
from deap import creator
from deap import tools
import math
import gym
import random
from gym import wrappers
import time
import numpy as np
from deap import algorithms

nn = NNN()
env = gym.make("BipedalWalker-v2")
MAX_STEPS = 3700
w_list = []


def forward(network, X):
    def sigmoid(x):
        return 1 / (1 + np.exp(-x))

    W1, W2, W3 = network['W1'], network['W2'], network['W3']
    b1, b2, b3 = network['B1'], network['B2'], network['B3']
    a1 = np.dot(X, W1) + b1
    a1 = np.dot(X, W1) + b1
    z1 = a1
    a2 = np.dot(z1, W2) + b2
Exemple #2
0
from walker_NN import NNN
from deap import base
from deap import creator
from deap import tools
import math
import gym
import random
from gym import wrappers
import time
import numpy as np
from deap import algorithms
import pickle

NGEN = 300
env = gym.make("BipedalWalker-v2")
nn = NNN()
POPNUM = 250
MAX_STEPS = 3700
w_list = []
# In[9]:
count = 0
CXPB = 0.5
MUTPB = 0.1
creator.create(
    "FitnessMax",
    base.Fitness,
    weights=[1.0],
)
creator.create("Individual", list, fitness=creator.FitnessMax)

toolbox = base.Toolbox()