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

  1. Latent Semantic Analysis (LSA) Tutorial 潜语义分析LSA介绍 一

    Latent Semantic Analysis (LSA) Tutorial 译:http://www.puffinwarellc.com/index.php/news-and-articles/a ...

  2. C# Driver LINQ Tutorial

    1.介绍 该教程涵盖了1.8版本的C#驱动中的LINQ查询.你可能已经阅读最新的C# Driver Tutorial. 2.快速开始 首先,给程序添加下面的using声明 using MongoDB. ...

  3. 【转】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 ...

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

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

  6. Coursera machine learning 第二周 quiz 答案 Octave/Matlab Tutorial

    https://www.coursera.org/learn/machine-learning/exam/dbM1J/octave-matlab-tutorial Octave Tutorial 5  ...

  7. Computer Vision_18_Image Stitching: Image Alignment and Stitching A Tutorial——2006(book)

    此部分是计算机视觉部分,主要侧重在底层特征提取,视频分析,跟踪,目标检测和识别方面等方面.对于自己不太熟悉的领域比如摄像机标定和立体视觉,仅仅列出上google上引用次数比较多的文献.有一些刚刚出版的 ...

  8. [翻译+山寨]Hangfire Highlighter Tutorial

    前言 Hangfire是一个开源且商业免费使用的工具函数库.可以让你非常容易地在ASP.NET应用(也可以不在ASP.NET应用)中执行多种类型的后台任务,而无需自行定制开发和管理基于Windows ...

  9. Django 1.7 Tutorial 学习笔记

    官方教程在这里 : Here 写在前面的废话:)) 以前学习新东西,第一想到的是找本入门教程,按照书上做一遍.现在看了各种网上的入门教程后,我觉得还是看官方Tutorial靠谱.书的弊端一说一大推 本 ...

随机推荐

  1. Linux学习笔记-Ubuntu添加右键菜单打开终端

    1.进入个人目录(如/home/batsing,下文缩写成 ~ ):设置显示隐藏文件,或使用命令行:2.进入 ~/.gnome2/nautilus-scripts 文件夹,新建一个文件,名为 term ...

  2. 由一次程序崩溃引起的对new表达式的再次学习

    1. 起因 某天,一个同事跟我反馈说在windows上调试公司产品的一个交易核心时出现了使用未初始化的指针导致后台服务崩溃的情况.示例代码如下所示: struct sample { ][]; //.. ...

  3. gravity、layout_gravity及orientation

    gravity.layout_gravity及orientation 最近在弄一个简单的界面:横向,添加一张准备好的背景图,在界面右边居中放置一个按钮.实现过程中发现对布局的主要属性没有想象中地那么熟 ...

  4. WPF学习之路由事件

    原文:http://www.cnblogs.com/lxy131/archive/2010/08/10/1796754.html WPF中新添加了一种事件---路由事件 路由事件与一般事件的区别在于: ...

  5. Web Api通过Route、RoutePrefix等特性设置路由

    [Route("customers/{customerId}/orders")] [HttpGet] public IEnumerable<Order> FindOrd ...

  6. BGP--边界网关协议

    要全面了解BGP,首先我们要回答以下看上去很简单的问题:为什么需要BGP,也就是说BGP是如何产生的,它解决了什么问题.带着以上问题,我们先简单的回顾一个路由协议发展的轨迹. 首先路由的实质是描述一个 ...

  7. python2.X和3.X的一些区别【整理中】

    1.性能 Py3.0运行 pystone benchmark的速度比Py2.5慢30%.Guido认为Py3.0有极大的优化空间,在字符串和整形操作上可  以取得很好的优化结果.  Py3.1性能比P ...

  8. 1021mysql 全外连接

    mysql 不支持全外连接,那么使用union all进行替换 -- 其他数据库 SELECT * FROM aa aFULL OUTER JOIN bb b ON a.col1=b.col1AND ...

  9. dblink连接的目标端 session不断的问题。

    来源于:http://blog.itpub.net/22782896/viewspace-676842/ 1.在使用了dblink的存储过程中,可以显示的手动关闭dblink连接,具体写法如下(测试存 ...

  10. EM算法

    EM算法的推导