%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
from glob import glob
import seaborn as sns
from PIL import Image
np.random.seed(123)
from sklearn.preprocessing import label_binarize
from sklearn.metrics import confusion_matrix
import itertools
import keras
from keras.utils.np_utils import to_categorical # used for converting labels to one-hot-encoding
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D
from keras import backend as K
import itertools
from keras.layers.normalization import BatchNormalization
from keras.utils.np_utils import to_categorical # convert to one-hot-encoding
from keras.optimizers import Adam
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import ReduceLROnPlateau
from sklearn.model_selection import train_test_split
当我将tensorflow下载到anaconda时出现错误,我不知道为什么会出现此错误,有人可以帮助我,因为我是anaconda的新手 此代码是从链接为https://www.kaggle.com/sid321axn/step-wise-approach-cnn-model-77-0344-accuracy的kaggle复制而来的 但我不知道为什么会遇到这个错误
ImportError Traceback (most recent call last)
<ipython-input-1-36803f80ec4f> in <module>
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')
2 import matplotlib.pyplot as plt
3 import numpy as np
4 import pandas as pd
5 import os
~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2285 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2286 with self.builtin_trap:
-> 2287 result = fn(*args,**kwargs)
2288 return result
2289
<decorator-gen-108> in matplotlib(self, line)
~\Anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~\Anaconda3\lib\site-packages\IPython\core\magics\pylab.py in matplotlib(self, line)
97 print("Available matplotlib backends: %s" % backends_list)
98 else:
---> 99 gui, backend = self.shell.enable_matplotlib(args.gui)
100 self._show_matplotlib_backend(args.gui, backend)
101
~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in enable_matplotlib(self, gui)
3353 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3354
-> 3355 pt.activate_matplotlib(backend)
3356 pt.configure_inline_support(self, backend)
3357
~\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in activate_matplotlib(backend)
311 matplotlib.rcParams['backend'] = backend
312
--> 313 import matplotlib.pyplot
314 matplotlib.pyplot.switch_backend(backend)
315
~\Anaconda3\lib\site-packages\matplotlib\pyplot.py in <module>
29 from cycler import cycler
30 import matplotlib
---> 31 import matplotlib.colorbar
32 from matplotlib import style
33 from matplotlib import _pylab_helpers, interactive
~\Anaconda3\lib\site-packages\matplotlib\colorbar.py in <module>
30
31 import matplotlib as mpl
---> 32 import matplotlib.artist as martist
33 import matplotlib.cbook as cbook
34 import matplotlib.collections as collections
~\Anaconda3\lib\site-packages\matplotlib\artist.py in <module>
14 import matplotlib
15 from . import cbook, docstring, rcParams
---> 16 from .path import Path
17 from .transforms import (Bbox, IdentityTransform, Transform, TransformedBbox,
18 TransformedPatchPath, TransformedPath)
~\Anaconda3\lib\site-packages\matplotlib\path.py in <module>
19 import numpy as np
20
---> 21 from . import _path, rcParams
22 from .cbook import (_to_unmasked_float_array, simple_linear_interpolation,
23 maxdict)
ImportError: cannot import name '_path'
答案 0 :(得分:0)
检查您的环境。该代码工作正常。