New Ribbon
用Canva設計超快超質感(第2版):商業設計、簡報、影片、網頁、電子書與AI應用最速技 AI繪圖工具 × AI視覺設計平台,從圖像生成到專業設計! 最強職場助攻!ChatGPT + AI 高效工作術 短影音制霸:打造TikTok、YT Shorts、IG Reels成功方程式與AI高效創作力 Canva+AI創意設計與品牌應用250招:從商業技巧、社群祕技到AI圖文影音特效 快快樂樂學威力導演2024.影音剪輯與AI精彩創作 Power Automate自動化超效率工作術 Midjourney AI圖像魔導書:搭配ChatGPT魔法加倍 超人氣FB+IG+LINE社群經營與行銷力(第二版) 翻倍效率工作術:不會就太可惜的 Excel × ChatGPT 自動化應用 AppInventor2零基礎入門班中文版(第六版) Python零基礎入門班(第四版) C語言學習聖經 用Canva設計超快超質感:平面、網頁、電子書、簡報、影片製作與AI繪圖最速技 PHP8/MySQL網頁程式設計自學聖經 翻倍效率工作術 - 不會就太可惜的Power BI大數據視覺圖表設計與分析(第三版) 社群經營一定要會的影音剪輯與動畫製作術 Notion高效管理250招:筆記×資料庫×團隊協作,數位生活與工作最佳幫手 Office 2021高效實用範例必修16課(附500分鐘影音教學/範例檔) Excel自學聖經(第二版):從完整入門到職場活用的技巧與實例大全

 

  新手求救

孫


更新時間: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機器學習與深度學習特訓班

JamesB

JamesB
更新時間:2021/9/18 下午 04:56:25

 

你看一下你的 tensorflow 是不是 2.6 版,predict_classes 這個語法在最新版的不能用,你可以安裝比較低版的 tensorflow 看看,或參考另一種寫法。
https://keras.rstudio.com/reference/predict_proba.html#details

孫


更新時間: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'

文淵閣工作室

文淵閣工作室
更新時間:2021/9/27 下午 09:41:10

 

上網 google 錯誤訊息,請參考這篇文章:
https://stackoverflow.com/questions/66178738/attributeerror-module-tensorflow-python-training-experimental-mixed-precision

內文中說 tensorflow 和 keras 版本不相容:
Because the installed tensorflow version does not match the keras version. Just uninstall keras and reinstall your own tensorflow corresponding version.

建議移除 keras 再重新安裝:
pip3 uninstall keras
pip3 install keras --upgrade


註:如果上面的操作仍不能解決,建議移除 Anaconda 後重新安裝新的環境。




 

 

Re:新手求救

請輸入姓名。

已超出字元數目的最大值。


請輸入電子郵件。

格式無效。


請輸入內容。