欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

针对分类问题的单隐层前馈神经网络模型

程序员文章站 2022-06-14 12:48:21
...

针对分类问题的单隐层前馈神经网络模型


针对分类问题的单隐层前馈神经网络模型

针对分类问题的单隐层前馈神经网络模型


以下代码片内容为周志华著《机器学习》习题5.5的自编程序。


# 周志华《机器学习》习题5.5
import random
import numpy as np
import matplotlib.pyplot as plt

DataSet = [[0.697,0.460,1,0],
           [0.774,0.376,1,0],
           [0.634,0.264,1,0],
           [0.608,0.318,1,0],
           [0.556,0.215,1,0],
           [0.403,0.237,1,0],
           [0.481,0.149,1,0],
           [0.437,0.211,1,0],
           [0.666,0.091,0,1],
           [0.243,0.267,0,1],
           [0.245,0.057,0,1],
           [0.343,0.099,0,1],
           [0.639,0.161,0,1],
           [0.657,0.198,0,1],
           [0.360,0.370,0,1],
           [0.593,0.042,0,1],
           [0.719,0.103,0,1]]



AttrSet = ['Density','Sugar','Quality']

NumInCell = 2
NumMidCell = 8
NumOutCell = 2

Vih = [[random.random()*1 for m in range(NumInCell)] for n in range(NumMidCell)]
Rh = [random.random()*1 for m in range(NumMidCell)]
Whj = [[random.random()*1 for m in range(NumMidCell)] for n in range(NumOutCell)]
Sj = [random.random()*1 for m in range(NumOutCell)]

MaxTimes = 10000
Time = 0
Yeta = 1
Loss = []
while Time