【问题标题】:How to get name of streams in MinibatchSource?如何在 MinibatchSource 中获取流的名称?
【发布时间】:2017-01-04 20:34:17
【问题描述】:

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

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

minibatch_source.stream_infos()

我还有一个后续问题:

结果来自: 打印(reader_train.streams.keys()) 是 dict_keys(['标签', '特征'

这些名称与 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'
)))

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

我猜这些名字是默认名字?

【问题讨论】:

    标签: cntk


    【解决方案1】:

    对于你原来的问题:

    minibatch_source.streams.keys()
    

    参见“数据和数据读取简介”部分下的 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 的值应与源匹配(这取决于您的输入数据和您使用的反序列化器)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多