简体   繁体   English

将矩阵从 (100, ) 重塑为 (100, 405416)

[英]Reshape a matrix from (100, ) to (100, 405416)

I am trying to reshape a one-hot encoded array to (samples, 405416) .我正在尝试将单热编码数组重塑为(samples, 405416) The output shape after one-hot encoded is (405416, 405416) and I want it to reshape to (100, 405416) where 100 is the samples. one-hot 编码后的输出形状是(405416, 405416)我希望它重塑为(100, 405416) ,其中100是样本。

y = []
for i in range(100):
    random_num = randint(0, 405416, 1)
    y.append(data_enc[random_number])

The output y shape is (100, )输出y形状为(100, )

The output y[0] shape is (1, 405416)输出y[0]形状为(1, 405416)

data_enc is the matrix of shape (405416, 405416) after one-hot encoding data_enc是one-hot编码后的shape矩阵(405416, 405416)

Reshape of a matrix should contain same number of elements from input to reshaped matrix.矩阵的重塑应该包含从输入到重塑矩阵的相同数量的元素。 so reshaping (405416, 405416) to (100, 405416) is not possible.所以将 (405416, 405416) 重塑为 (100, 405416) 是不可能的。

When you have 100 samples then the onehot encoding should result (100, features) not (features, features).当您有 100 个样本时,onehot 编码的结果应该是 (100, features) 而不是 (features, features)。 Check your implementation of Onehot clearly.清楚地检查您对 Onehot 的实施。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从随机生成的值中获得多项式的四阶并将数组从(100)重塑为(100,4)? - How to get the 4th order of polynomial from random generated values and reshape array from (100) to (100,4)? 从Numpy.zeros(100,100)转换为使用Scipy.sparse.lil_matrix(100,100)错误 - Converting from Numpy.zeros(100,100) to using a Scipy.sparse.lil_matrix(100,100) Error ValueError:无法将大小为270000的数组重塑为形状(1,100,100,3) - ValueError: cannot reshape array of size 270000 into shape (1,100,100,3) ValueError:无法将大小为 300 的数组重塑为形状 (100,100,3) - ValueError: cannot reshape array of size 300 into shape (100,100,3) 我如何将(100,)到(250,100)的Numpy数组重塑 - how can I reshape a numpy array of (100,) to (250,100) 使用 Python,生成 100 X 100 随机矩阵,其条目从正态分布中采样 - Using Python, generate 100 X 100 random matrix whose entries are sampled from the normal distribution 用矩阵模拟 for 循环 100 次 - Simulating for loop 100 times with a matrix 在python中的100 x 100矩阵中,填充非对角线元素 - In matrix of 100 x 100 in python, filling the off diagonal elements 如何重塑我的阵列以适应 (4,100) - How can I reshape my array to fit (4,100) 从.txt 文件重塑矩阵 - Reshape matrix from .txt file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM