簡體   English   中英

用 Keras 實現神經網絡

[英]Implementing Neural Nets with Keras

我正在嘗試在我的計算機中實現此代碼,我面臨的問題是運行以下代碼時出現錯誤:

fashion_mnist = keras.datasets.fashion_mnist
(X_train_full, y_train_full), (X_test, y_test) = (fashion_mnist.load_data())
X_valid, X_train = X_train_full[:5000], X_train_full[5000:]
y_valid, y_train = y_train_full[:5000], y_train_full[5000:]

錯誤:

~\Anaconda3\lib\site-packages\tensorflow_core\python\keras\utils\data_utils.py in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir)
    251         urlretrieve(origin, fpath, dl_progress)
    252       except HTTPError as e:
--> 253         raise Exception(error_msg.format(origin, e.code, e.msg))
    254       except URLError as e:
    255         raise Exception(error_msg.format(origin, e.errno, e.reason))

Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz: 403 -- Forbidden

但是如果我嘗試單獨下載數據,它不會給出禁止的錯誤,我嘗試加載數據而不從谷歌下載,但又出現了另一個錯誤

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-68fe7d0ac27a> in <module>
      1 fashion_mnist = keras.datasets.fashion_mnist
----> 2 (X_train_full, y_train_full), (X_test, y_test) = (fashion_mnist)
      3 X_valid, X_train = X_train_full[:5000], X_train_full[5000:]
      4 y_valid, y_train = y_train_full[:5000], y_train_full[5000:]

TypeError: cannot unpack non-iterable module object

最后,我決定不使用load_data()方法但仍然出現相同的錯誤,有沒有辦法在不使用上述方法的情況下從train-labels-idx1-ubyte解包和准備數據?

PS:我嘗試使用 VPN 但仍然響應禁止

如果下載正確,則需要指定路徑。

你有沒有試過(X_train_full, y_train_full), (X_test, y_test) = fashion_mnist.load_data (path="%yourLocalPath%")作為記錄在這里 張量流文檔

如果不是,您遇到的第一個錯誤是因為您居住在禁止使用 TensorFlow 的地方,只需使用 VPN。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM