|

楼主 |
发表于 2021-3-5 16:32:48
|
显示全部楼层
import numpy as np
sol_per_pop = 2
initial_pop_weights = []
for curr_sol in np.arange(0, sol_per_pop):
HL1_neurons = 5
input_HL1_weights = np.random.uniform(low=-0.1, high=0.1,
size=(5, HL1_neurons))
HL2_neurons = 3
HL1_HL2_weights = np.random.uniform(low=-0.1, high=0.1,
size=(HL1_neurons, HL2_neurons))
output_neurons = 2
HL2_output_weights = np.random.uniform(low=-0.1, high=0.1,
size=(HL2_neurons, output_neurons))
initial_pop_weights.append(np.array([input_HL1_weights,
HL1_HL2_weights,
HL2_output_weights]))
pop_weights_mat = np.array(initial_pop_weights)
print(pop_weights_mat)
print(pop_weights_mat.shape)
print(pop_weights_mat.ndim)
|
|