这部分教程直接给出了源码,以为会很快的跑起来,没想到遇到了许多问题。
第一个错误:
直接运行给出的实例代码
fully_connected_feed.py
NotFoundError: Failed to create a directory: /tmp\tensorflow; No such file or directory
解决方法:这个是找不到文件,无法创建字典。修改代码中的地址:将下面的红色部分的地址前面加/,或者改为你自己代码位置的地址
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] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。>
这个问题是无法访问网址,从而无法获取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.
# ==============================================================================
"""Trains and Evaluates the MNIST network using a feed dictionary."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# pylint: disable=missing-docstring
import argparse
import os
import sys
import time
from six.moves import xrange # pylint: disable=redefined-builtin
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
from tensorflow.examples.tutorials.mnist import mnist
# Basic model parameters as external flags.
FLAGS = None
def placeholder_inputs(batch_size):
"""Generate placeholder variables

这篇学习笔记详细记录了作者在尝试运行TensorFlow源码时遇到的问题及解决过程,对于初学者来说是一份宝贵的实战经验。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



