【问题标题】:Source path inside jupyter notebook to other filesjupyter notebook 中其他文件的源路径
【发布时间】:2019-01-30 11:18:12
【问题描述】:

从 jupyter 笔记本中,我想为已上传到 Jupyter 的其他文件设置一个位置。

这是代码,我猜错的行是第一行:

location = os.path.normpath('localhost:888/notebooks/project')

data = {
  'train': { 'file': 'train_modified.csv', 'location': 0 },
  'test': { 'file': 'test_modified.csv', 'location': 0 },
  'query': { 'file': 'query.csv', 'location': 1 },
  'slots': { 'file': 'train_labels.csv', 'location': 1 }
}

for item in data.values():
    location = locations[item['location']]
    path = os.path.join('..', location, item['file'])
    if os.path.exists(path):
        print("Reusing locally cached:", item['file'])
        # Update path
        item['file'] = path
    elif os.path.exists(item['file']):
        print("Reusing locally cached:", item['file'])

运行此代码工作正常。

但是,当我继续工作时,我收到以下错误:

RuntimeError                              Traceback (most recent call last)
<ipython-input-26-c873a36fb4b7> in <module>
      1 # peek
----> 2 reader = create_reader(data['train']['file'], is_training=True)
      3 reader.streams.keys()

<ipython-input-23-81736f039ae7> in create_reader(path, is_training)
      4          intent_unused = C.io.StreamDef(field='S1', shape=num_intents, is_sparse=True),
      5          slot_labels   = C.io.StreamDef(field='S2', shape=num_labels,  is_sparse=True)
----> 6      )), randomize=is_training, max_sweeps = C.io.INFINITELY_REPEAT if is_training else 1)

~\Anaconda333\lib\site-packages\cntk\io\__init__.py in __init__(self, deserializers, max_samples, max_sweeps, randomization_window_in_chunks, randomization_window_in_samples, randomization_seed, trace_level, multithreaded_deserializer, frame_mode, truncation_length, randomize)
    191             config.randomization_window_in_samples = 0
    192 
--> 193         source = cntk_py.create_composite_minibatch_source(config)
    194         # transplant into this class instance
    195         self.__dict__ = source.__dict__

RuntimeError: Expected a sequence id at the offset 0, none was found.

[CALL STACK]
    > CreateDeserializer
    - Microsoft::MSR::CNTK::IDataReader::  SupportsDistributedMBRead (x3)
    - CreateDeserializer
    - CreateCompositeDataReader (x3)
    - CNTK::  UniversalLearner
    - CNTK::  CreateCompositeMinibatchSource
    - PyInit__cntk_py
    - PyCFunction_FastCallDict
    - PyObject_GetAttr
    - PyEval_EvalFrameDefault
    - PyObject_IsInstance
    - PyFunction_FastCallDict

感谢您的帮助

【问题讨论】:

  • @anky_91 知道吗?谢谢

标签: python directory location jupyter-notebook cntk


【解决方案1】:

你可能想看看this

其次,假设我们在以下选项卡中有一个数据集 分隔文本格式:* 第一列是序列 ID:e.g. 0 是 sequecne 0 的 ID; 1 是序列 1 的 ID。 * 第二个 列以符号“|”开头。它是名为“x”的特征,它是 我们训练数据中单词的稀疏表示。 * 第三 列再次以符号“|”开头。我们的标签名为“y” 是标签的 one-hot 表示。

基本上,我认为您的源数据文件格式不正确。您可能需要在每一行的开头包含一个序列 ID。

【讨论】:

  • 您查看过链接吗?它提供了一个应该如何完成的示例
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-13
  • 1970-01-01
  • 1970-01-01
  • 2019-01-16
  • 2020-11-25
相关资源
最近更新 更多