将具有mat格式的张量导入到tensorflow [英] import tensor with mat format to tensorflow
问题描述
我是tensorflow和Python的新手.我在Matlab中有一个图像数据集,其张量大小为:96 * 96 * 5000(图像大小,图像数量),我需要将其导入Tensorflow.我看了Tensorflow教程,该教程说我应该使用TFRecords或CSV格式,但是我认为这意味着我将每个图像分别保存为csv格式.有什么办法可以直接将我的张量导入tensorflow吗?
I am new in tensorflow and Python. I have an image data set in Matlab in a tensor with size : 96*96*5000 (image size , number of images) and I need to import it to Tensorflow. I looked at the Tensorflow tutorial, which says I should use TFRecords or CSV formats but I think this means that I save each image separately in csv format. Is there any way to directly import my tensor to tensorflow?
推荐答案
正如奥利维尔(Olivier)在馈送机制,以将数据传递到TensorFlow模型中.
As Olivier said in his comment, the easiest solution is to convert the data into a Numpy array, and use TensorFlow's feeding mechanism to pass the data into your TensorFlow model.
可以使用SciPy中的 scipy.io.loadmat()
函数将Matlab .mat
文件加载到Python中,作为将Matlab矩阵名称(作为字符串)映射到Numpy数组的字典.
The scipy.io.loadmat()
function in SciPy can be used to load a Matlab .mat
file into Python, as a dictionary mapping Matlab matrix names (as strings) to Numpy arrays.
这篇关于将具有mat格式的张量导入到tensorflow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!