当前位置:网站首页>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
边栏推荐
- 2019年的一个小目标,成为csdn的博客专家,纪念一下
- H5 makes its own video player (JS Part 2)
- 数字城市响应相关国家政策大力发展数字孪生平台的建设
- Python + appium automatic operation wechat is enough
- 每个前端工程师都应该懂的前端性能优化总结:
- axios学习笔记(二):轻松弄懂XHR的使用及如何封装简易axios
- “颜值经济”的野望:华熙生物净利率六连降,收购案遭上交所问询
- IPFS/Filecoin合法性:保护个人隐私不被泄露
- ipfs正舵者Filecoin落地正当时 FIL币价格破千来了
- Multi classification of unbalanced text using AWS sagemaker blazingtext
猜你喜欢

Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!

Summary of common algorithms of linked list

PHP应用对接Justswap专用开发包【JustSwap.PHP】

一篇文章教会你使用HTML5 SVG 标签

多机器人行情共享解决方案

git rebase的時候捅婁子了,怎麼辦?線上等……

华为云“四个可靠”的方法论

The difference between Es5 class and ES6 class

Just now, I popularized two unique skills of login to Xuemei

The road of C + + Learning: from introduction to mastery
随机推荐
Brief introduction of TF flags
[actual combat of flutter] pubspec.yaml Configuration file details
多机器人行情共享解决方案
It's so embarrassing, fans broke ten thousand, used for a year!
Deep understanding of common methods of JS array
TRON智能钱包PHP开发包【零TRX归集】
How to select the evaluation index of classification model
Vuejs development specification
100元扫货阿里云是怎样的体验?
ES6学习笔记(五):轻松了解ES6的内置扩展对象
Working principle of gradient descent algorithm in machine learning
In order to save money, I learned PHP in one day!
Analysis of partial source codes of qthread
Installing the consult cluster
JVM memory area and garbage collection
How long does it take you to work out an object-oriented programming interview question from Ali school?
Just now, I popularized two unique skills of login to Xuemei
深度揭祕垃圾回收底層,這次讓你徹底弄懂她
做外包真的很难,身为外包的我也无奈叹息。
git rebase的時候捅婁子了,怎麼辦?線上等……