进化算法似乎没有取得任何进展

时间:2017-10-08 07:21:16

标签: neural-network genetic-algorithm evolutionary-algorithm

我试图改变价值观以调整它们但我觉得我的代码不够好。我最大的问题是,这些值的范围是-.5到.5,这使得很难从父母那里得到什么。 (顺便说一下,我演化的是神经网络中的权重)

def mutate_array(self, inher1, inher2):

    shape = inher1.shape
    random_values = 2 * np.random.rand(*shape) - 1
    mutatings = np.random.rand(*shape) < self.entropy
    one_chance = (np.random.rand(*shape) <= 0.5)
    new_values = np.array(inher2)
    new_values[one_chance] = np.array(inher1[one_chance])
    new_values[mutatings] += random_values[mutatings]
    return new_values

其中inher1和inher2是来自父母的2个数组,而self.entropy是变量(也是进化的)在0.05 - 0.2之间

当我尝试这样做时我得到的是完全失败。

0 个答案:

没有答案