• 大小: 14.35MB
    文件类型: .gz
    金币: 1
    下载: 0 次
    发布日期: 2023-07-30
  • 语言: 其他
  • 标签: hdf5  

资源简介

hdf5-1.10.1.tar.gz , hdf5 用于深度学习中常见的数据模型的存储。

资源截图

代码片段和文件信息

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice including     *
 * terms governing use modification and redistribution is contained in    *
 * the COPYING file which can be found at the root of the source code       *
 * distribution tree or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
 * If you do not have access to either file you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
 *   This example shows how to read data from a chunked dataset.
 *   We will read from the file created by extend.cpp
 */

#ifdef OLD_HEADER_FILENAME
#include 
#else
#include 
#endif
using std::cout;
using std::endl;

#include 
#include “H5Cpp.h“
using namespace H5;

const H5std_string FILE_NAME( “SDSextendible.h5“ );
const H5std_string DATASET_NAME( “ExtendibleArray“ );
const int      NX = 10;
const int      NY = 5;
const int      RANK = 2;
const int      RANKC = 1;

int main (void)
{
    hsize_t i j;

    // Try block to detect exceptions raised by any of the calls inside it
    try
    {
/*
 * Turn off the auto-printing when failure occurs so that we can
 * handle the errors appropriately
 */
Exception::dontPrint();

/*
 * Open the file and the dataset.
 */
H5File file( FILE_NAME H5F_ACC_RDONLY );
DataSet dataset = file.openDataSet( DATASET_NAME );

/*
 * Get filespace for rank and dimension
 */
DataSpace filespace = dataset.getSpace();

/*
 * Get number of dimensions in the file dataspace
 */
int rank = filespace.getSimpleExtentNdims();

/*
 * Get and print the dimension sizes of the file dataspace
 */
hsize_t dims[2];  // dataset dimensions
rank = filespace.getSimpleExtentDims( dims );
cout << “dataset rank = “ << rank << “ dimensions “
     << (unsigned long)(dims[0]) << “ x “
     << (unsigned long)(dims[1]) << endl;

/*
 * Define the memory space to read dataset.
 */
DataSpace mspace1(RANK dims);

/*
 * Read dataset back and display.
 */
int data_out[NX][NY];  // buffer for dataset to be read
dataset.read( data_out PredType::NATIVE_INT mspace1 filespace );

cout << “\n“;
cout << “Dataset: \n“;
for (j = 0; j < dims[0]; j++)
{
    for (i = 0; i < dims[1]; i++)
cout << data_out[j][i] << “ “;
    cout << endl;
}

/*
 *     dataset rank 2 dimensions 10 x 5
 *     chunk rank 2 dimensions 2 x 5

 *     Dataset:
 *     1 1 1 3 3
 *     1 1 1 3 3
 *     1 1 1 0 0
 *     2 0 0 0 0
 *     2 0 0 0 0
 *     2 0 0 0 0
 *    

评论

共有 条评论