最近压力好大,写点东西可能对心情有好处。

reshape即把矩阵的形状变一下,这跟matlab一样的,但如果参数是-1的话是什么意思呢?

看一下例子哈:

. . .
In [21]:
 
tensor = tf.constant([1, 2, 3, 4, 5, 6, 7,8])

. . .

In [22]:
 
sess.run(tf.initialize_all_variables())

. . .

In [23]:
print(sess.run(tensor)) 

 
print(sess.run(tensor))

[1 2 3 4 5 6 7 8]

. . .

In [24]:
 
tensorReshape = tf.reshape(tensor,[2,4])

. . .

In [25]:
 
print(sess.run(tensorReshape))

[[1 2 3 4][5 6 7 8]]

. . .

In [26]:
 
tensorReshape = tf.reshape(tensor,[1,2,4])

. . .

In [27]:
 
print(sess.run(tensorReshape))

[[[1 2 3 4][5 6 7 8]]]

. . .

In [28]:
tensorResha

 
tensorReshape = tf.reshape(tensor,[-1,2,2])

. . .

In [29]:
 
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相关推荐

  1. 【tensorflow】tf.reshape函数说明:重塑张量

    转载 [471]tf.reshape函数说明_周小董-CSDN博客 https://blog.csdn.net/xc_zhou/article/details/85342542 函数原型: tf.re ...

  2. TensorFlow学习笔记(十八)tf.reshape矩阵变形

    tf.reshape(tensor, shape, name=None) 矩阵变形是常用的操作,在Tensorflow中调用方式有多种,例如: 1. tf.reshape tf.reshape(L3, ...

  3. tensorflow 之 最近用到的几个小操作tf.reshape,tf.convert_to_tensor,tf.where

    1.tf.reshape() #调整tensor的形状 img = .... img_res = tf.reshape(img, [-1]) 着重记录是shape=[-1]时,相当于flatten操作 ...

  4. Tensorflow中tf.ConfigProto()详解

    参考Tensorflow Machine Leanrning Cookbook tf.ConfigProto()主要的作用是配置tf.Session的运算方式,比如gpu运算或者cpu运算 具体代码如 ...

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

  6. python3 tensorflowprint错误_解决import tensorflow as tf 出错的原因

    笔者在运行 import tensorflow as tf时出现下面的错误,但在运行import tensorflow时没有出错. >>> import tensorflow as ...

  7. tf.reshape的-1的错误理解

    一直以为reshape(-1,)会变成一维的,然后变成一个标量: import tensorflow as tf lenth = tf.reshape(30,shape=[-1]) lenth2 = ...

  8. tf.reshape(inputs, [-1,dim])的理解

    示例: import tensorflow as tf lenth = tf.reshape(30,shape=[-1]) #变成一维张量 lenth2 = tf.reshape(30,shape=[ ...

  9. TensorFlow之tf.nn.dropout():防止模型训练过程中的过拟合问题

    一:适用范围: tf.nn.dropout是TensorFlow里面为了防止或减轻过拟合而使用的函数,它一般用在全连接层 二:原理: dropout就是在不同的训练过程中随机扔掉一部分神经元.也就是让 ...

最新文章

  1. boost::format模块测试格式与枚举一起使用
  2. 【网搜】禁止 number 输入非数字(Android仍有问题)
  3. 笔记本电脑频繁自动重启_笔记本电脑自动重启是什么原因
  4. PWA(Progressive Web App)入门系列:(二)相关准备
  5. 经典面试题(11):关于变量提升,以下代码将输出什么?
  6. Activating Browser Modes with Doctype
  7. 【UVALive】3695 Distant Galaxy(......)
  8. ❤️《IOC理论推导》
  9. python语言适用于哪些领域_Python用于哪些领域
  10. 计算机单机游戏c0005错误,堡垒之夜Epic Games Launcher错误怎么办错误解决方法介绍...
  11. MySQL数据库学习资料(一)
  12. 使用URLDecoder对URL进行中文解析
  13. Excel表格的35招必学秘技[配图]
  14. MATLAB实现偏最小,偏最小二乘法 matlab程序
  15. 浅谈AlphaGo背后所涉及的深度学习技术
  16. YUV和RGB调节色彩公式
  17. 单页面优化有哪些可以参考的策略
  18. 文华学院计算机专业考研,英语复试第1,初试375分,她从文华学院跨专业考研华中科技大学...
  19. 雷神加速器无限更新失败️️️
  20. SWF (Simple Workflow Service)简介

热门文章

  1. Labview通过RS422通讯接口PC与下位机通信
  2. 如何让自己时刻冷静的方法_如何锻炼自己的口才及沟通技巧?这5个方法让你受用一辈子...
  3. IDEA创建maven JavaWeb工程
  4. android tv 悬浮窗口,android TV的自定义关机弹出框
  5. sql用什么替代or
  6. hashmap的五种便利方式
  7. 006_JSONObject对象公共方法
  8. java 等待_Java并发之等待/通知机制
  9. 思科光传输功率查询_各品牌网络设备的光功率查看方法(不完全统计)
  10. Android Studio 小技巧/快捷键 合集