是否存在从一组节点中随机选择节点的神经网络(以随机顺序和随机次数)?

人工智能 神经网络 机器学习
2021-11-09 11:52:12

我正在尝试做一个分类器。

我是 AI 新手(即使我知道定义之类的东西),即使我知道一点 Python 编码,我也不知道如何正确地实现它(事实上,我已经 15 岁了)老!🙄🙄),但我对此的热情让我问了这个(可能是愚蠢的)问题。

是否存在从一组节点中随机选择节点的神经网络(以随机顺序和随机次数)?我知道这是来自 ML(或者可能是深度学习,我想),但我不知道如何从目前可用的算法中识别出这样的东西。如果你们都可以帮助我,那就太好了,因为我正准备发布一个 API 来编程我在 GitHub 上称为“Insane Mind”的模型,我想要一些帮助来了解我的努力是否没有结果。

作为参考,这里是代码:

from math import *
from random import *
 
class MachineError(Exception):
    '''standard exception in the API'''
    def __init__(self, stmt):
        self.stmt = stmt
def sig(x):
    '''Sigmoid function'''
    return (exp(x) + 1)/exp(x)

class Graviton:
    def __init__(self, weight, marker):
        '''Basic unit in 'Insane Mind' algorithm
           -------------------------------------
           Graviton simply refers to a node in the algorithm.
           I call it graviton because of the fact that it applies a weight
           on the input to transform it, besides using the logistic function '''
        self.weight = weight # Weight factor of the graviton
        self.marker = marker # Marker to help in sorting
        self.input = 0 # Input to the graviton
        self.output = 0 # Output of the graviton
        self.derivative = 0 # Derivative of the output

    def process(self, input_to_machine):
        '''processes the input (a bit of this is copied from the backprop algorithm'''
        self.input = input_to_machine
        self.output = (sig(self.weight * self.input) - 1)/(self.marker + 1)
        self.derivative = (sig(self.input * self.weight) - 1) * self.input *self.output * (1- self.output) 
        return self.output
    
    def get_derivative_at_input(self):
        '''returns the derivative of the output'''
        return self.derivative

    def correct_self(self, learning_rate, error):
        '''edits the weight'''
        self.weight += -1 * error * learning_rate * self.get_derivative_at_input() * self.weight
        
class Insane_Mind:

    def __init__(self, number_of_nodes):
        '''initialiser for Insane_Mind class.
           arguments : number_of_nodes : the number of nodes you want in the model'''
        self.system = [Graviton(random(),i) for i in range(number_of_nodes)] # the actual system
        self.system_size = number_of_nodes # number of nodes , or 'system size'
        
    def  output_sys(self, input_to_sys):
        '''system output'''
        self.output = input_to_sys
        for i in range(self.system_size):
            self.output = self.system[randint(0,self.system_size - 1 )].process(self.output)
        return self.output
    
    def train(self, learning_rate, wanted):
        '''trains the system'''
        self.cloned = [] # an array to keep the sorted elements during the sorting process below
        order = [] # the array to make out the order of arranging the nodes
        temp = {} # a temporary dictionary to pick the nodes from
        for graviton in self.system:
            temp.update({str(graviton.derivative): graviton.marker})
        order = sorted(temp)
        i = 0
        error = wanted - self.output
        for value in order:
            self.cloned.append(self.system[temp[value]])
            self.cloned[i].correct_self(learning_rate, error)
            error *= self.cloned[i].derivative
            i += 1
        self.system = self.cloned

很抱歉没有MachineError在我的代码中的任何地方使用该异常(我将在能够部署此 API 时使用它)。

为了更多地了解这个算法,这给出了随机输出(就像猜测一样)。猜测的数量从 1(对于具有一个节点的系统)、2(对于两个节点)等到无限数量的节点的无限猜测。

另外,我想尝试找出它有多少用处(如果这是从未被发现的东西,如果它可以在 ML 或深度学习的世界中找到一个好地方)以及它可以在哪里使用.

提前致谢。

批评(有明确的理由)也被接受。

1个回答

很难证明是否定的,但我认为没有任何分类器(神经网络或其他)完全符合您的想法。

我怀疑您将无法在运行时采用随机连接和循环的想法,并从中制作出有用的分类器。这并不是说这个想法完全没有价值,有时探索蓝天的想法并看看会发生什么是好的。然而,我认为在没有一些基本的基础工作的情况下,在你的想法之上构建任何东西可能是一个令人沮丧的练习。我建议您将逻辑回归的理论和实现作为起点,这是理解神经网络的一个很好的垫脚石。

有一些神经网络组件和架构在激活级别使用随机行为:

  • 辍学这是在训练期间使用的一种方法,它将随机选择的神经元的输出归零。它通常可以有效地提高神经网络的稳定性(防止过度拟合输入数据),并且由于其行为类似于拥有多个更简单的分类器,因此也可以提高分类器的准确性。

  • 玻尔兹曼机受限玻尔兹曼机 (RBM)从每个“神经元”单元随机输出 0 或 1,概率由输入总和决定。它们用于创建生成模型,而不是分类器。另一个区别是在训练和推理过程中都应用了随机性,而 dropout 最常用于增强训练。在深度学习的早期,RBM ​​被用于对深度神经网络中的层进行预训练。这是有效的,但后来发现了其他更简单的方法,现在在大多数情况下都是首选方法。

  • 在推理时使用一种称为Monte Carlo dropout的 dropout 调用变体。这可用于衡量模型单个预测中的不确定性,否则很难获得。

  • 虽然不像每个神经元的随机连接那样自由。如果您将 dropout 应用于循环神经网络,那可能与您的想法非常接近,因为每个时间步长中神经元之间存在的循环将是随机的。这可以应用于序列数据的语言建模和分类器。与更简单的前馈分类器中的 dropout 相同的动机在这里适用——理论上它可以使分类器对输入中的噪声更鲁棒并且更准确。