当前位置:网站首页>一、单个神经元网络构建
一、单个神经元网络构建
2022-06-25 07:56:00 【beyond谚语】
一、本人使用编译器为Jupyter Notebook,tensorflow版本为1.13.1
import tensorflow as tf
print(tf.__version__)
""" 1.13.1 """
二、训练单个神经元网络
x为-1.0, 0.0, 1.0, 2.0, 3.0, 4.0
y为-3.0, -1.0, 1.0, 3.0, 5.0, 7.0
人用大脑很容易可以看出y=2*x-1,这里进行构建单一神经元模型去预测x=10.0时,y的值,理论应该为19,接下来看下模型的表现吧
from tensorflow import keras
import numpy as np
model = keras.Sequential([keras.layers.Dense(units=1,input_shape=[1])])
model.compile(optimizer='sgd',loss='mean_squared_error')
x = np.array([-1.0,0.0,1.0,2.0,3.0,4.0],dtype=float)
y = np.array([-3.0,-1.0,1.0,3.0,5.0,7.0],dtype=float)
model.fit(x,y,epochs=1000)
model.predict([10.0])
""" array([[18.999922]], dtype=float32) """
最终模型训练1000次,预测的结果为18.999922,与实际真实值19相差不太大
边栏推荐
猜你喜欢

InfluxDB时序数据库

¥3000 | 录「TBtools」视频,交个朋友&拿现金奖!

初识生成对抗网络(11)——利用Pytorch搭建WGAN生成手写数字

Exchange: manage calendar permissions

Index analysis of DEMATEL model

微信小程序_7,项目练习,本地生活

Easyplayer streaming media player plays HLS video. Technical optimization of slow starting speed

In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World

C language "recursive series": recursive implementation of 1+2+3++ n

NIPS 2014 | Two-Stream Convolutional Networks for Action Recognition in Videos 阅读笔记
随机推荐
[summary] 1361- package JSON and package lock JSON relationship
106. 简易聊天室9:使用 Socket 传递音频
How to increase the monthly salary of software testing from 10K to 30K? Only automated testing can do it
A 35 year old Tencent employee was laid off and sighed: a suite in Beijing, with a deposit of more than 7 million, was anxious about unemployment
How to become a software testing expert? From 3K to 17k a month, what have I done?
Unity addressable batch management
Analysis of a video website m3u8 non perceptual encryption
atguigu----18-组件
GPU calculation
开户券商怎么选择?在线开户是安全么?
声纹技术(一):声纹技术的前世今生
(翻译)采用字母间距提高全大写文本可读性的方式
Wechat applet_ 7. Project practice, local life
Stimulsoft Ultimate呈现报告和仪表板
In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World
35岁腾讯员工被裁员感叹:北京一套房,存款700多万,失业好焦虑
打新债真的安全吗? 风险大吗
《树莓派项目实战》第五节 使用Nokia 5110液晶屏显示Hello World
某视频网站m3u8非感知加密分析
Is it safe to open a stock account online now?