module 'numpy' has no attribute 'max' - python-3.x

I did the above code, I got the error message "module 'numpy' has no attribute 'max'." How should I do?
Python 3.7.2, numpy-1.17.2, macOS 10.14.5, and jupyter notebook
import numpy as np
np.array(range(10))
or
import numpy as np
np.arange(1, 51)

Related

ImportError: cannot import name 'int_classes' from 'torch._six' (/usr/local/lib/python3.7/dist-packages/torch/_six.py)

I am working on healthcare image dataset for image segmentation. More specific, it is "Spinal Cord Gray Matter Segmentation Using PyTorch". When I am trying to install libraries initially using this code:
!pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.0-cp36-cp36m-linux_x86_64.whl
!pip3 install torchvision
!pip install medicaltorch
!pip3 install numpy==1.14.1
it is showing some errors in between required satisfied like this:
1st screenshot
2nd screenshot
After that I am importing libraries:
from collections import defaultdict
import time
import os
import numpy as np
from tqdm import tqdm
from medicaltorch import datasets as mt_datasets
from medicaltorch import models as mt_models
from medicaltorch import transforms as mt_transforms
from medicaltorch import losses as mt_losses
from medicaltorch import metrics as mt_metrics
from medicaltorch import filters as mt_filters
import torch
from torchvision import transforms
from torch.utils.data import DataLoader
from torch import autograd, optim
import torch.backends.cudnn as cudnn
import torch.nn as nn
import torchvision.utils as vutils
cudnn.benchmark = True
import matplotlib.pyplot as plt
%matplotlib inline
This importing is throwing an error like this:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-80b8c583d1fe> in <module>()
20
21
---> 22 from medicaltorch import datasets as mt_datasets
23 from medicaltorch import models as mt_models
24 from medicaltorch import transforms as mt_transforms
/usr/local/lib/python3.7/dist-packages/medicaltorch/datasets.py in <module>()
11 from torch.utils.data import Dataset
12 import torch
---> 13 from torch._six import string_classes, int_classes
14
15 from PIL import Image
ImportError: cannot import name 'int_classes' from 'torch._six' (/usr/local/lib/python3.7/dist-packages/torch/_six.py)
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
can someone help me resolve this?
In pytorch 1.9 int_classes variable in torch._six was removed. facebookresearch/TimeSformer#47
Use this code instead.
from torch._six import string_classes
int_classes = (bool, int)
See source here: https://github.com/visionml/pytracking/issues/272

AttributeError: module 'matplotlib' has no attribute 'scatter'

I'm trying to make cluster of latitude and longitude.
the code gave an error in plt.scatter(data['Lng'],data['Lat']) line
the error is:
AttributeError: module 'matplotlib' has no attribute 'scatter'
code:
import numpy as np
import pandas as pd
import matplotlib as plt
import seaborn as sns
sns.set()
from sklearn.cluster import KMeans
data = pd.read_csv("pk.csv")
data.head()
lat_long = data.drop(['country', 'iso2','admin', 'capital','population',
'population_proper'] , axis = 1)
lat_long.head()
plt.scatter(data['Lng'],data['Lat']) # error here
It should be:
import matplotlib.pyplot as plt
Or it can be:
from matplotlib import pyplot as plt
Also you can read PEP 328 for more information and clearity.

'float' object has no attribute 'exp' in spyder python

import numpy as np
from scipy import interpolate
import pylab as py
import pandas as pd
def func(x1):
return x*np.exp(-5.0*x1**2)
dataset=pd.read_excel('Messwerte_FIBRE1.xlsx')
dataset=dataset.drop([0])
index=[1]
index2=[9]
x=dataset.iloc[:, index]
y=dataset.iloc[:, index2]
x1=np.array(x)
y1=np.array(y)
fvals=func(x1)
File "C:/Users/Windows 10/.spyder-py3/RBF.py", line 10, in func
return x*np.exp(-5.0*x1**2)
AttributeError: 'float' object has no attribute 'exp'
Any1 can help me to solve this problem?
Here is the png of my textfile
np.exp(...)
'float' object has no attribute 'exp'
This means that you likely have redefined the name np, and now it's a floating-point number and not the numpy module any more.
Look around your code for np = ....

This code is running perfectly in jupyter but not in python 3.6

It generates an error {{import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'}}
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
style.use('ggplot')
start = dt.datetime(2000, 1, 1)
end = dt.datetime(2016, 12, 31)
df = web.DataReader('TSLA', "yahoo", start, end)
print(df.head())
You have to install matplotlib module, do:
$pip3 install matplotlib

How to use waldboost detector in opencv-3.2 using python

import cv2
import numpy as np
detector=cv2.createWaldBoost()
but this code is showing me error
detector=cv2.createWaldBoost()
AttributeError: module 'cv2' has no attribute 'createWaldBoost'

Resources