简体   繁体   English

如何格式化Keras上的训练输入和输出数据

[英]How to format training input and output data on Keras

I am new to Deep Learning and I struggle with some data format on Keras. 我是深度学习的新手,我在Keras上遇到了一些数据格式。 My CNN is based on the Stacked Hourglass Networks for Human Pose Estimation from A.Newell et al. 我的CNN基于A.Newell等人的人体姿势估计堆积沙漏网络

On this network the input is a 256x256 RGB image and the output should be a 64x64 heatmap highlighting body joints (shoulder, knee,...). 在这个网络上,输入是256x256 RGB图像,输出应该是64x64热图,突出显示身体关节(肩膀,膝盖,......)。 I manage to build the network and I have all the data (images) with their annotations (pixel labels for body joints). 我设法建立网络,我有所有数据(图像)及其注释(身体关节的像素标签)。 I was wondering how should I format the Input and Output Data of the training set to train my model. 我想知道如何格式化训练集的输入和输出数据来训练我的模型。 Currently I use a numpy array (256,256,3) for an image and I don't know how to format my output. 目前我使用numpy数组(256,256,3)作为图像,我不知道如何格式化我的输出。 Should I create a table [n,64,64,7]? 我应该创建一个表[n,64,64,7]吗? (n being the size of the training set and 7 is the number of filters I use to obtain a heatmap for 7 joints) (n是训练集的大小,7是我用来获得7个关节的热图的滤波器数量)

Thank you for your time. 感谢您的时间。

The output can also be a numpy array. 输出也可以是一个numpy数组。 Consider this example: Training set: 50 images of size 256x256x3. 考虑这个例子:训练集:50个大小为256x256x3的图像。 This can be combined into a single numpy array of shape(50, 256, 256, 3). 这可以组合成单个numpy形状的阵列(50,256,256,3)。 Similar approach to format the output data. 类似的格式化输出数据的方法。 Sample code below: 示例代码如下:

    #a, b and c are arrays of size 256x256x3
    import numpy as np

    temp = []
    temp.append(a)
    temp.append(b)
    temp.append(c)
    output_labels = []
    output_labels = np.stack(temp)

The output_labels array will be of shape(3x256x256x3). output_labels数组的形状(3x256x256x3)。

Keras recommend to create data generator to feed training data and ground truth to network. Keras建议创建数据生成器,以便将训练数据和基础事实提供给网络。 Specific to stacked hourglass network case, you can refer to my implementation for details https://github.com/yuanyuanli85/Stacked_Hourglass_Network_Keras/tree/master/src/data_gen 具体到堆叠沙漏网络案例,你可以参考我的实现细节https://github.com/yuanyuanli85/Stacked_Hourglass_Network_Keras/tree/master/src/data_gen

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

相关问题 在 keras 中训练多类输入 output - Training Multiclass input output in keras 损失 function 和用于训练“分类输入”到“分类输出”model 的数据格式? - Loss function and data format for training a ''categorical input' to 'categorical output' model? Keras输入数据格式 - Keras input data format Keras LSTM培训。 如何调整我的输入数据? - Keras LSTM training. How to shape my input data? 在训练TensorFlow模型(,?不是Keras模型)时,如何获取模型中间层(op)的输入输出? - During training the TensorFlow model(!!Not the Keras model), How to get the input and output of the intermediate layer(op) of the model? 用于训练多输入功能的几个 x 输入的格式 keras model - Format of several x inputs for training multi input functional keras model Keras:使用数组作为输入进行训练 - Keras : training with an array as an input Keras:如何在每批训练时修改 keras model 的输入 - Keras: how to modify input of keras model while training for every batch Tensorflow/Keras:训练数据和预测数据中的 Output 形状不匹配 - Tensorflow/Keras: Output shape mismatch in training data and predicted data 如何在多输出 model 训练期间加载数据,而无需在 Keras 中进行迭代? - How to load data during training of a multi-output model without iteration in Keras?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM