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的更多相关文章

  1. Python深度学习(Deep Learning with Python) 中文版+英文版+源代码

    Keras作者.谷歌大脑François Chollet最新撰写的深度学习Python教程实战书籍(2017年12月出版)介绍深入学习使用Python语言和强大Keras库,详实新颖.PDF高清中文版 ...

  2. Python深度学习 deep learning with Python

    内容简介 本书由Keras之父.现任Google人工智能研究员的弗朗索瓦•肖莱(François Chollet)执笔,详尽介绍了用Python和Keras进行深度学习的探索实践,涉及计算机视觉.自然 ...

  3. 机器学习(Machine Learning)&深度学习(Deep Learning)资料【转】

    转自:机器学习(Machine Learning)&深度学习(Deep Learning)资料 <Brief History of Machine Learning> 介绍:这是一 ...

  4. 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, ...

  5. 机器学习(Machine Learning)与深度学习(Deep Learning)资料汇总

    <Brief History of Machine Learning> 介绍:这是一篇介绍机器学习历史的文章,介绍很全面,从感知机.神经网络.决策树.SVM.Adaboost到随机森林.D ...

  6. 【深度学习Deep Learning】资料大全

    最近在学深度学习相关的东西,在网上搜集到了一些不错的资料,现在汇总一下: Free Online Books  by Yoshua Bengio, Ian Goodfellow and Aaron C ...

  7. 课程一(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 ...

  8. Deep Learning Libraries by Language

    Deep Learning Libraries by Language Tweet         Python Theano is a python library for defining and ...

  9. 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 ...

随机推荐

  1. HTTP的options方法作用

    1.HTTP的options方法作用 检测服务器所支持的请求方法.(比如:‘/user'路由支持哪些方法:get.post.delete...) CORS中的预检请求(检测某个接口是否支持跨域) 2. ...

  2. PHP回顾(2)

    print_r()打印输出原格式,就加上标签<pre>.例子:echo '<pre>'; print_r($arr); echo '<pre>'; 添加数组的时候, ...

  3. RPM软件管理

    1.源代码形式 绝大多数软件都是以源代码形式发布的:     因为开源的理念是不重复造轮子:让其它不以商业为目的人都能修改这个软件:   源代码一般会被打包成tar.gz的压缩归档文件: 程序源代码需 ...

  4. Word:不显示图片 + 清空“最近使用的文档”列表

     造冰箱的大熊猫,本文适用于Microsoft Office 2007@cnblogs 2019/3/4 1.Word突然不显示嵌在文本中的图片,只能看到一个空的图片框 解决办法: 1)点击Word左 ...

  5. vue中使用laydate.js插件

    1.到官网下载laydate.js https://www.layui.com/laydate/ 2.下载好后,将包解压好放在index.html同级的地方.我是在public中建立个statick文 ...

  6. SQL语句中 NOT IN 子句的“正确打开方式”

    在写SQL语句的时候,若where条件是判断用户不在某个集合当中,我们习惯使用 where 列名 not in (集合) 子句,这种写法本身没有问题,但实践过程中却发现很多人在写类似的SQL语句时,写 ...

  7. FRP

    使用 FRP 反向代理实现 Windows 远程连接 互联网普及率的日渐攀升与 IPv4 资源的持续减少,现在大部分家庭宽带都不会分配公网 IP ,这使一些网络应用的实现多了些困难,像个人的 NAS ...

  8. linux rpm包管理 yum管理

    1. 软件包的管理 RPM的定义:RPM就是Red Hat Package Manger(红帽软件包管理工具)的缩写. RPM包不需要编译,本身就是二进制,而源码包需要先编译成系统识别的二进制文件,才 ...

  9. EFI/UEFI BIOS 入门

    我们已经使用BIOS超过了二十年.可是直到今天还有许多朋友不知道BIOS到底是什么,以及它主要做些什么事情,它在整个个人计算机之中所处的地位如何.事实上,BIOS是整个计算机系统中最重要的底层系统软件 ...

  10. H264编码原理以及I帧、B和P帧详解, H264码流结构分析

    H264码流结构分析 http://blog.csdn.net/chenchong_219/article/details/37990541 1.码流总体结构: h264的功能分为两层,视频编码层(V ...