[python] a little deep learning case
from numpy import exp, array, random, dot class NeuralNetwork():
def __init__(self):
random.seed(1)
self.synaptic_weights = 2 * random.random((3,1)) - 1 def __sigmoid(self, x):
return 1 / (1 + exp(-x)) def __sigmoid_derivative(self, x):
return x*(1-x) def train(self, training_set_inputs, training_set_outputs, number_of_training_iterations):
for iteration in range(number_of_training_iterations):
output = self.think(training_set_inputs)
error = training_set_outputs - output
adjustment = dot(training_set_inputs.T, error*self.__sigmoid_derivative(output))
self.synaptic_weights += adjustment def think(self, inputs):
return self.__sigmoid(dot(inputs, self.synaptic_weights)) if __name__ == '__main__':
neural_network = NeuralNetwork()
print('随机的初始突触权重')
print(neural_network.synaptic_weights) training_set_inputs = array([[0,0,1], [1,1,1], [1,0,1], [0,1,1]])
training_set_outputs = array([[0,1,1,0]]).T neural_network.train(training_set_inputs, training_set_outputs, 10000) print('训练后的突触权重')
print(neural_network.synaptic_weights) print('考虑新的形势[1, 0, 0]')
print(neural_network.think(array([1, 0, 0])))
[python] a little deep learning case的更多相关文章
- Python深度学习(Deep Learning with Python) 中文版+英文版+源代码
Keras作者.谷歌大脑François Chollet最新撰写的深度学习Python教程实战书籍(2017年12月出版)介绍深入学习使用Python语言和强大Keras库,详实新颖.PDF高清中文版 ...
- Python深度学习 deep learning with Python
内容简介 本书由Keras之父.现任Google人工智能研究员的弗朗索瓦•肖莱(François Chollet)执笔,详尽介绍了用Python和Keras进行深度学习的探索实践,涉及计算机视觉.自然 ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料【转】
转自:机器学习(Machine Learning)&深度学习(Deep Learning)资料 <Brief History of Machine Learning> 介绍:这是一 ...
- What are some good books/papers for learning deep learning?
What's the most effective way to get started with deep learning? 29 Answers Yoshua Bengio, ...
- 机器学习(Machine Learning)与深度学习(Deep Learning)资料汇总
<Brief History of Machine Learning> 介绍:这是一篇介绍机器学习历史的文章,介绍很全面,从感知机.神经网络.决策树.SVM.Adaboost到随机森林.D ...
- 【深度学习Deep Learning】资料大全
最近在学深度学习相关的东西,在网上搜集到了一些不错的资料,现在汇总一下: Free Online Books by Yoshua Bengio, Ian Goodfellow and Aaron C ...
- 课程一(Neural Networks and Deep Learning),第一周(Introduction to Deep Learning)—— 1、经常提及的问题
Frequently Asked Questions Congratulations to be part of the first class of the Deep Learning Specia ...
- Deep Learning Libraries by Language
Deep Learning Libraries by Language Tweet Python Theano is a python library for defining and ...
- How to Grid Search Hyperparameters for Deep Learning Models in Python With Keras
Hyperparameter optimization is a big part of deep learning. The reason is that neural networks are n ...
随机推荐
- perl 纯变量(Scalar) 转载
转载http://blog.chinaunix.net/uid-20639775-id-154591.html Perl有三种变量: 纯变量(Scalar Varible) 数组(Array) 关联数 ...
- 20190716NOIP模拟赛T2 通讯(tarjan缩点+贪心)
题目描述 “这一切都是命运石之门的选择.” 试图研制时间机器的机关SERN截获了中二科学家伦太郎发往过去的一条短 信,并由此得知了伦太郎制作出了电话微波炉(仮). 为了掌握时间机器的技术,SERN总部 ...
- jQuery属性操作之类样式操作
类样式的操作:指对DOM属性className进行添加.移除操作.比如addClass().removeClass().toggleClass(). 1. addClass() 1.1 概述 $(se ...
- 服务器上class文件是新的,但就是执行的老代码
故事是这样的. 上周末回老家,n个测试和开发找我,说我写的代码哪儿哪儿不行,吓得我赶紧打开电脑,连上阿里云数据库,修改了代码,测试们拉包重新测试后,还是不行,通过看打出的日志,还是执行的修改之前的代码 ...
- js一维数组转换为二维数组
function arrTrans(num, arr) { // 一维数组转换为二维数组 const iconsArr = []; // 声明数组 arr.forEach((item, index) ...
- MySQL_(Java)使用JDBC创建用户名和密码校验查询方法
MySQL_(Java)使用JDBC向数据库发起查询请求 传送门 MySQL数据库中的数据,数据库名garysql,表名garytb,数据库中存在的用户表 通过JDBC对MySQL中的数据用户名和密码 ...
- 初学 Nginx (一) SSI 的作用
SSI:Server Side Include,是一种基于服务端的网页制作技术, Nginx ssi 的例子如下: It took a little while to figure this out ...
- truncate at 255 characters with xlsx files(OLEDB方式读取Excel丢失数据、字符串截断的原因和解决方法)
The TypeGuessRows setting is supported by ACE. Note the version numbers in the key may change depend ...
- 2.HDFS和HA
1.HDFS简介 DataNode NameNode SecondaryNameNode HDFS文件权限 2.HDFS小结 3.HDFS交互操作 4.HDFS编程访问接口
- 手把手教你 iOS通过自己的服务器实现应用分发
第一步:打包ipa 1:可以是development.ad-hoc.enterprise任何一种打包方式,导出的ipa, 稍后会将安装包上传到服务器上. 2:如下图,箭头指的要打勾 3.点击下一步后出 ...