tensorflow 之 tf.reshape 之 -1
最近压力好大,写点东西可能对心情有好处。
reshape即把矩阵的形状变一下,这跟matlab一样的,但如果参数是-1的话是什么意思呢?
看一下例子哈:
tensor = tf.constant([1, 2, 3, 4, 5, 6, 7,8])
sess.run(tf.initialize_all_variables())
print(sess.run(tensor))
print(sess.run(tensor))
[1 2 3 4 5 6 7 8]
tensorReshape = tf.reshape(tensor,[2,4])
print(sess.run(tensorReshape))
[[1 2 3 4][5 6 7 8]]
tensorReshape = tf.reshape(tensor,[1,2,4])
print(sess.run(tensorReshape))
[[[1 2 3 4][5 6 7 8]]]
tensorResha
tensorReshape = tf.reshape(tensor,[-1,2,2])
print(sess.run(tensorReshape))
[[[1 2][3 4]][[5 6][7 8]]]所以-1,就是缺省值,就是先以你们合适,到时总数除以你们几个的乘积,我该是几就是几。
转载于:https://www.cnblogs.com/wasss/p/5439363.html
tensorflow 之 tf.reshape 之 -1相关推荐
- 【tensorflow】tf.reshape函数说明:重塑张量
转载 [471]tf.reshape函数说明_周小董-CSDN博客 https://blog.csdn.net/xc_zhou/article/details/85342542 函数原型: tf.re ...
- TensorFlow学习笔记(十八)tf.reshape矩阵变形
tf.reshape(tensor, shape, name=None) 矩阵变形是常用的操作,在Tensorflow中调用方式有多种,例如: 1. tf.reshape tf.reshape(L3, ...
- tensorflow 之 最近用到的几个小操作tf.reshape,tf.convert_to_tensor,tf.where
1.tf.reshape() #调整tensor的形状 img = .... img_res = tf.reshape(img, [-1]) 着重记录是shape=[-1]时,相当于flatten操作 ...
- Tensorflow中tf.ConfigProto()详解
参考Tensorflow Machine Leanrning Cookbook tf.ConfigProto()主要的作用是配置tf.Session的运算方式,比如gpu运算或者cpu运算 具体代码如 ...
- tf.reshape 和 tf.transpose 用法
import tensorflow as tf x= tf.constant([[2,3],[4,5],[6,7]],tf.int32) print(x.numpy()) [[2 3][4 5][6 ...
- python3 tensorflowprint错误_解决import tensorflow as tf 出错的原因
笔者在运行 import tensorflow as tf时出现下面的错误,但在运行import tensorflow时没有出错. >>> import tensorflow as ...
- tf.reshape的-1的错误理解
一直以为reshape(-1,)会变成一维的,然后变成一个标量: import tensorflow as tf lenth = tf.reshape(30,shape=[-1]) lenth2 = ...
- tf.reshape(inputs, [-1,dim])的理解
示例: import tensorflow as tf lenth = tf.reshape(30,shape=[-1]) #变成一维张量 lenth2 = tf.reshape(30,shape=[ ...
- TensorFlow之tf.nn.dropout():防止模型训练过程中的过拟合问题
一:适用范围: tf.nn.dropout是TensorFlow里面为了防止或减轻过拟合而使用的函数,它一般用在全连接层 二:原理: dropout就是在不同的训练过程中随机扔掉一部分神经元.也就是让 ...
最新文章
- boost::format模块测试格式与枚举一起使用
- 【网搜】禁止 number 输入非数字(Android仍有问题)
- 笔记本电脑频繁自动重启_笔记本电脑自动重启是什么原因
- PWA(Progressive Web App)入门系列:(二)相关准备
- 经典面试题(11):关于变量提升,以下代码将输出什么?
- Activating Browser Modes with Doctype
- 【UVALive】3695 Distant Galaxy(......)
- ❤️《IOC理论推导》
- python语言适用于哪些领域_Python用于哪些领域
- 计算机单机游戏c0005错误,堡垒之夜Epic Games Launcher错误怎么办错误解决方法介绍...
- MySQL数据库学习资料(一)
- 使用URLDecoder对URL进行中文解析
- Excel表格的35招必学秘技[配图]
- MATLAB实现偏最小,偏最小二乘法 matlab程序
- 浅谈AlphaGo背后所涉及的深度学习技术
- YUV和RGB调节色彩公式
- 单页面优化有哪些可以参考的策略
- 文华学院计算机专业考研,英语复试第1,初试375分,她从文华学院跨专业考研华中科技大学...
- 雷神加速器无限更新失败️️️
- SWF (Simple Workflow Service)简介
热门文章
- Labview通过RS422通讯接口PC与下位机通信
- 如何让自己时刻冷静的方法_如何锻炼自己的口才及沟通技巧?这5个方法让你受用一辈子...
- IDEA创建maven JavaWeb工程
- android tv 悬浮窗口,android TV的自定义关机弹出框
- sql用什么替代or
- hashmap的五种便利方式
- 006_JSONObject对象公共方法
- java 等待_Java并发之等待/通知机制
- 思科光传输功率查询_各品牌网络设备的光功率查看方法(不完全统计)
- Android Studio 小技巧/快捷键 合集