wentaozhu / adversarial-deep-structural-networks

ISBI2018: Adversarial Deep Structural Networks for Mammographic Mass Segmentation https://arxiv.org/abs/1612.05970
Apache License 2.0
51 stars 25 forks source link

error running code #1

Closed brisker closed 7 years ago

brisker commented 7 years ago

Is the crf-rnn in your paper identical to the crfasrnn model? If yes, I am a little confused about your implementation. Where is the crf-rnn layer forward computation actually? Because the code seems a little disordered to me..

wentaozhu commented 7 years ago

Yes. It is in the utils.py def crfrnn(ux, wsmooth, wcontra, k1, k2, trainiter=5, testiter=10, wunary=None): I am very sorry for the disorder.

brisker commented 7 years ago

@wentaozhu Since tensorflow has autograd functions, so in your code there are no backprop or gradients computation implementations for the crf-rnn layer? (I am not familiar with tensorflow) If there are, where are they?

wentaozhu commented 7 years ago

We do not need to write the back propagation or gradient computation function explicitly. It will calculate the gradients and do the bp automatically. The only thing we need to do is to design a calculation graph (forward pass).

Some gradients related functions in the tensorflow/theano is useful for the adversarial based models.

brisker commented 7 years ago

@wentaozhu I tried to set the model as 'crf' to get crf-rnn mode, and run crfcnn_combine.py, but got this error: (I use the inbreastmassseg dataset). I just installed tensorflow 1.0.0-rc2.

jcc@jcc:~/research/tensorflow_crfrnn$ python crfcnn_combine.py

0.00350000.12lrfsave5crfnormvalpara335

Traceback (most recent call last):
  File "crfcnn_combine.py", line 68, in <module>
    trainenergy, accuracy, di, testenergy, qtest = model(X, Y, k1, k2, paras)
  File "/home/jcc/research/tensorflow_crfrnn/utils_combine.py", line 281, in model
    yonehot = tf.concat(3, [1-yreshape, yreshape])
  File "/home/jcc/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1029, in concat
    dtype=dtypes.int32).get_shape(
  File "/home/jcc/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 637, in convert_to_tensor
    as_ref=False)
  File "/home/jcc/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 702, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/jcc/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 111, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/home/jcc/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 100, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/home/jcc/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 370, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/home/jcc/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.
wentaozhu commented 7 years ago

I am very sorry. I think you installed tensorflow version 1. Please try to install tensorflow version 0.12.1. The bug is the tensorflow version incompatible.

wentaozhu commented 7 years ago

Actually, you can open a new issue to facilitate our people to check the issues. Thanks!

wentaozhu commented 7 years ago

@wentaozhu still error when I create use tensorflor-0.12.1: (tensorflow-0.12.1) jcc@jcc:~/research/tensorflow_crfrnn$ python crfcnn_combine.py 0.00350000.12lrfsave5crfnormvalpara335

Traceback (most recent call last): File "crfcnn_combine.py", line 68, in trainenergy, accuracy, di, testenergy, qtest = model(X, Y, k1, k2, paras) File "/home/jcc/research/tensorflow_crfrnn/utils_combine.py", line 281, in model yonehot = tf.concat(axis=3, values=[1-yreshape, yreshape]) TypeError: concat() got an unexpected keyword argument 'axis'

You should check the tensorflow api python function.

brisker commented 7 years ago

@wentaozhu Hi, I got the code running successfully, and I am a little confused about the crfasrnn training process:

  1. are all the learnable parameters corresponding to the crfrnn layer just wsmooth and wcontra? just 2*1 matrix?
  2. If not, is the crfrnn layer just doing a filter work, and without any learnable parameters?
  3. Does wsmooth represent smooth kernel and wcontra represent apperance kernel? If yes, where was the difference between the two kernels reflected in the code? (given that they are both intialized as: tf.Variable(tf.random_normal([2,1]

(I was trying to understand the crfasrnn model by reading your code)

wentaozhu commented 7 years ago

Yes. The dimensions of features used in the CRF is small. Initialization is ok. We usually initialize the parameters by random. Then we use the learning algorithms to update them. The final parameters is not the initialization.

brisker commented 7 years ago

@wentaozhu So actually crf only learns about just some 2*1 matrix ? So few information, how could that be a help for the refinement of segmentation?

wentaozhu commented 7 years ago

Please see CRFasRNN paper for details. The dimension of weights depends on the used features.