# Buggy code
def _build(self):
    unconstrained = self._build_parameter()
    constrained = self._build_constrained(unconstrained)
    prior = self._build_prior(unconstrained, constrained)
    self._unconstrained_tensor = unconstrained  # pylint: disable=W0201
    self._constrained_tensor = constrained  # pylint: disable=W0201
    self._prior_tensor = prior  # pylint: disable=W0201


# Traceback (AttributeError)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-e3c07a8fceb7> in <module>()
10                                 np.random.randn(M, D),
11                                 minibatch_size=2)
---> 12 model.compute_log_likelihood()

/[...]/GPflow/gpflow/decors.py in runnable(obj, *args, **kwargs)
152                     _setup_storage(store, *af_args, **af_kwargs)
153                     _build_method(method, obj, store)
--> 154             return _session_run(session, obj, store, *args, **kwargs)
155         return runnable
156     return autoflow_wrapper

/[...]/GPflow/gpflow/decors.py in _session_run(session, obj, store, *args, **kwargs)
189         feed_dict.update(obj.feeds)
190     initialize = kwargs.pop('initialize', False)
--> 191     obj.initialize(session=session, force=initialize)
192     return session.run(store['result'], **kwargs)
193

/[...]/GPflow/gpflow/core/node.py in initialize(self, session, force)
82                 session=session,
83                 force=force,
---> 84                 feed_dict=self.initializable_feeds)
85
86     def clear(self):

/[...]/GPflow/gpflow/misc.py in initialize_variables(variables, session, force, **run_kwargs)
82             initializer = tf.variables_initializer(variables)
83         else:
---> 84             uninitialized = tf.report_uninitialized_variables(var_list=variables)
85             def uninitialized_names():
86                 for uv in session.run(uninitialized):

/[...]/anaconda3/envs/py35cpu/lib/python3.5/site-packages/tensorflow/python/util/tf_should_use.py in wrapped(*args, **kwargs)
105   """
106   def wrapped(*args, **kwargs):
--> 107     return _add_should_use_warning(fn(*args, **kwargs))
108   return tf_decorator.make_decorator(
109       fn, wrapped, 'should_use_result',

/[...]/anaconda3/envs/py35cpu/lib/python3.5/site-packages/tensorflow/python/ops/variables.py in report_uninitialized_variables(var_list, name)
1519         variables_mask = math_ops.logical_not(
1520             array_ops.stack(
-> 1521                 [state_ops.is_variable_initialized(v) for v in var_list]))
1522         # Get a 1-D string tensor containing all the variable names.
1523         variable_names_tensor = array_ops.constant(

/[...]/anaconda3/envs/py35cpu/lib/python3.5/site-packages/tensorflow/python/ops/variables.py in <listcomp>(.0)
1519         variables_mask = math_ops.logical_not(
1520             array_ops.stack(
-> 1521                 [state_ops.is_variable_initialized(v) for v in var_list]))
1522         # Get a 1-D string tensor containing all the variable names.
1523         variable_names_tensor = array_ops.constant(

/[...]/anaconda3/envs/py35cpu/lib/python3.5/site-packages/tensorflow/python/ops/state_ops.py in is_variable_initialized(ref, name)
182     A `Tensor` of type `bool`.
183   """
--> 184   if ref.dtype._is_ref_dtype:
185     return gen_state_ops.is_variable_initialized(ref=ref, name=name)
186   # Handle resource variables.

AttributeError: 'Iterator' object has no attribute 'dtype'

# Fixed code
def _build(self):
    unconstrained = self._build_parameter()
    constrained = self._build_constrained(unconstrained)
    prior = self._build_prior(unconstrained, constrained)

    self._is_initialized_tensor = tf.is_variable_initialized(unconstrained)
    self._unconstrained_tensor = unconstrained
    self._constrained_tensor = constrained
    self._prior_tensor = prior