新手求救 |
|
孫
更新時間:2021/9/16 下午 09:09:14 |
|
範例檔Keras_Mnist_MLP我沒辦法run
File "E:\本書範例\ch02\Keras_Mnist_MLP.py", line 89, in <module> prediction=model.predict_classes(test_feature_normalize)
AttributeError: 'Sequential' object has no attribute 'predict_classes' |
|
|
|
孫
更新時間:2021/9/17 上午 10:34:13 |
|
from tensorflow.python.client import device_lib
for d in device_lib.list_local_devices(): print(d.name) print('-'*10)
runfile('C:/Users/USER/untitled5.py') /device:CPU:0 ----------
2021-09-17 10:28:54.828417: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-09-17 10:28:54.828731: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. 2021-09-17 10:28:57.285917: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-09-17 10:28:57.337119: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-09-17 10:28:57.337649: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cublas64_11.dll'; dlerror: cublas64_11.dll not found 2021-09-17 10:28:57.338167: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cublasLt64_11.dll'; dlerror: cublasLt64_11.dll not found 2021-09-17 10:28:57.604251: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusolver64_11.dll'; dlerror: cusolver64_11.dll not found 2021-09-17 10:28:57.604783: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusparse64_11.dll'; dlerror: cusparse64_11.dll not found 2021-09-17 10:28:57.605309: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found 2021-09-17 10:28:57.605328: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices... 2021-09-17 10:32:46.747474: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices... |
|
|
|
孫
更新時間:2021/9/17 上午 10:43:09 |
|
tensorflow keras cuda toolkit cuDNN都有安裝
|
|
|
|
孫
更新時間:2021/9/17 下午 09:58:29 |
|
書名叫python機器學習與深度學習特訓班 |
|
|
|
|
孫
更新時間:2021/9/20 下午 03:17:37 |
|
換成2.5版本
from keras.datasets import mnist (train_feature,train_label),\ (test_feature,test_label)=mnist.load_data() print(len(train_feature),len(train_label))
會出現
runfile('C:/Users/USER/untitled5.py') Traceback (most recent call last):
File "C:\Users\USER\untitled5.py", line 15, in <module> print(len(train_feature),len(train_label))
NameError: name 'train_feature' is not defined
runfile('C:/Users/USER/untitled5.py') Traceback (most recent call last):
File "C:\Users\USER\untitled5.py", line 11, in <module> from keras.datasets import mnist
File "D:\Users\USER\anaconda3\lib\site-packages\keras\__init__.py", line 25, in <module> from keras import models
File "D:\Users\USER\anaconda3\lib\site-packages\keras\models.py", line 20, in <module> from keras import metrics as metrics_module
File "D:\Users\USER\anaconda3\lib\site-packages\keras\metrics.py", line 27, in <module> from keras import activations
File "D:\Users\USER\anaconda3\lib\site-packages\keras\activations.py", line 20, in <module> from keras.layers import advanced_activations
File "D:\Users\USER\anaconda3\lib\site-packages\keras\layers\__init__.py", line 148, in <module> from keras.layers.normalization import LayerNormalization
ImportError: cannot import name 'LayerNormalization' from 'keras.layers.normalization' (D:\Users\USER\anaconda3\lib\site-packages\keras\layers\normalization\__init__.py)
|
|
|
|
孫
更新時間:2021/9/20 下午 03:18:49 |
|
好像不能安裝比較低階的tensorflow
會換其他的不能動
|
|
|
|
孫
更新時間:2021/9/20 下午 03:18:52 |
|
好像不能安裝比較低階的tensorflow
會換其他的不能動
|
|
|
|
孫
更新時間:2021/9/22 上午 11:56:31 |
|
那個,我原本的tensorflow就是2.6 |
|
|
|
孫
更新時間:2021/9/23 上午 10:39:40 |
|
不好意思,能再給一點具體的解決方案嗎 我目前還卡在最前面 |
|
|
|
文淵閣工作室
更新時間:2021/9/23 上午 11:02:49 |
|
TensorFlow 2.x 版已棄用 predict_classes方法 請將原來程式 prediction=model.predict_classes(test_feature_normalize) 改為以下兩列
#預測 # prediction=model.predict_classes(test_feature_normalize) predict_x=model.predict(test_feature_normalize) prediction=np.argmax(predict_x,axis=1) |
|
|
|
孫
更新時間:2021/9/23 下午 03:10:01 |
|
from keras.datasets import mnist (train_feature,train_label),\ (test_feature,test_label)=mnist.load_data()
runfile('E:/本書範例/ch02/untitled0.py') Traceback (most recent call last):
File "E:\本書範例\ch02\untitled0.py", line 1, in <module> from keras.datasets import mnist
File "D:\Users\USER\anaconda3\lib\site-packages\keras\__init__.py", line 25, in <module> from keras import models
File "D:\Users\USER\anaconda3\lib\site-packages\keras\models.py", line 20, in <module> from keras import metrics as metrics_module
File "D:\Users\USER\anaconda3\lib\site-packages\keras\metrics.py", line 27, in <module> from keras import activations
File "D:\Users\USER\anaconda3\lib\site-packages\keras\activations.py", line 20, in <module> from keras.layers import advanced_activations
File "D:\Users\USER\anaconda3\lib\site-packages\keras\layers\__init__.py", line 24, in <module> from keras.engine.input_layer import Input
File "D:\Users\USER\anaconda3\lib\site-packages\keras\engine\input_layer.py", line 21, in <module> from keras.engine import base_layer
File "D:\Users\USER\anaconda3\lib\site-packages\keras\engine\base_layer.py", line 41, in <module> from keras.mixed_precision import loss_scale_optimizer
File "D:\Users\USER\anaconda3\lib\site-packages\keras\mixed_precision\loss_scale_optimizer.py", line 1180, in <module> mixed_precision._register_wrapper_optimizer_cls(optimizer_v2.OptimizerV2,
AttributeError: module 'tensorflow.python.training.experimental.mixed_precision' has no attribute '_register_wrapper_optimizer_cls' |
|
|
|
孫
更新時間:2021/9/23 下午 03:12:02 |
|
(base) C:\Users\USER>pip show keras Name: keras Version: 2.6.0 Summary: TensorFlow Keras. Home-page: https://keras.io/ Author: Google Inc. Author-email: packages@tensorflow.org License: Apache 2.0 Location: d:\users\user\anaconda3\lib\site-packages Requires: Required-by: tensorflow
(base) C:\Users\USER>pip show tensorflow Name: tensorflow Version: 2.6.0 Summary: TensorFlow is an open source machine learning framework for everyone. Home-page: https://www.tensorflow.org/ Author: Google Inc. Author-email: packages@tensorflow.org License: Apache 2.0 Location: d:\users\user\anaconda3\lib\site-packages Requires: numpy, termcolor, absl-py, tensorboard, h5py, clang, keras, gast, wheel, typing-extensions, flatbuffers, astunparse, tensorflow-estimator, keras-preprocessing, wrapt, six, opt-einsum, protobuf, grpcio, google-pasta Required-by: |
|
|
|
文淵閣工作室
更新時間:2021/9/23 下午 04:00:43 |
|
您好: 我的環境是 Tensorflow 2.6.0 keras 2.6.0,看起來像您的一樣。
我將棄用的 prediction=model.predict_classes(test_feature_normalize)
改用 predict_x=model.predict(test_feature_normalize) prediction=np.argmax(predict_x,axis=1)
替代,執行是正常的,請您再確定。
如果還是有問題,建議您 Tensorflow、Keras 全部移除後再重新安裝。 您也可以 e-mail 到文淵閣工作室 service@e-happy.com.tw 這樣會比較方便傳檔案給您。 |
|
|
|
孫
更新時間:2021/9/27 下午 04:44:13 |
|
import numpy as np from keras.utils import np_utils
我只執行這兩個就碰到
mixed_precision._register_wrapper_optimizer_cls(optimizer_v2.OptimizerV2,
AttributeError: module 'tensorflow.python.training.experimental.mixed_precision' has no attribute '_register_wrapper_optimizer_cls' |
|
|
|
|
|
|
|