Closed brisker closed 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.
@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?
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.
@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.
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.
Actually, you can open a new issue to facilitate our people to check the issues. Thanks!
@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.
@wentaozhu Hi, I got the code running successfully, and I am a little confused about the crfasrnn training process:
tf.Variable(tf.random_normal([2,1]
(I was trying to understand the crfasrnn model by reading your code)
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.
@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?
Please see CRFasRNN paper for details. The dimension of weights depends on the used features.
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..