ganeshjawahar / mem_absa

Aspect Based Sentiment Analysis using End-to-End Memory Networks
MIT License
199 stars 104 forks source link

issue with the api use #10

Open verazuo opened 6 years ago

verazuo commented 6 years ago

https://github.com/ganeshjawahar/mem_absa/blob/5b7770243e3cbf0b50cfb0206f1b578a49205669/model.py#L82 Hello, I am running the code in Windows10. And I met a error in this line. Below is the error report

Traceback (most recent call last):
  File "main.py", line 76, in <module>
    tf.app.run()
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 72, in main
    model.build_model()
  File "C:\Users\verazuo\Desktop\practice\mood\undefined-algorithm\mem_absa2\model.py", line 107, in build_model
    self.build_memory()
  File "C:\Users\verazuo\Desktop\practice\mood\undefined-algorithm\mem_absa2\model.py", line 82, in build_memory
    att = tf.batch_matmul(a_til_concat, til_bl_3dim, adj_y = True)
AttributeError: module 'tensorflow' has no attribute 'batch_matmul'

I try to change the batch_matmul to matmul based on this issue of tf Then I met this error below.

Traceback (most recent call last):
  File "main.py", line 76, in <module>
    tf.app.run()
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 72, in main
    model.build_model()
  File "C:\Users\verazuo\Desktop\practice\mood\undefined-algorithm\mem_absa-master\model.py", line 107, in build_model
    self.build_memory()
  File "C:\Users\verazuo\Desktop\practice\mood\undefined-algorithm\mem_absa-master\model.py", line 82, in build_memory
    att = tf.matmul(a_til_concat, til_bl_3dim, adj_y = True)
TypeError: matmul() got an unexpected keyword argument 'adj_y'

So I delete 'adj_y',now the line has changed like below.

att = tf.matmul(a_til_concat, til_bl_3dim)

This is the Traceback info.

Traceback (most recent call last):
  File "main.py", line 76, in <module>
    tf.app.run()
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 72, in main
    model.build_model()
  File "C:\Users\verazuo\Desktop\practice\mood\undefined-algorithm\mem_absa2\model.py", line 107, in build_model
    self.build_memory()
  File "C:\Users\verazuo\Desktop\practice\mood\undefined-algorithm\mem_absa2\model.py", line 82, in build_memory
    att = tf.matmul(a_til_concat, til_bl_3dim)
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1814, in matmul
    a, b, adj_x=adjoint_a, adj_y=adjoint_b, name=name)
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 337, in _batch_mat_mul
    adj_y=adj_y, name=name)
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2632, in create_op
    set_shapes_for_outputs(ret)
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1911, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1861, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 595, in call_cpp_shape_fn
    require_shape_fn)
  File "C:\Users\verazuo\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 659, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Dimensions must be equal, but are 100 and 1 for 'MatMul' (op: 'BatchMatMul') with input shapes: [128,78,100], [128,1,100].

Do you have any idea to deal with this error? Coud you please tell me the develop-environment and configure of your repository? Thands a lot.

verazuo commented 6 years ago

I guess the author used tf0.12, so I try to use a ubuntu16.0.4 machine with tf0.12 and solved the problem, but then I also meet the problem of IndexError: index out of bounds However, I still want to know how to solve the problem above, do you have any idea?

jiansonglei commented 6 years ago

'adj_y' of batch_matmul is corresponding to the 'adjoint_b' of matmul. So, change the code to:

tf.matmul(a_til_concat, til_bl_3dim, adjoint_b = True)