如何为神经网络项目修复Python中的Keras和Tensorflow导入错误

时间:2019-01-08 05:01:47

标签: python tensorflow keras

最近,为了完成一个实验,我试图在IDLE集成开发人员环境中为Python运行一个程序。该程序导入了各种模块(librosa,glob,numpy,matplotlib和Keras(在Tensorflow上运行)。我开发了单独导入这些模块的程序,以测试初步错误。当我仅运行导入这些库的代码时,Python在shell中产生了以下错误消息:

 Using TensorFlow backend.
Traceback (most recent call last):
  File "/Users/surengrigorian/Documents/Stage1.py", line 7, in <module>
    from keras.models import Sequential
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/utils/__init__.py", line 6, in <module>
    from . import conv_utils
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/utils/conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/backend/__init__.py", line 89, in <module>
    from .tensorflow_backend import *
  File                "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-        packages/keras/backend/tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

代码:

import librosa
import librosa.feature
import librosa.display
import glob
import numpy as np
import matplotlib.pyplot as plt
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.utils.np_utils import to_categorical

简而言之,预期结果将没有错误。我试图调查错误消息,并且大多数错误与它正在运行的后端程序有关。有关更多信息,请访问此网站: https://medium.com/@navdeepsingh_2336/identifying-the-genre-of-a-song-with-neural-networks-851db89c42f0

我也想知道您是否对如何开发能够按流派分类古典音乐的神经网络有任何建议,或者您是否知道任何使用图形用户界面的神经网络设计界面。多谢您提供的协助。希望您新年快乐。

0 个答案:

没有答案