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. 一、基本的bash shell命令(基于Ubuntu实现)

    一.基本的bash shell命令(基于Ubuntu实现) /etc/passwd文件包含了所有系统用户账户列表以及每个用户的基本配置信息. man命令 在想要查找的工具的名称前输入man命令,就可以 ...

  2. JVM系列大纲

    本系列主要分析JVM主要功能要点,初步大纲如下,会根据写作情况进行细化,目的在于梳理JVM的知识体系,具体分析文章会陆续发布. [JVM]类加载机制(1) [JVM]Java内存区域(2) [JVM] ...

  3. 线程系列5--java中的ThreadLocal类实现线程范围内的数据共享(二)

    ThreadLocal类可以理解成一个类似与map集合使用,以当前线程当做key 来使用,将线程氛围内需要共享的数据当做value,形成键值对的形式使用.ThreadLocal和线程同步机制都是为了解 ...

  4. mysql基础知识语法汇总整理(二)

    mysql基础知识语法汇总整理(一) insert /*insert*/ insert into 表名(字段列表) values(值列表); --蠕虫复制 (优点:快速复制数据,测试服务器压力) in ...

  5. IP输出 之 ip_output、ip_finish_output、ip_finish_output2

    概述 ip_output-设置输出设备和协议,然后经过POST_ROUTING钩子点,最后调用ip_finish_output: ip_finish_output-对skb进行分片判断,需要分片,则分 ...

  6. redis如何清空当前缓存和所有缓存

    Windows环境下使用命令行进行redis缓存清理1.redis安装目录下输入cmd2.redis-cli -p 端口号3.flushdb    清除当前数据库缓存4.flushall     清除 ...

  7. 解释HTTP中Get和Post。它们有什么区别,哪个使用时更加安全?

    Get和Post都是浏览器向网页服务器提交数据的方法. Get把要提交的数据编码在url中,比如/workinfo.jsp/mianshiti?key1=value1&key2=value2中 ...

  8. Activity的screenOrientation属性

    activity在屏幕当中显示的方向.属性值可以是下表中列出的一个值: "unspecified" 默认值,由系统来选择方向.它的使用策略,以及由于选择时特定的上下文环境,可能会因 ...

  9. 微服务一键启动脚本shell没有环境变量的

    #!/bin/bash#######################################################export JAVA_HOME=/root/data/app/jd ...

  10. 配置Log4j 详解

    Log4J的配置文件(Configuration File)就是用来设置记录器的级别.存放器和布局的,它可接key=value格式的设置或xml格式的设置信息.通过配置,可以创建出Log4J的运行环境 ...