.. currentmodule:: tensor
===========================
Basic Tensor Functionality
===========================
Theano supports any kind of Python object, but its focus is support for
symbolic matrix expressions. When you type,
>>> x = T.fmatrix()
the ``x`` is a :class:`TensorVariable` instance.
The ``T.fmatrix`` object itself is an instance of :class:`TensorType`.
Theano knows what type of variable ``x`` is because ``x.type``
points back to ``T.fmatrix``.
This chapter explains the various ways of creating tensor variables,
the attributes and methods of :class:`TensorVariable` and :class:`TensorType`,
and various basic symbolic math and arithmetic that Theano supports for
tensor variables.
.. _libdoc_tensor_creation:
Creation
========
Theano provides a list of predefined tensor types that can be used
to create a tensor variables. Variables can be named to facilitate debugging,
and all of these constructors accept an optional ``name`` argument.
For example, the following each produce a TensorVariable instance that stands
for a 0-dimensional ndarray of integers with the name ``'myvar'``:
>>> x = scalar('myvar', dtype='int32')
>>> x = iscalar('myvar')
>>> x = TensorType(dtype='int32', broadcastable=())('myvar')
Constructors with optional dtype
----------------------------------------
These are the simplest and often-preferred methods for creating symbolic
variables in your code. By default, they produce floating-point variables
(with dtype determined by config.floatX, see :attr:`floatX`) so if you use
these constructors it is easy to switch your code between different levels of
floating-point precision.
.. function:: scalar(name=None, dtype=config.floatX)
Return a Variable for a 0-dimensional ndarray
.. function:: vector(name=None, dtype=config.floatX)
Return a Variable for a 1-dimensional ndarray
.. function:: row(name=None, dtype=config.floatX)
Return a Variable for a 2-dimensional ndarray
in which the number of rows is guaranteed to be 1.
.. function:: col(name=None, dtype=config.floatX)
Return a Variable for a 2-dimensional ndarray
in which the number of columns is guaranteed to be 1.
.. function:: matrix(name=None, dtype=config.floatX)
Return a Variable for a 2-dimensional ndarray
.. function:: tensor3(name=None, dtype=config.floatX)
Return a Variable for a 3-dimensional ndarray
.. function:: tensor4(name=None, dtype=config.floatX)
Return a Variable for a 4-dimensional ndarray
.. #COMMENT
Each of the types described above can be constructed by two methods:
a singular version (e.g., :ref:`dmatrix <libdoc_tensor_creation>`)
and a plural version (:ref:`dmatrices <libdoc_tensor_creation>`).
When called, the singular version takes a single
argument which is the name of the *Variable* we want to make and it
makes a single Variable of that type. The plural version can either take
All Fully-Typed Constructors
----------------------------
The following TensorType instances are provided in the theano.tensor module.
They are all callable, and accept an optional ``name`` argument. So for example:
.. code-block:: python
from theano.tensor import *
x = dmatrix() # creates one Variable with no name
x = dmatrix('x') # creates one Variable with name 'x'
xyz = dmatrix('xyz') # creates one Variable with name 'xyz'
.. #COMMENT
table generated by
$ python Theano/doc/generate_dtype_tensor_table.py
============ =========== ==== =========== =================================
Constructor dtype ndim shape broadcastable
============ =========== ==== =========== =================================
bscalar int8 0 () ()
bvector int8 1 (?,) (False,)
brow int8 2 (1,?) (True, False)
bcol int8 2 (?,1) (False, True)
bmatrix int8 2 (?,?) (False, False)
btensor3 int8 3 (?,?,?) (False, False, False)
btensor4 int8 4 (?,?,?,?) (False, False, False, False)
wscalar int16 0 () ()
wvector int16 1 (?,) (False,)
wrow int16 2 (1,?) (True, False)
wcol int16 2 (?,1) (False, True)
wmatrix int16 2 (?,?) (False, False)
wtensor3 int16 3 (?,?,?) (False, False, False)
wtensor4 int16 4 (?,?,?,?) (False, False, False, False)
iscalar int32 0 () ()
ivector int32 1 (?,) (False,)
irow int32 2 (1,?) (True, False)
icol int32 2 (?,1) (False, True)
imatrix int32 2 (?,?) (False, False)
itensor3 int32 3 (?,?,?) (False, False, False)
itensor4 int32 4 (?,?,?,?) (False, False, False, False)
lscalar int64 0 () ()
lvector int64 1 (?,) (False,)
lrow int64 2 (1,?) (True, False)
lcol int64 2 (?,1) (False, True)
lmatrix int64 2 (?,?) (False, False)
ltensor3 int64 3 (?,?,?) (False, False, False)
ltensor4 int64 4 (?,?,?,?) (False, False, False, False)
dscalar float64 0 () ()
dvector float64 1 (?,) (False,)
drow float64 2 (1,?) (True, False)
dcol float64 2 (?,1) (False, True)
dmatrix float64 2 (?,?) (False, False)
dtensor3 float64 3 (?,?,?) (False, False, False)
dtensor4 float64 4 (?,?,?,?) (False, False, False, False)
fscalar float32 0 () ()
fvector float32 1 (?,) (False,)
frow float32 2 (1,?) (True, False)
fcol float32 2 (?,1) (False, True)
fmatrix float32 2 (?,?) (False, False)
ftensor3 float32 3 (?,?,?) (False, False, False)
ftensor4 float32 4 (?,?,?,?) (False, False, False, False)
cscalar complex64 0 () ()
cvector complex64 1 (?,) (False,)
crow complex64 2 (1,?) (True, False)
ccol complex64 2 (?,1) (False, True)
cmatrix complex64 2 (?,?) (False, False)
ctensor3 complex64 3 (?,?,?) (False, False, False)
ctensor4 complex64 4 (?,?,?,?) (False, False, False, False)
zscalar complex128 0 () ()
zvector complex128 1 (?,) (False,)
zrow complex128 2 (1,?) (True, False)
zcol complex128 2 (?,1) (False, True)
zmatrix complex128 2 (?,?) (False, False)
ztensor3 complex128 3 (?,?,?) (False, False, False)
ztensor4 complex128 4 (?,?,?,?) (False, False, False, False)
============ =========== ==== =========== =================================
Plural Constructors
--------------------------
There are several constructors that can produce multiple variables at once.
These are not frequently used in practice, but often used in tutorial examples to save space!
.. function:: iscalars, lscalars, fscalars, dscalars
Return one or more scalar variables.
.. function:: ivectors, lvectors, fvectors, dvectors
Return one or more vector variables.
.. function:: irows, lrows, frows, drows
Return one or more row variables.
.. function:: icols, lcols, fcols, dcols
Return one or more col variables.
.. function:: imatrices, lmatrices, fmatrices, dmatrices
Return one o
没有合适的资源?快使用搜索试试~ 我知道了~
Theano-0.4.0.zip
共344个文件
py:199个
txt:133个
cu:4个
0 下载量 76 浏览量
2024-05-12
23:20:07
上传
评论
收藏 1.09MB ZIP 举报
温馨提示
Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
资源推荐
资源详情
资源评论
收起资源包目录
Theano-0.4.0.zip (344个子文件)
setup.cfg 99B
cuda_ndarray.cu 117KB
conv.cu 60KB
conv_kernel.cu 39KB
conv_full_kernel.cu 18KB
cuda_ndarray.cuh 15KB
MANIFEST.in 144B
PKG-INFO 10KB
PKG-INFO 10KB
test_basic.py 206KB
basic.py 194KB
opt.py 154KB
test_opt.py 126KB
conv.py 79KB
basic_ops.py 79KB
debugmode.py 77KB
basic.py 72KB
nnet.py 59KB
cmodule.py 58KB
blas_headers.py 58KB
basic.py 58KB
elemwise.py 57KB
cc.py 53KB
function_module.py 50KB
blas.py 47KB
scan_op.py 46KB
opt.py 43KB
elemwise.py 42KB
scan.py 40KB
opt.py 40KB
module.py 40KB
test_blas.py 40KB
test_nnet.py 38KB
test_basic_ops.py 38KB
test_raw_random.py 34KB
test_tutorial.py 33KB
test_pfunc.py 32KB
rng_mrg.py 32KB
raw_random.py 32KB
__init__.py 30KB
printing.py 30KB
blas.py 30KB
test_sharedvar.py 28KB
profilemode.py 28KB
test_conv_cuda_ndarray.py 28KB
test_cuda_ndarray.py 28KB
test_shared_randomstreams.py 27KB
test_module.py 26KB
neighbours.py 26KB
graph.py 26KB
test_randomstreams.py 26KB
sp.py 25KB
test_function_module.py 24KB
test_naacl09.py 24KB
Conv3D.py 24KB
test_basic.py 24KB
test_rng_mrg.py 22KB
test_mlp.py 22KB
test_debugmode.py 21KB
op.py 21KB
link.py 21KB
ConvTransp3D.py 20KB
scan_utils.py 19KB
env.py 19KB
destroyhandler.py 19KB
nnet.py 18KB
test_elemwise.py 18KB
pfunc.py 18KB
test_conv3d.py 18KB
test_sp.py 17KB
GpuConvTransp3D.py 17KB
test_neighbours.py 17KB
ops.py 17KB
elemwise_cgen.py 16KB
distribute_setup.py 15KB
symbolic_module.py 15KB
GpuConvGrad3D.py 14KB
mode.py 14KB
type.py 14KB
speed_test_conv.py 13KB
downsample.py 13KB
sigm.py 13KB
test_opt.py 13KB
mlp_test.py 13KB
type.py 13KB
GpuConv3D.py 13KB
test_bench_loopfusion.py 12KB
unify.py 12KB
test_conv.py 12KB
compilelock.py 12KB
configparser.py 11KB
ConvGrad3D.py 11KB
neighbourhoods.py 11KB
multinomial.py 11KB
nvcc_compiler.py 11KB
configdefaults.py 10KB
io.py 10KB
test_shared.py 10KB
test_compute_test_value.py 10KB
__init__.py 10KB
共 344 条
- 1
- 2
- 3
- 4
资源评论
程序员Chino的日记
- 粉丝: 2980
- 资源: 4万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- gzip-1.12-3.1.x86-64.rpm
- student_manager.py
- stomp.js用于uniapp实现socket连接
- 网络安全相关的RSS订阅列表,这个项目记录了个人订阅的一些Hackers的博客地址,一些安全团队的博客,一些国外著名的安全新闻平
- SQLDumpSplitter3.rar
- java文字转语音示例
- (2024.3.19版本)最新全国三级(省-市-区县)行政区划表
- about edge deteetcionabout edge deteetcion
- about edge deteetcionabout edge deteetcion
- 基于java springboot高校工作室管理系统毕业设计源码+数据库,送文档
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功