最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于Tensorflow讀取MNIST數(shù)據(jù)集時網(wǎng)絡(luò)超時的解決方式

 更新時間:2020年06月22日 14:19:12   作者:sdoddyjm68  
這篇文章主要介紹了基于Tensorflow讀取MNIST數(shù)據(jù)集時網(wǎng)絡(luò)超時的解決方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

最近在學習TensorFlow,比較煩人的是使用tensorflow.examples.tutorials.mnist.input_data讀取數(shù)據(jù)

from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets('/temp/mnist_data/')
X = mnist.test.images.reshape(-1, n_steps, n_inputs)
y = mnist.test.labels

時,經(jīng)常出現(xiàn)網(wǎng)絡(luò)連接錯誤

解決方法其實很簡單,這里我們可以看一下input_data.py的源代碼(這里截取關(guān)鍵部分)

def maybe_download(filename, work_directory):
 """Download the data from Yann's website, unless it's already here."""
 if not os.path.exists(work_directory):
 os.mkdir(work_directory)
 filepath = os.path.join(work_directory, filename)
 if not os.path.exists(filepath):
 filepath, _ = urllib.request.urlretrieve(SOURCE_URL + filename, filepath)
 statinfo = os.stat(filepath)
 print('Successfully downloaded', filename, statinfo.st_size, 'bytes.')
return filepath

可以看到,代碼會先檢查文件是否存在,如果不存在再進行下載,那么我是不是自己下載數(shù)據(jù)不就行了?

MNIST的數(shù)據(jù)集是從Yann LeCun教授的官網(wǎng)下載,下載完成之后修改一下我們讀取數(shù)據(jù)的代碼,加上我們下載的路徑即可

from tensorflow.examples.tutorials.mnist import input_data
import os

data_path = os.path.join('.', 'temp', 'data')
mnist = input_data.read_data_sets(datapath)
X = mnist.test.images.reshape(-1, n_steps, n_inputs)
y = mnist.test.labels

測試一下

成功!

補充知識:在tensorflow的使用中,from tensorflow.examples.tutorials.mnist import input_data報錯

最近在學習使用python的tensorflow的使用,使用編輯器為spyder,在輸入以下代碼時會報錯:

from tensorflow.examples.tutorials.mnist import input_data

報錯內(nèi)容如下:

from tensorflow.python.autograph.lang.special_functions import stack
ImportError: cannot import name 'stack'

為了解決這個問題,在

File "K:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\autograph_init_.py"文件中直接把
from tensorflow.python.autograph.lang.special_functions import stack

這一行注釋掉了,問題并沒有解決。然后又把下面一行注釋掉了:

from tensorflow.python.autograph.lang.special_functions import tensor_list

問題解決,但報了一大頓warning:

WARNING:tensorflow:From C:/Users/phmnku/.spyder-py3/tensorflow_prac/classification.py:4: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From K:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Please write your own downloading logic.
WARNING:tensorflow:From K:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting MNIST_data\train-images-idx3-ubyte.gz
WARNING:tensorflow:From K:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:267: extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting MNIST_data\train-labels-idx1-ubyte.gz
WARNING:tensorflow:From K:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:110: dense_to_one_hot (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.one_hot on tensors.
Extracting MNIST_data\t10k-images-idx3-ubyte.gz
Extracting MNIST_data\t10k-labels-idx1-ubyte.gz
WARNING:tensorflow:From K:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:290: DataSet.__init__ (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From K:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\tf_should_use.py:189: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use `tf.global_variables_initializer` instead.

但是程序好歹能用了

以上這篇基于Tensorflow讀取MNIST數(shù)據(jù)集時網(wǎng)絡(luò)超時的解決方式就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • python遍歷文件夾的各種方法大全

    python遍歷文件夾的各種方法大全

    在Python中,可以使用多種方法來多次遍歷文件,下面這篇文章主要給大家介紹了關(guān)于python遍歷文件夾的各種方法,文中通過代碼介紹的非常詳細,需要的朋友可以參考下
    2024-03-03
  • python 繪制正態(tài)曲線的示例

    python 繪制正態(tài)曲線的示例

    這篇文章主要介紹了python 繪制正態(tài)曲線的示例,幫助大家更好的利用python繪制圖像,感興趣的朋友可以了解下
    2020-09-09
  • 使用python編寫udp協(xié)議的ping程序方法

    使用python編寫udp協(xié)議的ping程序方法

    下面小編就為大家分享一篇使用python編寫udp協(xié)議的ping程序方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-04-04
  • opencv實現(xiàn)答題卡識別

    opencv實現(xiàn)答題卡識別

    這篇文章主要為大家詳細介紹了opencv實現(xiàn)答題卡識別,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • Python讀取二進制文件代碼方法解析

    Python讀取二進制文件代碼方法解析

    這篇文章主要介紹了Python讀取二進制文件代碼方法解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-06-06
  • python將YUV420P文件轉(zhuǎn)PNG圖片格式的兩種方法

    python將YUV420P文件轉(zhuǎn)PNG圖片格式的兩種方法

    這篇文章主要介紹了python將YUV420P文件轉(zhuǎn)PNG圖片格式的兩種方法,幫助大家更好的理解和使用python,感興趣的朋友可以了解下
    2021-01-01
  • Python爬蟲與反爬蟲大戰(zhàn)

    Python爬蟲與反爬蟲大戰(zhàn)

    這篇文章主要介紹了Python爬蟲與反爬蟲的相關(guān)資料,文中講解非常細致,幫助大家更好的理解Python爬蟲與反爬蟲的關(guān)系,感興趣的朋友可以了解下
    2020-07-07
  • 使用Python編寫提取日志中的中文的腳本的方法

    使用Python編寫提取日志中的中文的腳本的方法

    這篇文章主要介紹了使用Python編寫提取日志中的中文的腳本的方法,該腳本包括過濾重復(fù)的字符行等功能,需要的朋友可以參考下
    2015-04-04
  • 在Python中使用lambda高效操作列表的教程

    在Python中使用lambda高效操作列表的教程

    這篇文章主要介紹了在Python中使用lambda高效操作列表的教程,結(jié)合了包括map、filter、reduce、sorted等函數(shù),需要的朋友可以參考下
    2015-04-04
  • 詳解python中靜態(tài)方法staticmethod用法

    詳解python中靜態(tài)方法staticmethod用法

    本文主要介紹了python中靜態(tài)方法staticmethod用法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-07-07

最新評論

莎车县| 芷江| 孟津县| 青浦区| 明星| 武功县| 丹巴县| 门头沟区| 阳新县| 抚松县| 青海省| 尉氏县| 新丰县| 于田县| 汝阳县| 和平县| 巍山| 奇台县| 通河县| 兴化市| 乾安县| 仙居县| 山阴县| 肇州县| 邛崃市| 大渡口区| 阿鲁科尔沁旗| 济南市| 黄陵县| 清水河县| 嘉定区| 蛟河市| 宜川县| 崇信县| 黑山县| 临潭县| 湖北省| 威宁| 余江县| 元江| 张家界市|