2

如何获取 MinibatchSource 中每个流的名称?

我可以获取与 stream_infos 返回的流信息相关的名称吗?

minibatch_source.stream_infos()

我还有一个后续问题:

结果来自: print(reader_train.streams.keys()) 是 dict_keys(['labels', 'features'

这些名称与 MiniBatchSource 的构造有何关系,MiniBatchSource 是这样完成的?

return MinibatchSource(ImageDeserializer(map_file, StreamDefs(
    features = StreamDef(field='image', transforms=transforms), # first column in map file is referred to as 'image'
    labels   = StreamDef(field='label', shape=num_classes)      # and second as 'label'
)))

我原以为我的流会被命名为“图像”和“标签”,但它们被命名为“标签”和“特征”。

我猜这些名字在某种程度上是默认名字?

4

1 回答 1

1

对于您的原始问题:

minibatch_source.streams.keys()

例如,请参阅“数据和数据读取简要介绍”部分下的本教程。

对于您的后续问题:返回的名称keys()StreamDefs(). 这就是您在程序中所需要的。如果你MinibatchSource这样定义你的

return MinibatchSource(ImageDeserializer(map_file, StreamDefs(
image = StreamDef(field='image', transforms=transforms), # first column in map file is referred to as 'image'
label = StreamDef(field='label', shape=num_classes)      # and second as 'label')))

那么名称将匹配。您可以选择任何您想要的名称,但field内部的值StreamDef()应与源匹配(这取决于您的输入数据和您使用的反序列化器)。

于 2017-01-04T20:44:16.293 回答