ValueError: malformed node or string

F219759_Salma: <p>Hi,<br>
I try to load the PyTorch model (specifically wav2vec2), using the following command:</p>
<pre><code class="lang-auto">state_dict = torch.load(model_name.pt)
arg = state_dict['args']
</code></pre>
<p>On loading the model, I’m getting errors.</p>
<pre><code class="lang-auto">  Traceback (most recent call last):
  File "/content/Wav2Keyword/downstream_kws.py", line 39, in &lt;module&gt;
    cfg = convert_namespace_to_omegaconf(state_dict['args'])
  File "/content/Wav2Keyword/fairseq/dataclass/utils.py", line 337, in convert_namespace_to_omegaconf
    overrides, deletes = override_module_args(args)
  File "/content/Wav2Keyword/fairseq/dataclass/utils.py", line 280, in override_module_args
    _override_attr(k, FairseqConfig.__dataclass_fields__[k].type, args)
  File "/content/Wav2Keyword/fairseq/dataclass/utils.py", line 226, in _override_attr
    val = ast.literal_eval(val)
  File "/usr/lib/python3.9/ast.py", line 105, in literal_eval
    return _convert(node_or_string)
  File "/usr/lib/python3.9/ast.py", line 104, in _convert
    return _convert_signed_num(node)
  File "/usr/lib/python3.9/ast.py", line 78, in _convert_signed_num
    return _convert_num(node)
  File "/usr/lib/python3.9/ast.py", line 69, in _convert_num
    _raise_malformed_node(node)
  File "/usr/lib/python3.9/ast.py", line 66, in _raise_malformed_node
    raise ValueError(f'malformed node or string: {node!r}')
ValueError: malformed node or string: &lt;ast.Name object at 0x7f50b3c82d60&gt;
</code></pre>
<p>What is the issue, and how can I resolve it?</p>
<p>Thanks</p>

nateanl: <p>Hi, the model checkpoint seems from fairseq, can you try using the load function in fairseq?</p>
<pre><code class="lang-python">cp_path = '/path/to/wav2vec.pt'
model, cfg, task = fairseq.checkpoint_utils.load_model_ensemble_and_task([cp_path])
model = model[0]
model.eval()
</code></pre>

F219759_Salma: <p>Hi, basically i am trying to run this repository from GitHub</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://github.com/qute012/Wav2Keyword">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="32" height="32">

      <a href="https://github.com/qute012/Wav2Keyword" target="_blank" rel="noopener nofollow ugc">GitHub</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/345;"><img src="https://opengraph.githubassets.com/06e605b89e2b25fe10f506f0d8ba165cfaaf4f670ecf66db56464c9990500927/qute012/Wav2Keyword" class="thumbnail" width="690" height="345"></div>

<h3><a href="https://github.com/qute012/Wav2Keyword" target="_blank" rel="noopener nofollow ugc">GitHub - qute012/Wav2Keyword: Wav2Keyword is keyword spotting(KWS) based on...</a></h3>

  <p>Wav2Keyword is keyword spotting(KWS) based on Wav2Vec 2.0. This model shows state-of-the-art in Speech commands dataset V1 and V2. - GitHub - qute012/Wav2Keyword: Wav2Keyword is keyword spotting(KW...</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>In this while running the python file, I got this error. Don’t know why this error occur.</p>
<p>Yes i am using the fairseq pretrained model.</p>