[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 ...
随机推荐
- DOM 事件流与事件处理程序
㈠事件流 ▶事件:是文档和浏览器窗口中发生的,特定的交互瞬间. ▶事件流:描述的是从页面中接受事件的顺序 ⑴DOM事件冒泡 定义:事件最开始由最具体的元素(文档中嵌套层次最深的那个节点)接受,然后 ...
- xss跨站攻击原理
https://www.cnblogs.com/frankltf/p/8975010.html 跨站脚本攻击:通过对网页注入可执行代码且成功地被浏览器执行,达到攻击的目的,一旦攻击成功,它可以获取用户 ...
- MessagePack Java 0.6.X 动态类型
我们知道 Java 是一个静态类型的语言.通过输入 Value MessagePack能够实现动态的特性. Value 有方法来检查自己的类型(isIntegerType(), isArrayType ...
- 2019牛客暑期多校训练营(第二场)A 数学
题意 eddy走一个长度为\(n\)的环,每次能往前或往后走一步,问走到\(m\)点恰好走完所有点至少一次的概率,前\(i\)个询问的答案要乘起来 分析 \(n=1,m=0\),答案为\(1\) \( ...
- go基本使用
一.第一个go语言程序 1.新建一个go项目:File--New--Progect 2.新建一个Go文件:File--New--Go File 3.在编辑区内写入下列代码: package main ...
- template模板循环嵌套循环
template嵌套循环写法:在第一次循环里面需要循环的地方再写个循环,把要循环的数据对象改为第一层的循环对象别名 //template模板循环嵌套循环 <script id="ban ...
- SpringMVC工作原理的介绍
1.用户向服务器发送请求,请求被Spring前端控制Servlet DispatcherServlet捕获 2.DispatcherServlet对请求URL进行解析,得到请求资源标识符(URL).然 ...
- State Threads之网络架构库
原文: State Threads for Internet Applications 介绍 State Threads is an application library which provide ...
- java html table 转 excel,给予jdom 和 poi
maven 引入 <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artif ...
- vue路由跳转到登录页
// 第一种 { path:'/', component: require('../components/Login.vue') }, // 第二种 { path: '/', redirect: '/ ...