本文主要是介绍from tensorflow.keras.layers import Dense,Flatten,Input报错无法引用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
from tensorflow.keras.layers import Dense,Flatten,Input
打印一下路径:
import tensorflow as tf
import keras
print(tf.__path__)
print(keras.__path__)
['E:\\开发工具\\pythonProject\\studyLL\\venv\\lib\\site-packages\\keras\\api\\_v2',
'E:\\开发工具\\pythonProject\\studyLL\\venv\\lib\\site-packages\\keras\\_tf_keras',
'E:\\开发工具\\pythonProject\\studyLL\\venv\\lib\\site-packages\\tensorflow_estimator\\python\\estimator\\api\\_v2',
'E:\\开发工具\\pythonProject\\studyLL\\venv\\lib\\site-packages\\tensorboard\\summary\\_tf', 'E:\\开发工具\\pythonProject\\studyLL\\venv\\lib\\site-packages\\tensorflow',
'E:\\开发工具\\pythonProject\\studyLL\\venv\\lib\\site-packages\\tensorflow\\_api\\v2']
['E:\\开发工具\\pythonProject\\studyLL\\venv\\lib\\site-packages\\keras']
做一下修改,分开来引用:
import tensorflow as tf import keras from keras.layers import Dense,Flatten,Input from keras.models import Model from tensorflow.python.keras.layers.embeddings import Embedding from keras.preprocessing.sequence import pad_sequences from keras.preprocessing.text import one_hot import numpy as np
运行报错:
ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires
that these DLLs be installed in a directory that is named in your %PATH% environment variable.
You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual
Studio 2015, 2017 and 2019" for your platform from this URL:
https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads
链接:https://learn.microsoft.com/zh-CN/cpp/windows/latest-supported-vc-redist?view=msvc-170
下载x64进行安装
再次运行tensorflow就ok了。
这篇关于from tensorflow.keras.layers import Dense,Flatten,Input报错无法引用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!