js05212 / MXNet-for-CDL

Official MXNet code for 'Collaborative Deep Learning for Recommender Systems' - SIGKDD
http://wanghao.in/CDL.htm
53 stars 16 forks source link

After running " python cdl.py" I have this problem #3

Open daicoolb opened 7 years ago

daicoolb commented 7 years ago
            Hi,After running " python cdl.py" I have this problem:
            Traceback (most recent call last):
            File "cdl.py", line 61, in 
            lr_scheduler=mx.misc.FactorScheduler(20000,0.1))
            File "/home/daicoolb/MXNet-for-CDL/autoencoder.py", line 175, in finetune
            0, n_iter, {}, False)
            File "/home/daicoolb/MXNet-for-CDL/solver.py", line 84, in solve
            update_dict = {name: nd for name, nd in zip(sym.list_arguments(), exe.grad_a rrays) if nd}
            File "/home/daicoolb/MXNet-for-CDL/solver.py", line 84, in 
            update_dict = {name: nd for name, nd in zip(sym.list_arguments(), exe.grad_a rrays) if nd}
            File "/usr/local/lib/python2.7/dist-packages/mxnet/ndarray.py", line 238, in _ bool_
            raise ValueError("The truth value of an NDArray with more than one element i s ambiguous.")
            ValueError: The truth value of an NDArray with more than one element is ambiguou s.
nimit2894 commented 7 years ago

I am facing the same issue, and I would really appreciate the creator of this repo to respond to this, as it is quite hard to find out the source of this error from the huge ndarray.py file that has been created in mxnet

js05212 commented 7 years ago

Hi, sorry for the late reply. I think this is because you are using a newer version of MXNet. There might be some compatibility issue in here. Have you try using earlier version of MXNet?

xanhho commented 7 years ago

Hi, I also have the same error when I running cdl.py INFO:root:Fine tuning... Traceback (most recent call last): File "", line 4, in File "autoencoder.py", line 175, in finetune return U, V, theta, BCD_loss File "solver.py", line 84, in solve update_dict = {name: nd for name, nd in zip(sym.list_arguments(), exe.grad_arrays) if nd} File "solver.py", line 84, in update_dict = {name: nd for name, nd in zip(sym.list_arguments(), exe.grad_arrays) if nd} File "/home/xanhho/.local/lib/python2.7/site-packages/mxnet/ndarray.py", line 293, in bool raise ValueError("The truth value of an NDArray is ambiguous. " \ ValueError: The truth value of an NDArray is ambiguous. Please convert to number with asscalar() first.

Can you guide me how to fix it?

js05212 commented 7 years ago

Hi, might I ask what version of MXNet you are using?

xanhho commented 7 years ago

Thank you for your reply! I had fixed this error by install another version of MXNet. I have some question related to your code. Could you please answer for me? In the paper had mentioned 5 hyperparameters lambda_w, lambda_n, lambda_u, lambda_s, lambda_v. But I see you just mentioned lambda_u and lambda_v in your code? How about lambda_w, lambda_n, lambda_s? Is there any related between lv, lambda_v_rt (in your code) and lambda_w, lambda_n, lambda_s (in the paper)?

Thank you very much!

js05212 commented 7 years ago

Hi. lambda_w is equivalent to the weight decay coefficient in NN if we use MAP inference, and it is fixed to 1e-4 (since the performance is not sensitive to it). lambda_s can be taken to positive infinity as mentioned in the paper. Essentially what is important is the ratio lambda_n/lambda_v and lambda_u.

Hope this helps!

xanhho commented 7 years ago

Hi, thank you for your reply!

Is this code can reproduce the result as mentioned in the paper? Or it just a simple version for CDL?

js05212 commented 7 years ago

Hi, it is a simple version for CDL. For the full version, please go to wanghao.in/code/cdl-release.rar.You are more than welcome to fork this repo to make it the full version though. Feel free to ask if you need help.

xanhho commented 7 years ago

Hi, thank you very much for your support!

m2rik commented 7 years ago

hi, can i know which version of MXNet solved the problem ?

xanhho commented 7 years ago

Hi, I am using MXNet 0.11.0.

m2rik commented 7 years ago

i'm using the same version still getting the same error ,any solution ?

xanhho commented 7 years ago

Can you show me the error? Have you tried debug by python command?

m2rik commented 7 years ago

error2

xanhho commented 7 years ago

You can fix this error by change the code in line 84 by this line:

update_dict = {name: nd for name, nd in zip(sym.list_arguments(), exe.grad_arrays) if nd}

    update_dict = {name: nd for name, nd in zip(sym.list_arguments(), exe.grad_arrays) if nd is not None}
m2rik commented 7 years ago

Okay,all the errors were just the Python version issue .Now stuck on the show recommendations file with the error attribute error object has no attribute 'A1' .can anyone solve this error4

xanhho commented 7 years ago

Change by these following lines, it will work. // s_test = set(np.where(R_test[user_id,:]>0)[1].A1) // l_train = np.where(R_train[user_id,:]>0)[1].A1.tolist() s_test = set(np.ravel(np.where(R_test[user_id, :] > 0)[1])) l_train = np.ravel(np.where(R_train[user_id, :] > 0)[1]).tolist()

m2rik commented 7 years ago

It worked, can you tell me how it fixes the A1 attribute of the array?

js05212 commented 7 years ago

Thanks, @xanhxanh94, for your help!

xanhho commented 7 years ago

Hi, @js05212, You're welcome! Can you please answer for me the questions in js05212/CDL?

Thank you very much for your support!

ShuyaZhang commented 6 years ago

Hi, @xanhxanh94 , I've corrected several mistakes you mentioned before, now I'm using earlier version of mxnet. However, I still have following error when running cdl.py, could you solve it? image

MaurizioFD commented 5 years ago

Hi, @xanhxanh94 , I've corrected several mistakes you mentioned before, now I'm using earlier version of mxnet. However, I still have following error when running cdl.py, could you solve it? image

The error is due to the fact that in python 3 the .values() function returns a view.

You can solve it by creating a list with the dict_values object. The code in solver.py in lines 131-138 becomes:

theta = list(model.extract_feature(sym[0], args, auxs,
    data_iter, X.shape[0], xpu).values())[0]
# update U, V and get BCD loss
U, V, BCD_loss = BCD_one(R, U, V, theta,
    lambda_u, lambda_v, dir_save, True)
# get recon' loss
Y = list(model.extract_feature(sym[1], args, auxs,
    data_iter, X.shape[0], xpu).values())[0]