autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.62k stars 270 forks source link

AttributeError: module 'tensorflow._api.v1.summary' has no attribute 'create_file_writer' #404

Closed mtwenzel closed 4 years ago

mtwenzel commented 4 years ago

Thank you very much for reporting a bug on Talos. Before you do, please go through the below checklist carefully and make sure to prepare your bug report in a way that facilitates effective handling of the matter.

1) Confirm the below

2) Include the output of:

talos.__version__ 0.6.3

3) Explain clearly what you expect to happen

Tune one hyperparameter.

4) Explain what actually happened

Error:

AttributeError                            Traceback (most recent call last)
<ipython-input-21-ea93cf9be25f> in <module>()
----> 1 h = talos.Scan(train_images.astype(np.float32), train_labels, p, demo_model, 'patchsize')

7 frames
/usr/local/lib/python3.6/dist-packages/talos/scan/Scan.py in __init__(self, x, y, params, model, experiment_name, x_val, y_val, val_split, random_method, seed, performance_target, fraction_limit, round_limit, time_limit, boolean_limit, reduction_method, reduction_interval, reduction_window, reduction_threshold, reduction_metric, minimize_loss, disable_progress_bar, print_params, clear_session, save_weights)
    194         # input parameters section ends
    195 
--> 196         self._runtime()
    197 
    198     def _runtime(self):

/usr/local/lib/python3.6/dist-packages/talos/scan/Scan.py in _runtime(self)
    199 
    200         from .scan_run import scan_run
--> 201         self = scan_run(self)

/usr/local/lib/python3.6/dist-packages/talos/scan/scan_run.py in scan_run(self)
     24         # otherwise proceed with next permutation
     25         from .scan_round import scan_round
---> 26         self = scan_round(self)
     27         self.pbar.update(1)
     28 

/usr/local/lib/python3.6/dist-packages/talos/scan/scan_round.py in scan_round(self)
     17     # fit the model
     18     from ..model.ingest_model import ingest_model
---> 19     self.model_history, self.round_model = ingest_model(self)
     20     self.round_history.append(self.model_history.history)
     21 

/usr/local/lib/python3.6/dist-packages/talos/model/ingest_model.py in ingest_model(self)
      8                       self.x_val,
      9                       self.y_val,
---> 10                       self.round_params)

<ipython-input-19-b08f1577d5b4> in demo_model(x_train, y_train, x_val, y_val, params)
     74   # class_index value should match the validation_data selected above
     75   callbacks = [
---> 76       tf_explain.callbacks.GradCAMCallback(validation_class_three, 'target_layer', class_index=3, output_dir='logs/GradCam/class3expl3'),
     77       tf_explain.callbacks.GradCAMCallback(validation_class_three, 'target_layer', class_index=9, output_dir='logs/GradCam/class3expl9'),
     78       tf_explain.callbacks.GradCAMCallback(validation_class_nine, 'target_layer', class_index=3, output_dir='logs/GradCam/class9expl3'),

/usr/local/lib/python3.6/dist-packages/tf_explain/callbacks/grad_cam.py in __init__(self, validation_data, layer_name, class_index, output_dir)
     42         Path.mkdir(Path(self.output_dir), parents=True, exist_ok=True)
     43 
---> 44         self.file_writer = tf.summary.create_file_writer(str(self.output_dir))
     45 
     46     def on_epoch_end(self, epoch, logs=None):

/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation_wrapper.py in __getattr__(self, name)
    104     if name.startswith('_dw_'):
    105       raise AttributeError('Accessing local variables before they are created.')
--> 106     attr = getattr(self._dw_wrapped_module, name)
    107     if (self._dw_warning_count < _PER_MODULE_WARNING_LIMIT and
    108         name not in self._dw_deprecated_printed):

AttributeError: module 'tensorflow._api.v1.summary' has no attribute 'create_file_writer'

5) Provide a code-complete reference

Don't think it will help. Error is supposedly related to version incompatibility, as all code runs fine without talos.

github-actions[bot] commented 4 years ago

Welcome to Talos community! Thanks so much for creating your first issue :)

mtwenzel commented 4 years ago

Solved. TF 2.0.0 rc0 works. My notebook didn't use it, though, which I didn't notice.

mysteryt1 commented 3 years ago

hey i have a same problem. did you solve it?