用于将HDF5文件读入TensorFlow的接口。

tftables的Python项目详细描述


tftables允许使用tensorflow方便地访问hdf5文件。 提供了一个从数组或表中读取成批数据的类。 二级类将主读卡器和tensorflow fifoquee包装起来,用于直接流式处理 从hdf5文件到tensorflow操作的数据。

库由multitables支持,用于高速读取hdf5 数据集。multitables基于pytables(tables),因此此库可以使用任何压缩算法 pytables支持的。

许可证

这个软件是根据麻省理工学院的许可证发行的。 有关详细信息,请参见LICENSE.txt文件。

安装

pip install tftables

或者,要从头部安装,请运行

pip install git+https://github.com/ghcollin/tftables.git

你也可以download 或者clone the repository并运行

python setup.py install

tftables依赖于multitablesnumpytensorflow。该包与最新版本的python兼容 2和3。

快速启动

访问HDF5文件中的表的示例。

importtftablesimporttensorflowastfwithtf.device('/cpu:0'):# This function preprocesses the batches before they# are loaded into the internal queue.# You can cast data, or do one-hot transforms.# If the dataset is a table, this function is required.definput_transform(tbl_batch):labels=tbl_batch['label']data=tbl_batch['data']truth=tf.to_float(tf.one_hot(labels,num_labels,1,0))data_float=tf.to_float(data)returntruth,data_float# Open the HDF5 file and create a loader for a dataset.# The batch_size defines the length (in the outer dimension)# of the elements (batches) returned by the reader.# Takes a function as input that pre-processes the data.loader=tftables.load_dataset(filename='path/to/h5_file.h5',dataset_path='/internal/h5/path',input_transform=input_transform,batch_size=20)# To get the data, we dequeue it from the loader.# Tensorflow tensors are returned in the same order as input_transformationtruth_batch,data_batch=loader.dequeue()# The placeholder can then be used in your networkresult=my_network(truth_batch,data_batch)withtf.Session()assess:# This context manager starts and stops the internal threads and# processes used to read the data from disk and store it in the queue.withloader.begin(sess):for_inrange(num_iterations):sess.run(result)

如果数据集是数组而不是表。那么input_transform可以省略 如果不需要预处理。如果只需要通过数据集一次, 然后应该将cyclic=False传递给load_dataset

示例

有关完整示例,请参见unit tests

示例

有关更深入的文档,请参见how-to,以及 unit tests完整示例。

文档

Online documentation可用。 ahow to给出了库的基本概述。

脱机文档可以使用sphinxdocs文件夹生成。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
二进制字符串的java NumberFormatExceprion   java如何在Neo4j中查找/匹配/选择标识符名称   java哪一年的日期与原始年份相同?   java什么时候JAXB可以用于Json而不是XML?   java使用PayPal权限API进行PayPal支付   java Getting error在使用安卓 vision api扫描二维码时加载图像失败   java直接突出显示RichTextFX中的一个文本范围   java Resolve@RegisteredAuth2AuthorizedClient,其令牌在spring Security 5.2的spring server之外获得。十、   yyyymmddhhmmss的Java正则表达式   java我试图将google recaptcha与spring mvc集成,但GreCaptCharResponse总是返回false。这里有一些代码   java使用JsonPath将文本转换为json   java无法解析符号。Maven依赖项已就位,但代码为红色   java使用循环查找范围内具有不同数字的数字   java这个SwingWorker是否不重用ThreadPoolExecutor中的线程?