Home>
The person who has just started to be interested in programming recently.
So it may be difficult to read the program code, but it would be helpful if you could answer. .
I am trying to recognize handwritten numbers using a web camera.
When trying to create a learning model using MNIST,
TimeoutError: [WinError 10060] The connection could not be established because the connected callee did not respond correctly after a certain period of time. Or the established connection failed because the connected host did not respond.
and an error message like this were displayed.
Error messageStart
C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ site-packages \ sklearn \ utils \ deprecation.py: 85: DeprecationWarning: Function fetch_mldata is deprecated;fetch_mldata was deprecated in version 0.20 and will be removed in version 0.22. Please use fetch_openml.
warnings.warn (msg, category = DeprecationWarning)
C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ site-packages \ sklearn \ utils \ deprecation.py: 85: DeprecationWarning: Function mldata_filename is deprecated;mldata_filename was deprecated in version 0.20 and will be removed in version 0.22. Please use fetch_openml.
warnings.warn (msg, category = DeprecationWarning)
Traceback (most recent call last):
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ urllib \ request.py", line 1318, in do_open
encode_chunked = req.has_header ('Transfer-encoding'))
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ http \ client.py", line 1239, in request
self._send_request (method, url, body, headers, encode_chunked)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ http \ client.py", line 1285, in _send_request
self.endheaders (body, encode_chunked = encode_chunked)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ http \ client.py", line 1234, in endheaders
self._send_output (message_body, encode_chunked = encode_chunked)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ http \ client.py", line 1026, in _send_output
self.send (msg)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ http \ client.py", line 964, in send
self.connect ()
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ http \ client.py", line 936, in connect
(self.host, self.port), self.timeout, self.source_address)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ socket.py", line 724, in create_connection
raise err
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ socket.py", line 713, in create_connection
sock.connect (sa)
TimeoutError: [WinError 10060] The connection could not be established because the connected callee did not respond correctly after a certain period of time. Or the established connection failed because the connected host did not respond.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):File "make_model.py", line 26, in<module>
mnist = fetch_mldata ("MNIST original", data_home = ".")
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ site-packages \ sklearn \ utils \ deprecation.py", line 86, in wrapped
return fun (* args, ** kwargs)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ site-packages \ sklearn \ datasets \ mldata.py", line 126, in fetch_mldata
mldata_url = urlopen (urlname)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ urllib \ request.py", line 223, in urlopen
return opener.open (url, data, timeout)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ urllib \ request.py", line 526, in open
response = self._open (req, data)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ urllib \ request.py", line 544, in _open
'_open', req)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ urllib \ request.py", line 504, in _call_chain
result = func (* args)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ urllib \ request.py", line 1346, in http_open
return self.do_open (http.client.HTTPConnection, req)
File "C: \ Users \ Taisei \ Anaconda3 \ envs \ opencv \ lib \ urllib \ request.py", line 1320, in do_open
raise URLError (err)
urllib.error.URLError:<urlopen error [WinError 10060] The connection could not be made because the connected callee did not respond correctly after a certain period of time. Or the established connection failed because the connected host did not respond. >
Applicable source code
import numpy as np
from chainer import Variable, optimizers, serializers
from chainer import Chain
import chainer.functions as F
import chainer.links as L
from sklearn.datasets import fetch_mldata
class MyMLP (Chain):
def __init __ (self, n_in = 784, n_units = 100, n_out = 10):
super (MyMLP, self) .__ init __ (
l1 = L.Linear (n_in, n_units),
l2 = L.Linear (n_units, n_units),
l3 = L.Linear (n_units, n_out),
)
def __call __ (self, x):
h1 = F.relu (self.l1 (x))h2 = F.relu (self.l2 (h1))
y = self.l3 (h2)
return y
#Indicates that the program has started (because it takes time to download MNIST).
print ('Start')
mnist = fetch_mldata ("MNIST original", data_home = ".")
x_all = mnist ['data']. astype (np.float32)/255
y_all = mnist ['target']. astype (np.int32)
model = MyMLP ()
optimizer = optimizers.SGD ()
optimizer.setup (model)
BATCHSIZE = 100
DATASIZE = 70000
for epoch in range (20):
print ('epoch% d'% epoch)
indexes = np.random.permutation (DATASIZE)
for i in range (0, DATASIZE, BATCHSIZE):
x = Variable (x_all [indexes [i: i + BATCHSIZE]])
t = Variable (y_all [indexes [i: i + BATCHSIZE]])
model.zerograds ()
y = model (x)
loss = F.softmax_cross_entropy (y, t)
loss.backward ()
optimizer.update ()
serializers.save_npz ("mymodel.npz", model)
#Indicates that the program is finished.
print ('Finish')
Check that there is no problem with the network connection.
Supplemental information (FW/tool version etc.)I use Python (3.6.8) with Anaconda.
The code is written in Spyder (3.3.6).
Chainer is already installed.
-
Answer # 1
Related articles
- python - about deep learning programs using keras
- python - fine chew using a trained model of your own dataset
- i don't understand the exercises using python trigonometric functions
- i want to adjust the execution result using the while statement in python as expected
- python - i want to separate by a specific word using the split function
- python - image recognition using cnn keras multiple inputs
- python - reinforcement learning of tag does not go well with open ai gym
- about batch change of file name using python
- python 3x - i want to get the nth array with an argument using python3 argparse
- python 3x - how to rename a folder created using jupyternotebook
- python 3x - processing to jump to the link destination using chrome driver in python
- creating a two-dimensional array using malloc in c language
- python - error in image binarization using cv2adaptivethreshold function
- python - aggregation processing using pandas
- python - i want to put the image file path in a variable and open it using that variable
- parallel processing using python multiprocessingpool and multiprocessingqueue does not work well
- specifying the range of the graph using python date
- python - about the fibonacci sequence using recursion
- python - abnormal termination in machine learning using jupyter notebook
- about data acquisition using python from becoming a novelist
Related questions
- How do I correctly fix broken /stopped working Python modules?
- python : I get an Attribute Error with cx_Freeze. : Module'setuptools._distutils.command' has no attribute'install'
- python : How do I do a rough text check?
- I want to convert a Python script to app /exe format.
- The console fails to log out to the installed python, python is output from the anaconda environment
- python : Separating point boundaries in matplotlib
I have never encountered this error myself, but it appears that a similar error has been reported.
https://github.com/YutaroOgawa/Deep-Reinforcement-Learning-Book/issues/4
https://webbibouroku.com/Blog/Article/fetch-mldata-error
To summarize the cause,
fetch_mldatadownloads data from the server, but it seems that the server is down.
For detailed solution, please refer to the above URL, but you can download MNIST data from another server.