Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Fetch argument None has invalid type <class 'NoneType'> #300

Open
rubbyaworka opened this issue Nov 19, 2020 · 1 comment
Open

Comments

@rubbyaworka
Copy link

python from __future__ import division, print_function %matplotlib inline import matplotlib.pyplot as plt import matplotlib import numpy as np plt.rcParams['image.cmap'] = 'gist_earth' np.random.seed(98765)
`python
from tf_unet import image_gen
from tf_unet import unet
from tf_unet import util

nx = 572
ny = 572

generator = image_gen.GrayScaleDataProvider(nx, ny, cnt=20)

x_test, y_test = generator(1)

fig, ax = plt.subplots(1,2, sharey=True, figsize=(8,4))
ax[0].imshow(x_test[0,...,0], aspect="auto")
ax[1].imshow(y_test[0,...,1], aspect="auto")

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

net = unet.Unet(channels=generator.channels, n_class=generator.n_class, layers=3, features_root=16)

trainer = unet.Trainer(net, optimizer="momentum", opt_kwargs=dict(momentum=0.2))

path = trainer.train(generator, "./unet_trained", training_iters=32, epochs=10, display_step=2)
`

the error of the path

TypeError Traceback (most recent call last)
in
----> 1 path = trainer.train(generator, "./unet_trained", training_iters=32, epochs=10, display_step=2)

~/.local/lib/python3.8/site-packages/tf_unet-0.1.2-py3.8.egg/tf_unet/unet.py in train(self, data_provider, output_path, training_iters, epochs, dropout, display_step, restore, write_graph, prediction_path)
447
448 if step % display_step == 0:
--> 449 self.output_minibatch_stats(sess, summary_writer, step, batch_x,
450 util.crop_to_shape(batch_y, pred_shape))
451

~/.local/lib/python3.8/site-packages/tf_unet-0.1.2-py3.8.egg/tf_unet/unet.py in output_minibatch_stats(self, sess, summary_writer, step, batch_x, batch_y)
486 def output_minibatch_stats(self, sess, summary_writer, step, batch_x, batch_y):
487 # Calculate batch loss and accuracy
--> 488 summary_str, loss, acc, predictions = sess.run([self.summary_op,
489 self.net.cost,
490 self.net.accuracy,

~/anaconda3/lib/python3.8/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
955
956 try:
--> 957 result = self._run(None, fetches, feed_dict, options_ptr,
958 run_metadata_ptr)
959 if run_metadata:

~/anaconda3/lib/python3.8/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1163
1164 # Create a fetch handler to take care of the structure of fetches.
-> 1165 fetch_handler = _FetchHandler(
1166 self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles)
1167

~/anaconda3/lib/python3.8/site-packages/tensorflow/python/client/session.py in init(self, graph, fetches, feeds, feed_handles)
475 """
476 with graph.as_default():
--> 477 self._fetch_mapper = _FetchMapper.for_fetch(fetches)
478 self._fetches = []
479 self._targets = []

~/anaconda3/lib/python3.8/site-packages/tensorflow/python/client/session.py in for_fetch(fetch)
264 elif isinstance(fetch, (list, tuple)):
265 # NOTE(touts): This is also the code path for namedtuples.
--> 266 return _ListFetchMapper(fetch)
267 elif isinstance(fetch, collections_abc.Mapping):
268 return _DictFetchMapper(fetch)

~/anaconda3/lib/python3.8/site-packages/tensorflow/python/client/session.py in init(self, fetches)
376 else:
377 self._fetch_type = type(fetches)
--> 378 self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in fetches]
379 self._unique_fetches, self._value_indices = _uniquify_fetches(self._mappers)
380

~/anaconda3/lib/python3.8/site-packages/tensorflow/python/client/session.py in (.0)
376 else:
377 self._fetch_type = type(fetches)
--> 378 self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in fetches]
379 self._unique_fetches, self._value_indices = _uniquify_fetches(self._mappers)
380

~/anaconda3/lib/python3.8/site-packages/tensorflow/python/client/session.py in for_fetch(fetch)
260 """
261 if fetch is None:
--> 262 raise TypeError('Fetch argument %r has invalid type %r' %
263 (fetch, type(fetch)))
264 elif isinstance(fetch, (list, tuple)):

TypeError: Fetch argument None has invalid type <class 'NoneType'>

@jakeret
Copy link
Owner

jakeret commented Nov 23, 2020

Hi @rubbyaworka this code hasn't been maintained for quite a while.
There is a Tensorflow 2.0 compatible reimplementation of tf_unet available here: https://github.com/jakeret/unet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants