code
stringlengths
3
6.57k
Sequential()
Dense(L1, activation = 'relu', input_dim = INPUT_DIM, kernel_initializer='uniform')
Conv2D(L1, FILTER_SIZE_1, activation='relu', input_shape = INPUT_SHAPE, kernel_initializer='uniform')
model.add(layer1)
model.add(MaxPooling2D(pool_size=POOLING_SIZE)
Conv2D(L2, FILTER_SIZE_2, activation='relu', kernel_initializer='uniform')
model.add(layer2)
model.add(MaxPooling2D(pool_size=POOLING_SIZE)
model.add(Dropout(0.25)
model.add(Flatten()
Dense(L3, activation = 'relu', kernel_initializer='uniform')
model.add(layer3)
Dense(L4, activation ='softmax', kernel_initializer='uniform')
model.add(layer4)
Adam(lr=0.01)
model.compile(loss='mean_squared_error', optimizer=adam)
model.get_weights()
print(len(weights)
print("====================================")
applyPolicyVectorToNN(policyVector)
reshape(FILTER_SIZE_1[0], FILTER_SIZE_1[1], INPUT_SHAPE[2], L1)
reshape(FILTER_SIZE_2[0], FILTER_SIZE_2[1], L1, L2)
reshape(FINAL_DIMENSION_X*FINAL_DIMENSION_Y*L2, L3)
reshape(L3, L4)
nnFormat.append(sec1)
nnFormat.append(sec2)
nnFormat.append(sec3)
nnFormat.append(sec4)
nnFormat.append(sec5)
nnFormat.append(sec6)
nnFormat.append(sec7)
nnFormat.append(sec8)
selection(scores, population)
np.zeros((ELITE_SET_SIZE,calculatePolicySize()
np.copy(scores)
range(ELITE_SET_SIZE)
np.argmax(scoresTemp)
cross(policy1, policy2)
policy1.copy()
np.random.randint(2, size=newPolicy.shape)
astype(np.bool)
range(calculatePolicySize()
np.random.uniform()
crossover(scores, population)
np.zeros((POPULATION_SIZE,calculatePolicySize()
np.array(scores)
np.sum(scores)
range(POPULATION_SIZE - ELITE_SET_SIZE)
np.random.choice(range(POPULATION_SIZE)
np.random.choice(range(POPULATION_SIZE)
cross(policy1, policy2)
mutation(crossoverPopulation)
int((POPULATION_SIZE - ELITE_SET_SIZE)
np.random.random_sample()
int(calculatePolicySize()
np.random.random_sample()
range(int(i*j*MUTATION_RATE)
np.random.random_sample()
range(POPULATION_SIZE - ELITE_SET_SIZE)
range(calculatePolicySize()
np.random.uniform()
if(rand < MUTATION_RATE)
np.random.random_sample()
generateNewGeneration(scores, population)
selection(scores, population)
crossover(scores, population)
mutation(crossoverPopulation)
range(ELITE_SET_SIZE)
saveHighestScorePolicy(population, generation, scores)
if (generation % 10 == 0)
np.argmax(scores)
str(generation)
str(scores[index])
np.save(os.path.join('SavedScores', filename)
print("Saved generation to file "+filename)
loadPolicy(filename, population, index)
np.load(filename)
print("Loaded\n",policy)
measureTime()
time.time()
test_selection()
quit()
env.reset()
initPopulation()
loadPolicy('generation0.npy',population,0)
buildModel()
time.time()
writeCsv(4, time.time()
while (keepTraining)
evaluate(dnnmodel, population, generation*POPULATION_SIZE)
print(int(measureTime()
np.max(scores)
writeCsv(0, generation)
writeCsv(1, np.max(scores)
if (np.max(scores)
np.max(scores)
writeCsv(5, all_time_high_score)
saveHighestScorePolicy(population, generation, scores)
generateNewGeneration(scores, population)
print(int(measureTime()