简体   繁体   English

如何在神经网络中使用 3 个神经元?

[英]How To Use 3 Neuron in Neural Network?

This is a classical visualization of the perceptron learning model with 1 neuron.这是具有 1 个神经元的感知器学习 model 的经典可视化。 Let's say that I'd like to use 3 neuron or 5 neuron for training, can I do it without hidden layer?假设我想使用 3 个神经元或 5 个神经元进行训练,我可以不使用隐藏层吗? I just can't picture in my head.我只是无法在脑海中想象。 Here is the code;这是代码;

在此处输入图像描述

import numpy as np

def tanh(x):  
    return (np.exp(x)-np.exp(-x))/(np.exp(x)+np.exp(-x))

def tanh_derivative(x):
    return 1-x**2

#inputs  
training_inputs = np.array([[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]])
                          
#outputs
training_outputs =np.array([[1,0,0,1,0,1,1,0]]).T

#3 input 1 output //
synaptic_weights = 2* np.random.random((3,1))-1 
print('Random weights :{}'.format(synaptic_weights))


for i in range(20000):
    input_layer = training_inputs
    outputs = tanh(np.dot(input_layer,synaptic_weights))
    error = training_outputs - outputs
    weight_adjust = error * tanh_derivative(outputs)
    
    synaptic_weights += np.dot(input_layer.T, weight_adjust)
print('After training Synaptic Weights: {}'.format(synaptic_weights))
print('\n')
print('After training Outputs :\n{}'.format(outputs))

If you have 3 neurons in the output layer, you have three outputs.如果 output 层中有 3 个神经元,则有 3 个输出。 This makes sense for some problems - imagine a color with RGB components.这对于某些问题是有意义的——想象一下带有 RGB 分量的颜色。

The size of your input determines your number input nodes;输入的大小决定了输入节点的数量; the size of your output determines your number of output nodes. output 的大小决定了 output 节点的数量。 Only hidden layers sizes can be chosen freely.只有隐藏层大小可以自由选择。 But any interesting network has at least one hidden layer.但是任何有趣的网络都至少有一个隐藏层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在神经网络中获得“神经元边缘神经元”值的有效方法 - Efficient way to get "neuron-edge-neuron" values in a neural network 神经网络预测一个神经元的坏处 - Neural network predicts bad with one neuron 如何控制输入特征是否仅对 Tensorflow 神经网络后续层中的一个神经元有贡献? - How to control if input features contribute exclusively to one neuron in subsequent layer of a Tensorflow neural network? 神经网络模型如何为单层中的每个神经元学习不同的权重? - How do neural network models learn different weights for each of the neuron in a single layer? 如何获得神经网络中每个神经元的进出边权重? - How can I get the in and out edges weights for each neuron in a neural network? 当使用具有单个输出神经元张量流的神经网络时,损失和准确度为0 - Loss and accuracy are 0 when using a neural network with a single output neuron tensorflow 三角洲正在增长而不是在简单的一个神经元神经网络中崩溃 - Delta is growing instead of going down in simple one neuron neural network 如何加速 RPN 或 SSD 神经元网络的训练 - how to accelerate the training of RPN or SSD neuron network 如何使用经过训练的神经网络模型? - How to use a trained neural network model? 如何在神经网络中使用 IP 地址作为特征 - How to use IP address as a feature in a neural network
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM