当前位置:网站首页>TensorFlow中的Tensor是什么?
TensorFlow中的Tensor是什么?
2020-11-06 20:53:00 【Alili丶前端大爆炸】
Tensor(张量)
“张量”一词最初由威廉·罗恩·哈密顿在1846年引入。对,就是那个发明四元数的哈密顿:
-
Tensor实际上就是一个多维数组(multidimensional array)
-
Tensor的目的是能够创造更高维度的矩阵、向量。
色彩的例子
彩色图像文件(RGB)一般都会处理成3-d tensor,每个2d array中的element表示一个像素,R代表Red,G代表Green,B代表Blue
多维数组
把三维张量画成一个立方体:
更高维的张量:
初始化一个向量
0维
tf.tensor(1).print();
1维
tf.tensor([1, 2, 3, 4]).print();
// or
tf.tensor1d([1, 2, 3]).print();
2维
tf.tensor([[1, 2], [3, 4]]).print();
// or
tf.tensor2d([[1, 2], [3, 4]]).print();
3维
tf.tensor([[[1], [2]], [[3], [4]]]).print();
// or
tf.tensor3d([[[1], [2]], [[3], [4]]]).print();
4维
tf.tensor([[[[1], [2]], [[3], [4]]]]).print();
// or
tf.tensor4d([[[[1], [2]], [[3], [4]]]]).print();
5维
tf.tensor([[[[[1], [2]], [[3], [4]]]]]).print();
// or
tf.tensor5d([[[[[1], [2]], [[3], [4]]]]]).print();
6维
tf.tensor([[[[[[1],[2]],[[3],[4]]],[[[5],[6]],[[7],[8]]]]]]).print();
// or
tf.tensor6d([[[[[[1],[2]],[[3],[4]]],[[[5],[6]],[[7],[8]]]]]]).print();
更多文章请关注我的博客 Alili丶前端大爆炸 订阅号:
Alili丶前端大爆炸
版权声明
本文为[Alili丶前端大爆炸]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4000748/blog/4667574
边栏推荐
- Examples of unconventional aggregation
- If PPT is drawn like this, can the defense of work report be passed?
- Five vuex plug-ins for your next vuejs project
- React design pattern: in depth understanding of react & Redux principle
- 小程序入门到精通(二):了解小程序开发4个重要文件
- Analysis of etcd core mechanism
- Advanced Vue component pattern (3)
- 一篇文章带你了解HTML表格及其主要属性介绍
- Wiremock: a powerful tool for API testing
- Skywalking series blog 1 - install stand-alone skywalking
猜你喜欢
Filecoin主网上线以来Filecoin矿机扇区密封到底是什么意思
I think it is necessary to write a general idempotent component
What to do if you are squeezed by old programmers? I don't want to quit
全球疫情加速互联网企业转型,区块链会是解药吗?
Don't go! Here is a note: picture and text to explain AQS, let's have a look at the source code of AQS (long text)
一篇文章带你了解CSS3圆角知识
Filecoin最新动态 完成重大升级 已实现四大项目进展!
Python download module to accelerate the implementation of recording
IPFS/Filecoin合法性:保护个人隐私不被泄露
[C / C + + 1] clion configuration and running C language
随机推荐
6.4 viewresolver view parser (in-depth analysis of SSM and project practice)
华为云“四个可靠”的方法论
Natural language processing - BM25 commonly used in search
What is the side effect free method? How to name it? - Mario
It's so embarrassing, fans broke ten thousand, used for a year!
Vite + TS quickly build vue3 project and introduce related features
采购供应商系统是什么?采购供应商管理平台解决方案
Mongodb (from 0 to 1), 11 days mongodb primary to intermediate advanced secret
Summary of common algorithms of binary tree
一篇文章带你了解CSS 渐变知识
Don't go! Here is a note: picture and text to explain AQS, let's have a look at the source code of AQS (long text)
Flink的DataSource三部曲之二:内置connector
Keyboard entry lottery random draw
Classical dynamic programming: complete knapsack problem
htmlcss
ipfs正舵者Filecoin落地正当时 FIL币价格破千来了
Using consult to realize service discovery: instance ID customization
html
6.1.1 handlermapping mapping processor (1) (in-depth analysis of SSM and project practice)
Calculation script for time series data