palash1992 / GEM

BSD 3-Clause "New" or "Revised" License
1.27k stars 360 forks source link

SDNE implementation error #94

Open isikcakmak opened 4 years ago

isikcakmak commented 4 years ago

Dear authors, I have issues using your implementation of sdne algorithm. when I run "!pip install git+https://github.com/palash1992/GEM.git, I get this ERROR: textgenrnn 1.4.1 has requirement keras>=2.1.5, but you'll have keras 2.0.2 which is incompatible.

I am using keras version 2.3.0-tf,tensorflow version=2.2.0-rc3,networkx=2.4 I tried to upgrade to the previous version of tensorflow. I tried "from tensorflow.python.keras import backend as k"

When I run embedding/sdne.py I get error: Using TensorFlow backend. Num nodes: 34, num edges: 77

AttributeError Traceback (most recent call last)

in () 36 t1 = time() 37 # Learn embedding - accepts a networkx graph or file with edge list ---> 38 Y, t = embedding.learn_embedding(graph=G, edge_f=None, is_weighted=True, no_python=True) 39 print (embedding._method_name+':\n\tTraining time: %f' % (time() - t1)) 40 # Evaluate on graph reconstruction 4 frames /usr/local/lib/python3.6/dist-packages/gem/embedding/sdne.py in learn_embedding(self, graph, edge_f, is_weighted, no_python) 89 self._K, self._n_units, 90 self._nu1, self._nu2, ---> 91 self._actfn) 92 self._decoder = get_decoder(self._node_num, self._d, 93 self._K, self._n_units, /usr/local/lib/python3.6/dist-packages/gem/embedding/sdne_utils.py in get_encoder(node_num, d, K, n_units, nu1, nu2, activation_fn) 63 def get_encoder(node_num, d, K, n_units, nu1, nu2, activation_fn): 64 # Input ---> 65 x = Input(shape=(node_num,)) 66 # Encoder layers 67 y = [None] * (K + 1) /usr/local/lib/python3.6/dist-packages/keras/engine/topology.py in Input(shape, batch_shape, name, dtype, sparse, tensor) 1386 name=name, dtype=dtype, 1387 sparse=sparse, -> 1388 input_tensor=tensor) 1389 # Return tensor including _keras_shape and _keras_history. 1390 # Note that in this case train_output and test_output are the same pointer. /usr/local/lib/python3.6/dist-packages/keras/engine/topology.py in __init__(self, input_shape, batch_size, batch_input_shape, dtype, input_tensor, sparse, name) 1251 if not name: 1252 prefix = 'input' -> 1253 name = prefix + '_' + str(K.get_uid(prefix)) 1254 super(InputLayer, self).__init__(dtype=dtype, name=name) 1255 /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in get_uid(prefix) 45 def get_uid(prefix=''): 46 global _GRAPH_UID_DICTS ---> 47 graph = tf.get_default_graph() 48 if graph not in _GRAPH_UID_DICTS: 49 _GRAPH_UID_DICTS[graph] = defaultdict(int) AttributeError: module 'tensorflow' has no attribute 'get_default_graph' Best regards, ışık
palash1992 commented 4 years ago

Please have a look here: https://github.com/keras-team/keras/issues/12379

isikcakmak commented 4 years ago

Hi,Palash Goyal; I looked keras-team/keras#12379 .I applied the solutions he said for the previous issue. but my problem was not solved. I took these error messages in SDNE implementation. I tried the things you suggested.

I didn’t solve my problems with 'from tensorflow.python.keras import backend' I tried all of them. image

I changed Tensorflow_version==1.13.1 and keras ==2.2.4 but I took this error .

image Keras==2.2.4 Tensorflow==1.13.1

image

juanpablo-munoz commented 3 years ago

You need to downgrade your tensorflow install to 1.xx. I installed 1.14 and it worked. You still need to force install keras==2.0.2 though.