Error data shape

randino: <p>when I tested this code:</p>
<pre><code class="lang-auto">
import numpy as np
from scipy import ndimage as img
from scipy import io as sio
import matplotlib.pyplot as plt
import pyshearlab
from os.path import dirname, join as pjoin
import scipy.io as sio
import  torch
tic()

sigma = 30
scales = 3
thresholdingFactor = 3

imd = pjoin('./data/', 'image.mat')
X = sio.loadmat(imd)

shearletSystem = pyshearlab.SLgetShearletSystem2D(0,X.shape[0], X.shape[1], scales)
</code></pre>
<p>error:<br>
AttributeError: ‘dict’ object has no attribute ‘shape’</p>

ZimoNitrome: <p>I don’t recognize all of these libraries but your variable <code>X</code> is a <code>dict</code>.</p>
<p>And <code>dict</code>s have no <code>.shape</code> attribute. So calling <code>X.shape</code> throws an error.</p>
<p>Try to <code>print(X)</code> or <code>print(X.keys())</code> to see what <code>X</code> holds. Maybe one of the <code>.values</code> of <code>X</code> is a <code>numpy.array</code> or <code>torch.tensor</code> which both have the <code>.shape</code> attribute.</p>

randino: <p><a class="mention" href="/u/zimonitrome">@ZimoNitrome</a>  thanks for reply, but</p>
<pre><code class="lang-auto">mat = pjoin('./sample_data/', 'gt.mat')
X1 = sio.loadmat(mat)
print(X1.keys)
</code></pre>
<p>–SLExampleImageDenoising<br>
loading image…<br>
&lt;built-in method keys of dict object at 0x7efe869a8c30&gt;</p>

ZimoNitrome: <p>you forgot the parentheses:</p>
<pre><code class="lang-python">mat = pjoin('./sample_data/', 'gt.mat')
X1 = sio.loadmat(mat)
print(X1.keys())
</code></pre>

ZimoNitrome: <p>Try reading up on how to use and index dictionaries. Some of your error messages can probably be found through a simple google search.</p>
<aside class="onebox stackexchange" data-onebox-src="https://stackoverflow.com/questions/35407560/attributeerror-dict-object-has-no-attribute-predictors">
  <header class="source">

      <a href="https://stackoverflow.com/questions/35407560/attributeerror-dict-object-has-no-attribute-predictors" target="_blank" rel="noopener nofollow ugc">stackoverflow.com</a>
  </header>

  <article class="onebox-body">
      <a href="https://stackoverflow.com/users/5018660/mike" target="_blank" rel="noopener nofollow ugc">
    <img alt="Mike" src="https://www.gravatar.com/avatar/65a2e7c3410db8095222ac1acd5f2fa5?s=256&amp;d=identicon&amp;r=PG&amp;f=1" class="thumbnail onebox-avatar" width="256" height="256">
  </a>

<h4>
  <a href="https://stackoverflow.com/questions/35407560/attributeerror-dict-object-has-no-attribute-predictors" target="_blank" rel="noopener nofollow ugc">AttributeError: 'dict' object has no attribute 'predictors'</a>
</h4>

<div class="tags">
  <strong>python</strong>
</div>

<div class="date">
  asked by
  
  <a href="https://stackoverflow.com/users/5018660/mike" target="_blank" rel="noopener nofollow ugc">
    Mike
  </a>
  on <a href="https://stackoverflow.com/questions/35407560/attributeerror-dict-object-has-no-attribute-predictors" target="_blank" rel="noopener nofollow ugc">10:57AM - 15 Feb 16 UTC</a>
</div>

  </article>

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

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