这部分教程直接给出了源码,以为会很快的跑起来,没想到遇到了许多问题。
第一个错误:
直接运行给出的实例代码
fully_connected_feed.py
NotFoundError: Failed to create a directory: /tmp\tensorflow; No such file or directory
![](https://i-blog.csdnimg.cn/blog_migrate/665a72129d0bad86ed92c25bd33657d0.png)
解决方法:这个是找不到文件,无法创建字典。修改代码中的地址:将下面的红色部分的地址前面加/,或者改为你自己代码位置的地址
parser.add_argument(
'--input_data_dir',
type=str,
default=os.path.join(os.getenv('TEST_TMPDIR', '/tmp'),
' tensorflow/mnist/input_data'),
help='Directory to put the input data.'
)
parser.add_argument(
'--log_dir',
type=str,
default=os.path.join(os.getenv('TEST_TMPDIR', '/tmp'),
' tensorflow/mnist/logs/fully_connected_feed'),
help='Directory to put the log data.'
)
'--input_data_dir',
type=str,
default=os.path.join(os.getenv('TEST_TMPDIR', '/tmp'),
' tensorflow/mnist/input_data'),
help='Directory to put the input data.'
)
parser.add_argument(
'--log_dir',
type=str,
default=os.path.join(os.getenv('TEST_TMPDIR', '/tmp'),
' tensorflow/mnist/logs/fully_connected_feed'),
help='Directory to put the log data.'
)
第二个错误:
URLError: <urlopen error [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。>
![](https://i-blog.csdnimg.cn/blog_migrate/3347673ac765a0cf7958a38eeae5cb56.png)
这个问题是无法访问网址,从而无法获取MINST的数据集
解决办法:下载下MINST数据集,复制到上面的input_data文件夹中
MINST数据集:http://yann.lecun.com/exdb/mnist/
三、代码 full_connected_feed.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================