DNNアイリス例を実行:完全性についてはhttps://www.tensorflow.org/versions/r0.10/tutorials/tflearn/index.htmlTensorFlow:私はここで見つける公式TensorFlowのウェブサイト上で提供されている例を実行しようとしています
を、私が実行している問題のコードは以下の通りです:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
import numpy as np
# Data sets
IRIS_TRAINING = "iris_training.csv"
IRIS_TEST = "iris_test.csv"
# Load datasets.
training_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TRAINING,
target_dtype=np.int)
test_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TEST,
target_dtype=np.int)
# Build 3 layer DNN with 10, 20, 10 units respectively.
classifier = tf.contrib.learn.DNNClassifier(hidden_units=[10, 20, 10],
n_classes=3,
model_dir="/tmp/iris_model")
# Fit model.
classifier.fit(x=training_set.data,
y=training_set.target,
steps=2000)
# Evaluate accuracy.
accuracy_score = classifier.evaluate(x=test_set.data,
y=test_set.target)["accuracy"]
print('Accuracy: {0:f}'.format(accuracy_score))
# Classify two new flower samples.
new_samples = np.array(
[[6.4, 3.2, 4.5, 1.5], [5.8, 3.1, 5.0, 1.7]], dtype=float)
y = classifier.predict(new_samples)
print('Predictions: {}'.format(str(y)))
しかし、私は「hidden_units」を変更した場合、変数への
WARNING:tensorflow:Change warning: `feature_columns` will be required after 2016-08-01.
Instructions for updating:
Pass `tf.contrib.learn.infer_real_valued_columns_from_input(x)` or `tf.contrib.learn.infer_real_valued_columns_from_input_fn(input_fn)` as `feature_columns`, where `x` or `input_fn` is your argument to `fit`, `evaluate`, or `predict`.
WARNING:tensorflow:Setting feature info to TensorSignature(dtype=tf.float32, shape=TensorShape([Dimension(None), Dimension(4)]), is_sparse=False)
WARNING:tensorflow:Setting targets info to TensorSignature(dtype=tf.int64, shape=TensorShape([Dimension(None)]), is_sparse=False)
E tensorflow/core/client/tensor_c_api.cc:485] Tensor name "hiddenlayer_2/weights/Adagrad" not found in checkpoint files /tmp/iris_model/model.ckpt-16000-?????-of-00001
[[Node: save/restore_slice_18 = RestoreSlice[dt=DT_FLOAT, preferred_shard=0, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/restore_slice_18/tensor_name, save/restore_slice_18/shape_and_slice)]]
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 730, in _do_call
return fn(*args)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 712, in _run_fn
status, run_metadata)
File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__
next(self.gen)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors.py", line 450, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors.NotFoundError: Tensor name "hiddenlayer_2/weights/Adagrad" not found in checkpoint files /tmp/iris_model/model.ckpt-16000-?????-of-00001
[[Node: save/restore_slice_18 = RestoreSlice[dt=DT_FLOAT, preferred_shard=0, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/restore_slice_18/tensor_name, save/restore_slice_18/shape_and_slice)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 26, in <module>
steps=2000)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 240, in fit
max_steps=max_steps)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 578, in _train_model
max_steps=max_steps)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/graph_actions.py", line 276, in _supervised_train
scaffold=scaffold) as super_sess:
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/supervised_session.py", line 212, in __init__
self._sess = recoverable_session.RecoverableSession(self._create_session)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/recoverable_session.py", line 46, in __init__
WrappedSession.__init__(self, sess_factory())
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/supervised_session.py", line 232, in _create_session
init_fn=self._scaffold.init_fn)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/session_manager.py", line 164, in prepare_session
max_wait_secs=max_wait_secs, config=config)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/session_manager.py", line 224, in recover_session
saver.restore(sess, ckpt.model_checkpoint_path)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py", line 1129, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 382, in run
run_metadata_ptr)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 655, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 723, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 743, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.NotFoundError: Tensor name "hiddenlayer_2/weights/Adagrad" not found in checkpoint files /tmp/iris_model/model.ckpt-16000-?????-of-00001
[[Node: save/restore_slice_18 = RestoreSlice[dt=DT_FLOAT, preferred_shard=0, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save/Const_0, save/restore_slice_18/tensor_name, save/restore_slice_18/shape_and_slice)]]
Caused by op 'save/restore_slice_18', defined at:
File "test.py", line 26, in <module>
steps=2000)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 240, in fit
max_steps=max_steps)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 578, in _train_model
max_steps=max_steps)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/graph_actions.py", line 252, in _supervised_train
keep_checkpoint_max=keep_checkpoint_max)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/supervised_session.py", line 152, in __init__
lambda: training_saver.Saver(sharded=True,
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/supervised_session.py", line 164, in _get_or_default
op = default_constructor()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/supervised_session.py", line 153, in <lambda>
max_to_keep=keep_checkpoint_max))
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py", line 861, in __init__
restore_sequentially=restore_sequentially)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py", line 515, in build
filename_tensor, per_device, restore_sequentially, reshape)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py", line 312, in _AddShardedRestoreOps
name="restore_shard"))
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py", line 272, in _AddRestoreOps
values = self.restore_op(filename_tensor, vs, preferred_shard)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/training/saver.py", line 187, in restore_op
preferred_shard=preferred_shard)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/io_ops.py", line 203, in _restore_slice
preferred_shard, name=name)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gen_io_ops.py", line 359, in _restore_slice
preferred_shard=preferred_shard, name=name)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op
op_def=op_def)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 2310, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1232, in __init__
self._traceback = _extract_stack()
:
は今、私がこの例を実行すると、私は次のようなエラーに遭遇していそうです0xの代わりに[10]
を実行すると、コードは実行されます(警告は表示されますが、エラーは発生しません)。
このネットワークに他のレイヤを追加すると、エラーが発生することはありますか?どんな入力であれ、助けになるでしょう、ありがとう!
ああ、それは私の答えを説明しています。ありがとう、私はあなたを受け入れるよ。 –