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自學聖經(第二版):從完整入門到職場活用的技巧與實例大全

 

  python機器學習與深度學習特訓班

George Seng

George Seng
更新時間:2020/7/13 上午 01:54:17

 

親愛的作者您好, 最近閱讀您的大作: Python機器學習與深度學習特訓班, 有一個問題請教:

TensorFlow GPU
keras installed

行 ch02 Keras_Mnist_MLP 程式時

runfile('H:/本書範例/ch02/Keras_Mnist_MLP.py', wdir='H:/本書範例/ch02')
Epoch 1/10
240/240 - 1s - loss: 0.4327 - accuracy: 0.8837 - val_loss: 0.2150 - val_accuracy: 0.9405
Epoch 2/10
240/240 - 1s - loss: 0.1877 - accuracy: 0.9471 - val_loss: 0.1546 - val_accuracy: 0.9569
Epoch 3/10
240/240 - 1s - loss: 0.1327 - accuracy: 0.9618 - val_loss: 0.1283 - val_accuracy: 0.9626
Epoch 4/10
240/240 - 1s - loss: 0.1022 - accuracy: 0.9715 - val_loss: 0.1118 - val_accuracy: 0.9682
Epoch 5/10
240/240 - 1s - loss: 0.0810 - accuracy: 0.9775 - val_loss: 0.0953 - val_accuracy: 0.9727
Epoch 6/10
240/240 - 1s - loss: 0.0658 - accuracy: 0.9821 - val_loss: 0.0924 - val_accuracy: 0.9724
Epoch 7/10
240/240 - 1s - loss: 0.0542 - accuracy: 0.9850 - val_loss: 0.0899 - val_accuracy: 0.9732
Epoch 8/10
240/240 - 1s - loss: 0.0454 - accuracy: 0.9875 - val_loss: 0.0854 - val_accuracy: 0.9747
Epoch 9/10
240/240 - 1s - loss: 0.0387 - accuracy: 0.9899 - val_loss: 0.0835 - val_accuracy: 0.9755
Epoch 10/10
240/240 - 1s - loss: 0.0331 - accuracy: 0.9916 - val_loss: 0.0852 - val_accuracy: 0.9747
313/313 [==============================] - 0s 781us/step - loss: 0.0774 - accuracy: 0.9761

準確率= 0.9761000275611877
WARNING:tensorflow:From H:\本書範例\ch02\Keras_Mnist_MLP.py:84: Sequential.predict_classes (from tensorflow.python.keras.engine.sequential) is deprecated and will be removed after 2021-01-01.
Instructions for updating:
Please use instead:* `np.argmax(model.predict(x), axis=-1)`,   if your model does multi-class classification   (e.g. if it uses a `softmax` last-layer activation).* `(model.predict(x) > 0.5).astype("int32")`,   if your model does binary classification   (e.g. if it uses a `sigmoid` last-layer activation).

Figures now render in the Plots pane by default. To make them also appear inline in the Console, uncheck "Mute Inline Plotting" under the Plots pane options menu.

<<<請問 240/240 在下句的意思 為何是 240, 而不是768之類 ? 不知那些warnings 是甚麽 ?>>>

Epoch 1/10
240/240 - 1s - loss: 0.4327 - accuracy: 0.8837 - val_loss: 0.2150 - val_accuracy: 0.9405

<<<又如 save to document 而execute, 不知那些warnings 是甚麽 ?:>>>

runfile('C:/Users/George/Documents/Keras_Mnist_MLP.py', wdir='C:/Users/George/Documents')
Reloaded modules: tmpqaml15om, tmpubp7y5k4, tmplriedydn
Epoch 1/10
WARNING:tensorflow:AutoGraph could not transform <function Model.make_train_function.<locals>.train_function at 0x00000296B255E950> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause:
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
WARNING: AutoGraph could not transform <function Model.make_train_function.<locals>.train_function at 0x00000296B255E950> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause:
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
WARNING:tensorflow:AutoGraph could not transform <function Model.make_test_function.<locals>.test_function at 0x00000296DB8FBA60> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause:
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
WARNING: AutoGraph could not transform <function Model.make_test_function.<locals>.test_function at 0x00000296DB8FBA60> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause:
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
240/240 - 1s - loss: 0.4423 - accuracy: 0.8821 - val_loss: 0.2279 - val_accuracy: 0.9357
Epoch 2/10
240/240 - 1s - loss: 0.1911 - accuracy: 0.9451 - val_loss: 0.1587 - val_accuracy: 0.9548
Epoch 3/10
240/240 - 1s - loss: 0.1357 - accuracy: 0.9614 - val_loss: 0.1281 - val_accuracy: 0.9632
Epoch 4/10
240/240 - 1s - loss: 0.1041 - accuracy: 0.9705 - val_loss: 0.1091 - val_accuracy: 0.9674
Epoch 5/10
240/240 - 1s - loss: 0.0840 - accuracy: 0.9771 - val_loss: 0.1048 - val_accuracy: 0.9708
Epoch 6/10
240/240 - 1s - loss: 0.0681 - accuracy: 0.9805 - val_loss: 0.0926 - val_accuracy: 0.9738
Epoch 7/10
240/240 - 1s - loss: 0.0548 - accuracy: 0.9853 - val_loss: 0.0876 - val_accuracy: 0.9730
Epoch 8/10
240/240 - 1s - loss: 0.0449 - accuracy: 0.9878 - val_loss: 0.0821 - val_accuracy: 0.9748
Epoch 9/10
240/240 - 1s - loss: 0.0379 - accuracy: 0.9901 - val_loss: 0.0813 - val_accuracy: 0.9756
Epoch 10/10
240/240 - 1s - loss: 0.0317 - accuracy: 0.9918 - val_loss: 0.0802 - val_accuracy: 0.9768
313/313 [==============================] - 0s 774us/step - loss: 0.0757 - accuracy: 0.9767

準確率= 0.9767000079154968
WARNING:tensorflow:AutoGraph could not transform <function Model.make_predict_function.<locals>.predict_function at 0x00000296DCA0B8C8> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause:
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert
WARNING: AutoGraph could not transform <function Model.make_predict_function.<locals>.predict_function at 0x00000296DCA0B8C8> and will run it as-is.
Please report this to the TensorFlow team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output.
Cause:
To silence this warning, decorate the function with @tf.autograph.experimental.do_not_convert

文淵閣工作室

文淵閣工作室
更新時間:2020/7/21 上午 10:00:15

 

感謝您的支持:
從顯示訊息看來,目前較新的版本 tensorflow (2.2.0),會在 2021-01-01 後棄用一些語法,例如:
一、predict_classes 方法

二、以 print(np.argmax(test_label_onehot,axis=-1) 顯示
test_label_onehot = np_utils.to_categorical(test_label) 的 One-Hot Encoding 編碼。
等等…

每個 Epoch 中的 240/240,我目前仍不知其意義,猜測是它內部訊息碼的代號。

至於新的語法怎麼用,我們會持續注意這些文件。

下列這一篇文章有提到如何存至 log 檔。
https://stackoverflow.com/questions/38445982/how-to-log-keras-loss-output-to-a-file

以下這兩文章也提供您參考。
https://www.tensorflow.org/api_docs/python/tf/keras/Sequential

http://hk.uwenku.com/question/p-apiyrimv-bgr.html

陳一誠

陳一誠
更新時間:2020/8/3 下午 08:25:14

 

在sypder下執行
import tensorflow as tf

出現以下錯誤訊息。

File "C:\Users\user\anaconda3\envs\tensorflowenv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)

ImportError: Traceback (most recent call last):
  File "C:\Users\user\anaconda3\envs\tensorflowenv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: 找不到指定的模組。


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

請問如何處理?

文淵閣工作室

文淵閣工作室
更新時間:2020/8/4 上午 09:35:34

 

您好:
我們並沒有碰到您的問題,所以只能依照經驗和網路上搜尋給您提供一些意見。
一、請確定自已使用的 python、tensorflow、keras 版本。
    在 console 下以 python --version 可以查看 python 版本
                    pip list 可以查看tensorflow、keras 版本。

二、網路上建議,最簡便方式是移除 tensorflow 後再重裝,即
    pip uninstall tensorflow
    pip install tensorflow

三、如果方法二不行,建議您移除 Anaconda 後,重新安裝全新的環境。

預祝順利

張文泉

張文泉
更新時間:2021/4/14 下午 09:04:04

 

hi 我使用的版本:tensorflow-gpu 2.4.1
在使用上也有類似問題,解法如下:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
os.environ['TF_XLA_FLAGS'] = '--tf_xla_enable_xla_devices'
os.environ['AUTOGRAPH_VERBOSITY'] = '1'
另外系統要求加decorate
可以用以下做法:
例如:
原先跑
model.fit_generator(  
train_generator,
steps_per_epoch=100,
epochs=100,
validation_data=validation_generator,
validation_steps=50)
可以改成decorate + 自定義function
如下
@tf.autograph.experimental.do_not_convert
def runhist():
    history = model.fit(  
train_generator,
steps_per_epoch=100,
epochs=100,
validation_data=validation_generator,
validation_steps=50)

就不會出現左邊的訊息,並且可以正常執行
供參考
謝謝
ps:爬文看起來是個tensorflow bug




 

 

Re:python機器學習與深度學習特訓班

請輸入姓名。

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


請輸入電子郵件。

格式無效。


請輸入內容。