Thenao tutorial – indexing
Theano和numpy一样,支持基本的下标取值方法和高级的下标取值方法。
因为theano中没有boolean类型,所以不支持boolean类型的masks。
# head file support
import numpy as np
numpy中的 Advanced Indexing:
高级下标取值用于获取非元组序列对象中的元素时,一般为 bdarray结构。
通常可以使用的取值方法包括:integer 和boolean
- integer indexing
>>> x = np.array([[1, 2], [3, 4], [5, 6]])
>>> x[[0, 1, 2], [0, 1, 0]]
array([1, 4, 5])
- boolean indexing
>>> x = np.array([1., -1., -2., 3])
>>> x[x < 0] += 20
>>> x
array([ 1., 19., 18., 3.])
numpy 的mask运算:
>>> n = np.arange(9).reshape(3,3)
>>> n[n > 4] # mask
array([5, 6, 7, 8])
theano中mask运算:
>>> t = theano.tensor.arange(9).reshape((3,3))
>>> t[t > 4].eval() # an array with shape (3, 3, 3)
array([[[0, 1, 2],
[0, 1, 2],
[0, 1, 2]], [[0, 1, 2],
[0, 1, 2],
[3, 4, 5]], [[3, 4, 5],
[3, 4, 5],
[3, 4, 5]]], dtype=int8)
Thenao tutorial – indexing的更多相关文章
- Latent Semantic Analysis (LSA) Tutorial 潜语义分析LSA介绍 一
Latent Semantic Analysis (LSA) Tutorial 译:http://www.puffinwarellc.com/index.php/news-and-articles/a ...
- C# Driver LINQ Tutorial
1.介绍 该教程涵盖了1.8版本的C#驱动中的LINQ查询.你可能已经阅读最新的C# Driver Tutorial. 2.快速开始 首先,给程序添加下面的using声明 using MongoDB. ...
- 【转】Multithreaded Python Tutorial with the “Threadworms” Demo
The code for this tutorial can be downloaded here: threadworms.py or from GitHub. This code works wi ...
- A Complete Tutorial to Learn Data Science with Python from Scratch
A Complete Tutorial to Learn Data Science with Python from Scratch Introduction It happened few year ...
- Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler--转载
原文地址:https://gist.github.com/maxivak/3e3ee1fca32f3949f052 Install Solr download and install Solr fro ...
- Coursera machine learning 第二周 quiz 答案 Octave/Matlab Tutorial
https://www.coursera.org/learn/machine-learning/exam/dbM1J/octave-matlab-tutorial Octave Tutorial 5 ...
- Computer Vision_18_Image Stitching: Image Alignment and Stitching A Tutorial——2006(book)
此部分是计算机视觉部分,主要侧重在底层特征提取,视频分析,跟踪,目标检测和识别方面等方面.对于自己不太熟悉的领域比如摄像机标定和立体视觉,仅仅列出上google上引用次数比较多的文献.有一些刚刚出版的 ...
- [翻译+山寨]Hangfire Highlighter Tutorial
前言 Hangfire是一个开源且商业免费使用的工具函数库.可以让你非常容易地在ASP.NET应用(也可以不在ASP.NET应用)中执行多种类型的后台任务,而无需自行定制开发和管理基于Windows ...
- Django 1.7 Tutorial 学习笔记
官方教程在这里 : Here 写在前面的废话:)) 以前学习新东西,第一想到的是找本入门教程,按照书上做一遍.现在看了各种网上的入门教程后,我觉得还是看官方Tutorial靠谱.书的弊端一说一大推 本 ...
随机推荐
- 【语言基础】c++ 基本数据类型与字节数组(string,char [] )之间的转化方法
有时候我们需要将基本数据类型转化为字节,以便写入文件,然后必要时还需要将这些字节读出来.有人说,为啥不把数字直接存进文件呢?比如:100,000,000,我们直接存数字明文到文件那就是9个字符(cha ...
- 拦截PHP各种异常和错误,发生致命错误时进行报警,万事防患于未然
在日常开发中,大多数人的做法是在开发环境时开启调试模式,在产品环境关闭调试模式.在开发的时候可以查看各种错误.异常,但是在线上就把错误显示的关闭. 上面的情形看似很科学,有人解释为这样很安全,别人看不 ...
- js10秒倒计时鼠标点击次数统计
<html> <head> <meta charset="utf-8"/> <script type="text/javascr ...
- C#中的Where和Lambda表达式
1 2 3 4 5 6 7 8 9 10 11 List<string> listString = new List<string>(); listString.Add(&qu ...
- C# EventHandler and Delegate(委托的使用)
委托的声明 public delegate void MyDelegate(string str); 注 1.委托的定义和方法的定义类似,只是在前面加了一个delegate,但委托不是方法,它是一种特 ...
- Git与GitHub到底有什么联系?
Git与GitHub区别 git 是一个软件 版本控制器 分享合并代码, 团队开发 时间机器, 可以获取到任意阶段时间节点开发的代码, 代码找回 git, cvs, bitkeeper, svn 典型 ...
- dblink连接的目标端 session不断的问题。
来源于:http://blog.itpub.net/22782896/viewspace-676842/ 1.在使用了dblink的存储过程中,可以显示的手动关闭dblink连接,具体写法如下(测试存 ...
- extJs学习基础2
一个登陆界面: Ext.onReady(function(){ Ext.define('Login', { //renderTo: Ext.getBody(), extend: 'Ext.window ...
- PHP中CURL方法curl_setopt()函数的参数
PHP CURL curl_setopt 参数 bool curl_setopt (int ch, string option, mixed value)curl_setopt()函数将为一个CURL ...
- [转]jsp与servlet的区别联系
原文地址:http://bbs.itheima.com/thread-28972-1-1.html Servlet是Java提供的用于开发Web服务器应用程序的一个组件,运行在服务器端,由Servle ...