View_classify in module 'helper'

username: Gafar
cooked: <p>I’m getting this error anytime I try using the module ‘helper’ to pass an image to the network.</p>
<p>module ‘helper’ has no attribute ‘view_classify’</p>
<p>What can I do about it?</p>

username: ptrblck
cooked: <p>Where did you find the method <code>view_classify</code>?<br>
It seems you are using some kind of wrapper (maybe from the Udacity course)?</p>

username: Gafar
cooked: <p>Yeah, Thank you. I got it resolved already.</p>

username: imtherealnaska
cooked: <p>how did you get it solved?<br>
i am also getting the same error</p>

username: Aditya_Gayan
cooked: <p>Hey, can you tell me how you resolved this problem?<br>
P.S. I already have helper.py file in ‘deep-learning-v2-pytorch-master\intro-to-pytorch’ folder.</p>

username: GokulDAS027
cooked: <p><strong>[<span class="hashtag">#Solution</span>] Udacity Specifically</strong><br>
<em>helper</em>  used here is not from pip but a .py file made by udacity, which is available in the repo<br>
and <em><strong>view_classify</strong></em> is declared inside that.</p>
<p>The code is :</p>
<pre><code class="lang-auto">import matplotlib.pyplot as plt
import numpy as np

def view_classify(img, ps, version="MNIST"):
    ''' Function for viewing an image and it's predicted classes.
    '''
    ps = ps.data.numpy().squeeze()

    fig, (ax1, ax2) = plt.subplots(figsize=(6,9), ncols=2)
    ax1.imshow(img.resize_(1, 28, 28).numpy().squeeze())
    ax1.axis('off')
    ax2.barh(np.arange(10), ps)
    ax2.set_aspect(0.1)
    ax2.set_yticks(np.arange(10))
    if version == "MNIST":
        ax2.set_yticklabels(np.arange(10))
    elif version == "Fashion":
        ax2.set_yticklabels(['T-shirt/top',
                            'Trouser',
                            'Pullover',
                            'Dress',
                            'Coat',
                            'Sandal',
                            'Shirt',
                            'Sneaker',
                            'Bag',
                            'Ankle Boot'], size='small');
    ax2.set_title('Class Probability')
    ax2.set_xlim(0, 1.1)

plt.tight_layout()
</code></pre>

username: Logamou_Seknewna_Lem
cooked: <p>Hi,</p>
<p>I had the same issue but solved it by importing all the <strong>notebooks</strong> (after cloning the repository) in <strong>Jupyter</strong>. If you want to see the images, you also have to create the ‘assets’ folder (in Jupyter) and then copy all the files from the asset folder in there.</p>
<p>I hope this helps.</p>

username: kartikpodugu
cooked: <p>Paste helper.py from the course folder into the folder where you are working and it should work</p>

username: Oudarjya718
cooked: <p>did the same see<br>
still getting the error<br>
<a href="https://gyazo.com/db7cdf213eafea306f97787fdd992b73" class="onebox" target="_blank" rel="nofollow noopener">https://gyazo.com/db7cdf213eafea306f97787fdd992b73</a><br>
as you can see i have helper.py on the left</p>

username: snip3r77
cooked: <p>I can’t get it to work eventhough I change the path<br>
( pls see the yellow color highlighted )<br>
                    <a href="https://i.imgur.com/tCURF4y.png" target="_blank" class="onebox" rel="nofollow noopener">
            <img src="https://i.imgur.com/tCURF4y.png" width="690" height="497">
          </a>

</p>
<p>of course if I were to copy and paste the code in the same notebook it will work but I want to solve this issue of mine if it’s possible.</p>
<p>Thanks.</p>

username: GokulDAS027
cooked: <p>Check the helper.py file and verify it has view_classify function.<br>
And in case if it doesn’t, copy paste the same to helper.py<br>
If it have, verify the function name.<br>
The module is found, it’s just the function that is missing…</p>

username: KhaledNasser
cooked: <p>first, make sure that you have “helper.py” in the same directory<br>
then choose restart runtime from the runtime</p>

username: WIZARDELF
cooked: <p>in any code cell, run:</p>
<pre><code class="lang-auto">!wget https://raw.githubusercontent.com/udacity/deep-learning-v2-pytorch/3bd7dea850e936d8cb44adda8200e4e2b5d627e3/intro-to-pytorch/helper.py
</code></pre>
<p>Reload the page, restart runtime, and run all.</p>

username: Petr_Frolkin
cooked: <p>I coppied view_classify() function into the same file and still getting nothing. No error, just nothing happens. Once the network is done training - shell is just waiting for a new command. Can anybody help please?</p>

username: ptrblck
cooked: <p>Could you post the code which shows how you are calling this method?</p>

username: Petr_Frolkin
cooked: <p>I made it work in Jupyter Notebooks, maybe something is wrong with python on my computer</p>