Tuesday, March 23, 2021

Colab(九。一):TensorFlow - LeNet

 Colab(九。一):TensorFlow - LeNet

2021/03/23

-----

說明:

這是 Kaggle 提供的 LeNet 範例,最後會輸出提交的結果。

-----


https://pixabay.com/zh/photos/poles-water-rotten-old-motion-1030747/

-----

步驟:


一、將 [1] 的內容移入 Colab。


二、加入以下指令

from google.colab import drive

drive.mount('/content/drive/')

# 點入系統提供的連結之後,登入自己的帳戶,會得到一組授權碼,將授權碼輸入後,即可存取自己的 Google Drive。

!ls '/content/drive/My Drive/'


三、修改輸入與輸出檔案的路徑為:

train = pd.read_csv('/content/drive/My Drive/train.csv')

test = pd.read_csv('/content/drive/My Drive/test.csv')

test.to_csv('/content/drive/My Drive/submit.csv', columns = ["Label"])


四、將原來匯入的 tensorflow 

import tensorflow as tf

改為匯入之前的精簡版本 [2], [3]:

import tensorflow.compat.v1 as tf

tf.disable_v2_behavior() 


五、以上都修改後即可正常執行(執行時會出現警告訊息)。


六、檢查 Google Drive 根目錄是否有 submit.csv 檔。


七、可嘗試 TensorFlow 其他的 LeNet 版本 [4]。

-----

References


[1] LeNet-5 Architecture for MNIST using Tensorflow | Kaggle

https://www.kaggle.com/niranjanjagannath/lenet-5-architecture-for-mnist-using-tensorflow


[2] AttributeError: module 'tensorflow' has no attribute 'placeholder' · Issue #14 · theislab/scgen · GitHub

https://github.com/theislab/scgen/issues/14


[3] python - TensorFlow, "'module' object has no attribute 'placeholder'" - Stack Overflow

https://stackoverflow.com/questions/37383812/tensorflow-module-object-has-no-attribute-placeholder


[4] advanced.ipynb - Colaboratory

https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/quickstart/advanced.ipynb#scrollTo=DUNzJc4jTj6G


-----

從 Colab 到 Kaggle(目錄)

https://hemingwang.blogspot.com/2021/03/colab_12.html

-----

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.