python 重塑numpy数组
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 重塑numpy数组相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#import autoencoder
import numpy as np
import h5py
import cv2 as cv
import loadlabels as ll
############################################################################################
# Load traindata
############################################################################################
X, Y, testX, testY = None, None, None, None
DATASET_FILE = "_no_install/full_data_2.h5"
try:
X, Y, testX, testY = ll.loadData(DATASET_FILE)
print("Shape X: {}".format(X.shape))
print("Dim X: {}, {}, {}".format(X.shape[0], X.shape[1], X.shape[2]))
X_R = np.reshape(X, (X.shape[0], X.shape[1], X.shape[2], 1))
print("Shape X_R: {}".format(X_R.shape))
print("Dim X_R: {}, {}, {}, {}".format(X_R.shape[0], X_R.shape[1], X_R.shape[2], X_R.shape[3]))
except BaseException as excep:
print(
"Loading of the dataset faild. For trainig and evaluation you need the weights file "
"{}. Exception-Message: {}".format(DATASET_FILE, str(excep)))
exit(1)
以上是关于python 重塑numpy数组的主要内容,如果未能解决你的问题,请参考以下文章
在 NumPy 中重塑数组
Python将3d数组重塑为2d
重塑 3 列 numpy 数组
在 NumPy 中将 4D 数组重塑为 2D 数组背后的直觉和想法
在python中重塑图像矩阵
Numpy 用 1 列将 1d 重塑为 2d 数组