如何获取 MinibatchSource 中的流名称?

How to get name of streams in MinibatchSource?

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

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

minibatch_source.stream_infos()

我还有一个后续问题:

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

这些名称与像这样完成的 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'
)))

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

我想这些名字不知何故是默认名称?

对于你原来的问题:

minibatch_source.streams.keys()

参见 "A Brief Look at Data and Data Reading" 部分下的示例 this tutorial

对于您的后续问题: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')))

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