当前位置:网站首页>一、单个神经元网络构建
一、单个神经元网络构建
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相差不太大
边栏推荐
- How to calculate the distance between texts: WMD
- To achieve good software testing results, it is a prerequisite to build a good testing environment
- Fault: 0x800ccc1a error when outlook sends and receives mail
- Unknown table 'column of MySQL_ STATISTICS‘ in information_ schema (1109)
- 软件测试月薪10K如何涨到30K,只有自动化测试能做到
- InfluxDB时序数据库
- NIPS 2014 | Two-Stream Convolutional Networks for Action Recognition in Videos 阅读笔记
- Go language learning tutorial (13)
- 华泰证券在上面开股票账户安全吗?
- 软件确认测试有什么作用?确认测试报告的价格是多少?
猜你喜欢

Bluecmsv1.6- code audit

LVS-DR模式多网段案例

What do various optimizers SGD, adagrad, Adam and lbfgs do?

2021 "Ai China" selection

Check whether the point is within the polygon

关于I/O——内存与CPU与磁盘之间的关系

How to analyze the coupling coordination index?

《树莓派项目实战》第五节 使用Nokia 5110液晶屏显示Hello World

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

atguigu----17-生命周期
随机推荐
如何设计测试用例
mysql之Unknown table ‘COLUMN_STATISTICS‘ in information_schema (1109)
Unknown table 'column of MySQL_ STATISTICS‘ in information_ schema (1109)
Scanpy (VII) spatial data analysis based on scanorama integrated scrna seq
如何成为一名软件测试高手? 月薪3K到17K,我做了什么?
Measure the current temperature
Can I grant database tables permission to delete column objects? Why?
Software engineering review questions
What are the indicators of VIKOR compromise?
Unity Addressable批量管理
城链科技平台,正在实现真正意义上的价值互联网重构!
RTOS 多线程下hardfault问题总结
Unity--Configurable Joint——简单教程,带你入门可配置关节
声纹技术(二):音频信号处理基础
Summary of hardfault problem in RTOS multithreading
GPU calculation
Super simple case: how to do hierarchical chi square test?
How to calculate critical weight indicators?
EasyPlayer流媒体播放器播放HLS视频,起播速度慢的技术优化
Prepare these before the interview. The offer is soft. The general will not fight unprepared battles