shenweichen / GraphNeuralNetwork

Implementation and experiments of graph neural netwokrs, like gcn,graphsage,gat,etc.
MIT License
793 stars 182 forks source link

gcn.py 报错。 #2

Closed tide1994cc closed 2 years ago

tide1994cc commented 5 years ago

TypeError: in converted code:

/home/jupyter-tide1994/tide/embedding/GraphNeuralNetwork-master/gnn/gcn.py:73 call *

TypeError: Input 'pred' of 'Switch' Op has type float32 that does not match expected type of bool.

def call(self, inputs, training=None, **kwargs): features, A = inputs features = self.dropout(features, training=training) output = tf.matmul(tf.sparse_tensor_dense_matmul(A, features), self.kernel) if self.bias: output += self.bias act = self.activation(output)

    act._uses_learning_phase = features._uses_learning_phase
    return act
shenweichen commented 5 years ago

在tf1.4下运行试试

tide1994cc commented 5 years ago

还是 不行。。。

Youskrpig commented 5 years ago

if self.bias 后面加上 is not None

shazhongcheng commented 4 years ago

if self.bias 后面加上 is not None

I think it should change self.bias to self.use_bias and remove act._uses_learning_phase = features._uses_learning_phase

And then , i meet error ValueError: setting an array element with a sequence. And don't how to deal with it. I only run success in run_gat_cora.py I also meet error Unsupported feed type in run_graphsage_cora And don't know how to deal with it.

I see the code in book is pytorch, but why on the github, it turns out TensorFlow??

shazhongcheng commented 4 years ago

好吧 大家都是中国人,作者是不是不打算回应后续问题了呢? 跪求作者解惑!

shazhongcheng commented 4 years ago

书上代码是pytorch版的,而且看起来更加易懂,为什么要改成不好debug的TensorFlow版的呢?而且在更改过程中,好像还因此出现了问题,作者确定可以运行成功吗? 跪求作者大大解惑!

Billy1900 commented 4 years ago

if self.bias 后面加上 is not None

I think it should change self.bias to self.use_bias and remove act._uses_learning_phase = features._uses_learning_phase

And then , i meet error ValueError: setting an array element with a sequence. And don't how to deal with it. I only run success in run_gat_cora.py I also meet error Unsupported feed type in run_graphsage_cora And don't know how to deal with it.

I see the code in book is pytorch, but why on the github, it turns out TensorFlow??

I can run the run_graphsage_cora and run_gat_cora.py with the implementation of tf 1.14.0 but I also met the error in run_gcn_cora.py, the info is following:

Traceback (most recent call last):
  File "run_gcn_cora.py", line 32, in 
    feature_less=FEATURE_LESS, )
  File "/root/Lnq/GraphNeuralNetwork/gnn/gcn.py", line 113, in GCN
    h = GraphConvolution(n_hidden, activation=activation, dropout_rate=dropout_rate, l2_reg=l2_reg)([h,Adj])
  File "/usr/local/miniconda3/envs/tf14/lib/python3.5/site-packages/tensorflow/python/keras/engine/base_layer.py", line 634, in __call__
    outputs = call_fn(inputs, *args, **kwargs)
  File "/usr/local/miniconda3/envs/tf14/lib/python3.5/site-packages/tensorflow/python/autograph/impl/api.py", line 149, in wrapper
    raise e.ag_error_metadata.to_exception(type(e))
TypeError: in converted code:

    /root/Lnq/GraphNeuralNetwork/gnn/gcn.py:74 call
        if self.bias:
    /usr/local/miniconda3/envs/tf14/lib/python3.5/site-packages/tensorflow/python/ops/resource_variable_ops.py:777 __bool__
        return bool(self.read_value())
    /usr/local/miniconda3/envs/tf14/lib/python3.5/site-packages/tensorflow/python/framework/ops.py:690 __bool__
        raise TypeError("Using a `tf.Tensor` as a Python `bool` is not allowed. "

I notice maybe there are errors about the number of parameters in function GCN, but I don't know how to deal with it.

lishuaibeijing0689 commented 4 years ago

gcn.py : [Line 72]output = tf.matmul(tf.matmul(A, features), self.kernel) # fix by ls [Line 73] if self.use_bias: # fix by ls [Line 95] Adj = Input(shape=(adj_dim,)) # fix by ls

I fix the bug ValueError: setting an array element with a sequence. like this. @shazhongcheng