首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏bye漫漫求学路

    x.reshape()

    经常见到将数据集reshape的操作,那么这个是什么意思呢,我查了一下,有下面的说法: 第一种:图像通道为1个通道 图像大小未曾变化 # X shape (60,000 28x28), y shape (X_train, y_train), (X_test, y_test) = mnist.load_data() # data pre-processing X_train = X_train.reshape 请问reshape这种写法什么含义? X_train.reshape(X_train.shape[0], -1), 表示:只保留第一维,其余的纬度,不管多少纬度,重新排列为一维。用-1是偷懒的做法,等同于 28*28。 :x_image = tf.reshape(x, [-1, 28, 28, 1]) 这里是将一组图像矩阵x重建为新的矩阵,该新矩阵的维数为(a,28,28,1),其中-1表示a由实际情况来定。

    2K20发布于 2021-01-06
  • 来自专栏计算机视觉理论及其实现

    tf.reshape()

    TensorFlow - tf.reshape 函数reshape( tensor, shape, name=None)重塑张量,给定tensor,这个操作返回一个张量,它与带有形状shape 例如:# tensor 't' is [1, 2, 3, 4, 5, 6, 7, 8, 9]# tensor 't' has shape [9]reshape(t, [3, 3]) ==> [[1, 2 # tensor 't' is [[[1, 1], [2, 2]],# [[3, 3], [4, 4]]]# tensor 't' has shape [2, 2, 2]reshape [[5, 5, 5],# [6, 6, 6]]]# tensor 't' has shape [3, 2, 3]# pass '[-1]' to flatten 't'reshape 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]# -1 can also be used to infer the shape# -1 is inferred to be 9:reshape

    1.9K20编辑于 2022-09-04
  • 来自专栏chenjx85的技术专栏

    leetcode-566-Reshape the Matrix

    题目描述: In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a If the 'reshape' operation with given parameters is possible and legal, output the new reshaped matrix Input: nums = [[1,2], [3,4]] r = 2, c = 4 Output: [[1,2], [3,4]] Explanation: There is no way to reshape vector<vector<int>> matrixReshape(vector<vector<int>>& nums, int r, int c)  说明: 1、这道题就是让我们实现matlab中的reshape

    56270发布于 2018-05-22
  • 来自专栏技术向

    python numpy reshape 详解

    本文由腾讯云+社区自动同步,原文地址 https://stackoverflow.club/article/python_reshape/ 按行reshape order=’C’ 按列reshape order =’F’ temp = np.array([[1,2,3],[4,5,6]]) temp # array([[1, 2, 3], # [4, 5, 6]]) temp.reshape((3,2 )) # array([[1, 2], # [3, 4], # [5, 6]]) temp.reshape((3,2),'F') # Traceback (most recent ((3,2),order='F') # array([[1, 5], # [4, 3], # [2, 6]]) temp.reshape((3,2),order='A') # array ([[1, 2], # [3, 4], # [5, 6]]) reshape(a, newshape, order=’C’) Gives a new shape to an array

    89630发布于 2019-11-20
  • 来自专栏月亮与二进制

    Reshape the Matrix

    问题(Easy): In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into If the 'reshape' operation with given parameters is possible and legal, output the new reshaped matrix nums = [[1,2], [3,4]] r = 2, c = 4 Output: [[1,2], [3,4]] Explanation: There is no way to reshape 大意: 在MATLAB中,有一个很有用的函数名为“reshape”,可以重构一个矩阵为另一个尺寸,并保持原始数据。

    49430发布于 2021-11-23
  • 来自专栏计算机视觉理论及其实现

    reshape(-1)的含义

    一个参数为-1时,那么reshape函数会根据另一个参数的维度计算出数组的另外一个shape属性值。 print(z)[[ 1 2 3 4] [ 5 6 7 8] [ 9 10 11 12] [13 14 15 16]]>>> print(z.shape)(4, 4)>>> print(z.reshape (-1))[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]>>> print(z.reshape(-1,1)) #我们不知道z的shape属性是多少, #但是想让z变成只有一列,行数不知道多少, #通过`z.reshape(-1,1)`,Numpy [[ 1] [ 2] [ 3] [ 4] [ 5] [ 6] [ 7] [ 8] [ 9] [10] [11] [12] [13] [14] [15] [16]]>>> print(z.reshape(

    1.9K00编辑于 2022-09-02
  • 来自专栏数值分析与有限元编程

    Fortran知识 | 还在使用reshape函数?

    Fortran语言用reshape函数描述一个二维数组,比如下面的二维数组 用reshape可表示为: A = reshape( (/ 1,5,2,6 /), (/2,2/) ) !

    5.4K70发布于 2018-04-08
  • 来自专栏全栈程序员必看

    restsharp中文文档_reshape怎么用

    翻译自:https://github.com/restsharp/RestSharp/wiki,转载请注明。

    3.1K10编辑于 2022-10-04
  • 来自专栏JNing的专栏

    tensorflow: tf.reshape探究

    tf.reshape(tensor,shape,name=None)   给定一个tensor,这个操作会返回一个有着跟原tensor一样的值且经过shape重塑过的张量。   

    71310发布于 2018-09-28
  • 来自专栏XSYMamba

    reshape()中的“-1”总结

    属性是(4, 4) z = np.array([[1, 2, 3, 4],[5, 6, 7, 8],[9, 10, 11, 12],[13, 14, 15, 16]])z.shape(4, 4) z.reshape (-1) z.reshape(-1)array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) z.reshape(- 1, 1) 也就是说,先前我们不知道z的shape属性是多少,但是想让z变成只有一列,行数不知道多少,通过`z.reshape(-1,1)`,Numpy自动计算出有12行,新的数组shape属性为(16 z.reshape(-1,1)array([[ 1],[ 2],[ 3],[ 4],[ 5],[ 6],[ 7],[ 8],[ 9],[10],[11],[12],[13],[14],[15],[16] ]) z.reshape(-1, 2) newshape等于-1,列数等于2,行数未知,reshape后的shape等于(8, 2) z.reshape(-1, 2)array([[ 1, 2],[

    1.4K20发布于 2019-07-04
  • 来自专栏月梦·剑心的技术专栏

    numpy中的reshape()函数

    reshape()是numpy模块中的一个函数,可以改变numpy array的形状,以达到我们的要求。 首先查看其介绍以及函数列表 reshape()函数是一个改变数组形状但是不改变它的数据的函数。

    1.9K20编辑于 2022-09-14
  • 来自专栏计算机视觉CV

    transpose和reshape函数实现

    在numpy里面有两个方法都可以让shape进行改变,reshape 和transpose。下面我们就来看下两者对区别,以及我们应该使用哪一个才是正确的。 C,H,W=data.shape #[3,5,5]变形为[5,5,3] r_data=data.reshape((H,W,C)) print("numpy_reshape \n" ,r_data,"\n") numpy_reshape [[[ 0. 1. 2 可以看到最终结果都是变成5个5*3的矩阵,reshape呢是按顺序开始排,看结果比较好理解。transpose是转置,只是维度进行来交换但是内部结构没有变。 理解了原理后,后面在很多应用中就不会错误使用reshape和transpose啦~

    1.1K20发布于 2021-01-26
  • 来自专栏生信修炼手册

    pandas中数据框的reshape操作

    数据框的长宽转换对于熟悉R语言的朋友而言,应该不会陌生。使用ggplot2画图时,最常用的数据处理就是长宽转换了。在pandas中,也提供了数据框的长宽转换功能,有以下几种实现方式

    6.7K10发布于 2020-07-02
  • 来自专栏vincent随笔

    LeetCode566:reshape matrix 解答

    ------------------------------------------ 题目 In MATLAB, there is a very useful function called ‘reshape ’, which can >reshape a matrix into a new one with different size but keep its original >data. If the ‘reshape’ operation with given parameters is possible and legal, output >the new reshaped matrix 题目大意:在MATLAB中有一个非常实用的函数,叫“reshape”,它能够将矩阵重塑为一个完全保留原始数据但是具有不同形状的矩阵。 nums = [[1,2], [3,4]] r = 2, c = 4 Output: [[1,2], [3,4]] Explanation: There is no way to reshape

    43520发布于 2021-08-18
  • 来自专栏计算机视觉理论及其实现

    numpy或pandas中reshape(-1)等用法

    3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])z.shape(4, 4)1.z.reshape (-1)或z.reshape(1,-1)将数组横向平铺 z.reshape(-1)array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 , 15, 16])2.z.reshape(-1, 1)将数组纵向平铺z.reshape(-1,1) array([[ 1], [ 2], [ 3], [ 4] 9], [10], [11], [12], [13], [14], [15], [16]])3.z.reshape (-1, 2)newshape等于-1,列数等于2,行数未知,reshape后的shape等于(8, 2)z.reshape(-1, 2) array([[ 1, 2], [ 3, 4

    1.4K30编辑于 2022-09-02
  • 来自专栏学习有记

    Reshape the Matrix(重塑矩阵)

    在MATLAB中,有一个非常有用的函数 reshape,它可以将一个矩阵重塑为另一个大小不同的新矩阵,但保留其原始数据。 如果具有给定参数的reshape操作是可行且合理的,则输出新的重塑矩阵;否则,输出原始矩阵。

    1.1K20发布于 2018-08-31
  • 来自专栏机器学习/数据可视化

    pandas系列6-重塑reshape

    重新排列表格型数据的基础运算称之为重塑reshape或者轴向旋转pivot stack:将数据的列旋转成行,AB由列属性变成行索引 unstack:将数据的行旋转成列,AB由行索引变成列属性 重点知识 import pandas as pd import numpy as np import matplotlib.pyplot as plt data = pd.DataFrame(np.arange(6).reshape

    94410发布于 2021-03-02
  • 来自专栏优雅R

    「R」使用reshape2包

    很多R用户都搞不太清楚用于修整数据的内置函数(比如stack、unstack与reshape),庆幸的是我们还有其他选择,Hadley Wickham(ggplot2的作者)开发了一个reshape2库 注:现在大部分时间我们都在使用 tidyr 提供的长宽格式转换工具,比 reshape2 包提供的操作更容易理解。 熔解与铸造 reshape库用一个直观的模型来描述如何操作数据表。 使用例子 我们用一个例子来看一下熔解与铸造究竟是怎么回事,以体会reshape2包的有用之处。 # 导入包 library(reshape2) md <- melt(airquality, id=c("Month", "Day")) head(md, 20) ## Month Day variable

    81620发布于 2020-07-03
  • 来自专栏桃花源记

    tf.reshape函数用法&理解

    函数原型 函数接口: tf.reshape( tensor, shape, name=None ) 参数 tensor Tensor张量 shape Tensor张量,用于定义输出张量的shape 用法 tf.reshape函数用于对输入tensor进行维度调整,但是这种调整方式并不会修改内部元素的数量以及元素之间的顺序,换句话说,reshape函数不能实现类似于矩阵转置的操作。 其内部实现可以理解为: tf.reshape(a, shape) -> tf.reshape(a, [-1]) -> tf.reshape(a, shape) 现将输入tensor,flatten铺平 ,然后再进行维度调整(元素的顺序没有变化) tf.reshape不会更改张量中元素的顺序或总数,因此可以重用基础数据缓冲区。 总结 关于tf.reshape函数我们需要知道的是: 函数用于张量维度调整,但是不会修改内部元素的数量以及相对顺序 shape中-1表示这个维度的大小,程序运行时会自动计算填充(因为变换前后元素数量不变

    1.7K20编辑于 2022-04-14
  • 来自专栏大数据

    数据管理—reshape2包

    今天,May带来数据管理常用的工具reshape2,这个包的作用在于可以对数据进行变形,然后组成自己想要的数据内容。 下面可以开始来了解reshape2的应用过程。

    88700发布于 2017-12-27
领券