module numpy has no attribute unit8

0 votes

Hi Guys,

I am trying to run the below CNN code in my system, but it is showing me an error.

import sys
os sys.path.append(os.pardir) 
import numpy as np 
from dataset.mnist import load_mnist 
from PIL import Image 
def img_show (img) : 
  pil_img = Image.fromarray(np.unit8(img)) 
  pil_img.show() 
module 'numpy' has no attribute 'unit8'

How can I solve this error?

Jun 23, 2020 in Python by akhtar
• 38,210 points
6,558 views

1 answer to this question.

0 votes

Hi@akhtar,

You have used unit8 in your code. But NumPy has no attribute named unit8. You have to use uint8 instead of unit8 in your code. So make changes in your code and try once again. It will work.

import sys
os sys.path.append(os.pardir) 
import numpy as np 
from dataset.mnist import load_mnist 
from PIL import Image 
def img_show (img) : 
  pil_img = Image.fromarray(np.uint8(img)) 
  pil_img.show() 
answered Jun 23, 2020 by MD
• 95,300 points

Related Questions In Python

0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,520 points
6,566 views
0 votes
0 answers

'module' object has no attribute 'PortScanner'

I am trying to run nmap in ...READ MORE

Jan 30, 2019 in Python by Karan
798 views
0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'mainloop'" python module turtle

Hey @Nagya, replace  wn.mainlopp() with turtle.mainloop() ...READ MORE

answered Jun 19, 2019 in Python by Faiza
3,533 views
0 votes
1 answer

How to rename columns in pandas (Python)?

You can use the rename function in ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8, 2020 by MD 768 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is "size" includes NaN values, ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8, 2020 by Gitika 1,588 views
0 votes
2 answers

Replacing a row in pandas data.frame

key error. I love python READ MORE

answered Feb 18, 2019 in Data Analytics by anonymous
9,724 views
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,620 points
3,637 views
0 votes
2 answers

module 'numpy' has no attribute 'unit8'

Hi@Ganesh, I think you are calling the wrong ...READ MORE

answered Sep 22, 2020 in Python by MD
• 95,300 points
737 views
0 votes
1 answer

AttributeError: module 'numpy' has no attribute '__version__'

Hi@akhtar, To avoid this error you can use ...READ MORE

answered Apr 20, 2020 in Python by MD
• 95,300 points
11,111 views