Skip to content

AttributeError: module 'tensorflow' has no attribute 'placeholder' #134

@Diksha1312

Description

@Diksha1312

I'm using TF 2.0 version on Colab.

Below is the error I'm getting -

nonlinear_mxts_mode is set to: DeepLIFT_GenomicsDefault
/usr/local/lib/python3.7/dist-packages/deeplift/conversion/kerasapi_conversion.py:366: H5pyDeprecationWarning: The default file mode will change to 'r' (read-only) in h5py 3.0. To suppress this warning, pass the mode you need to h5py.File(), or set the global default h5.get_config().default_file_mode, or set the environment variable H5PY_DEFAULT_READONLY=1. Available modes are: 'r', 'r+', 'w', 'w-'/'x', 'a'. See the docs for details.
model_weights = h5py.File(h5_file)

AttributeError Traceback (most recent call last)
in
14 h5_file=keras_model_weights,
15 json_file=keras_model_json,
---> 16 nonlinear_mxts_mode=nonlinear_mxts_mode)

2 frames
/usr/local/lib/python3.7/dist-packages/deeplift/layers/core.py in init(self, batch_shape, **kwargs)
205 self._num_dims = len(batch_shape)
206 self._shape = batch_shape
--> 207 self.activation_vars = tf.placeholder(
208 dtype=tf.float32, shape=batch_shape,
209 name="inp
"+str(self.get_name()))

AttributeError: module 'tensorflow' has no attribute 'placeholder'

Below is the code I'm trying to execute -

from deeplift.layers import NonlinearMxtsMode
import deeplift.conversion.kerasapi_conversion as kc
from collections import OrderedDict

method_to_model = OrderedDict()
for method_name, nonlinear_mxts_mode in [
#The genomics default = rescale on conv layers, revealcance on fully-connected
('rescale_conv_revealcancel_fc', NonlinearMxtsMode.DeepLIFT_GenomicsDefault),
('rescale_all_layers', NonlinearMxtsMode.Rescale),
('revealcancel_all_layers', NonlinearMxtsMode.RevealCancel),
('grad_times_inp', NonlinearMxtsMode.Gradient),
('guided_backprop', NonlinearMxtsMode.GuidedBackprop)]:
method_to_model[method_name] = kc.convert_model_from_saved_files(
h5_file=keras_model_weights,
json_file=keras_model_json,
nonlinear_mxts_mode=nonlinear_mxts_mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions