def is_connect_exist_nn(node_in, node_out, nn):
"""
check if the connection between node_in and node_out exists
:param node_in:
:param node_out:
:param nn: Neural network instance
:return: True if exists, False if DNE
"""
assert type(nn) == NeuralNetwork, "nn must be an instance of Neural Network"
if nn.connect_genes is None:
return False
connect = [node_in, node_out]
history = nn.connect_genes[:, :2]
return any(np.equal(connect, history).all(1))
评论列表
文章目录