Error in importing libraries of helper though helper is installed
to solve these issue run the following code at the top most cell of your notebook to install the helper file;
!wget -c https://raw.githubusercontent.com/udacity/deep-learning-v2-pytorch/master/intro-to-pytorch/helper.py
Then restart your entire runtime for the notebook to load the file
If you're getting an AttributeError
, it suggests that you've installed helper
but a different version.
You can begin a Colab notebook with a block of only pip calls
!pip install helper==x.y.z...
And you need to run it every time you start a new runtime.
The helper library you are referring to is developed by Udacity.
Define a imshow function as following:
def imshow(image, ax=None, title=None, normalize=True): """Imshow for Tensor.""" if ax is None: fig, ax = plt.subplots() image = image.numpy().transpose((1, 2, 0)) if normalize: mean = np.array([0.485, 0.456, 0.406]) std = np.array([0.229, 0.224, 0.225]) image = std * image + mean image = np.clip(image, 0, 1) ax.imshow(image) ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) ax.spines['left'].set_visible(False) ax.spines['bottom'].set_visible(False) ax.tick_params(axis='both', length=0) ax.set_xticklabels('') ax.set_yticklabels('') return ax
Afterwards call:
imshow("your_image");
You can call image[0]
using
imshow(images[0].view(1, 28, 28));
And you're good to go!
Reference:
https://github.com/udacity/DL_PyTorch/blob/master/helper.py#L42