Chapter 12 Losses and Metrics Based on Model Internals error trying to fit the model
- Dominant language
- Jupyter Notebook
- Stars
- 30k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
When I try to execute model.fit I receive the following error:
```stacktrace
InaccessibleTensorError Traceback (most recent call last)
in ()
1 model = ReconstructingRegressor(1)
2 model.compile(loss="mse", optimizer="nadam")
----> 3 history = model.fit(X_train_scaled, y_train, epochs=2)
4 y_pred = model.predict(X_test_scaled)
10 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
966 except Exception as e: # pylint:disable=broad-except
967 if hasattr(e, "ag_error_metadata"):
--> 968 raise e.ag_error_metadata.to_exception(e)
969 else:
970 raise
InaccessibleTensorError: in user code:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:571 train_function *
outputs = self.distribute_strategy.run(
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:951 run **
return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2290 call_for_each_replica
return self._call_for_each_replica(fn, args, kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2649 _call_for_each_replica
return fn(*args, **kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:533 train_step **
y, y_pred, sample_weight, regularization_losses=self.losses)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/compile_utils.py:227 __call__
reg_loss = math_ops.add_n(regularization_losses)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py:180 wrapper
return target(*args, **kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3239 add_n
return gen_math_ops.add_n(inputs, name=name)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_math_ops.py:420 add_n
"AddN", inputs=inputs, name=name)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:744 _apply_op_helper
attrs=attr_protos, op_def=op_def)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py:591 _create_op_internal
inp = self.capture(inp)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py:641 capture
% (tensor, tensor.graph, self))
InaccessibleTensorError: The tensor 'Tensor("mul:0", shape=(), dtype=float32)' cannot be accessed here: it is defined in another function or code block. Use return values, explicit Python locals or TensorFlow collections to access it. Defined in: FuncGraph(name=build_graph, id=140080628583112); accessed from: FuncGraph(name=train_function, id=140080628733320).
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.