codekansas / seqgan-text-tensorflow

:dango: SeqGAN implementation for generating text using an RNN.
GNU General Public License v3.0
101 stars 48 forks source link

`InvalidArgumentError: Incompatible shapes: [32,100,44] vs. [32,100,100,1]` #7

Closed suzil closed 4 years ago

suzil commented 6 years ago

I'm getting an InvalidArgumentError: Incompatible shapes: [32,100,44] vs. [32,100,100,1] when I run ./train.py without changing any of the files. I set up my environment using the versions of libraries in requirements.txt with the additional library of tensorflow-gpu==1.0.1 so I can use a GPU. This error seems similar to the one commented at the end of https://github.com/codekansas/seqgan-text-tensorflow/issues/5.

Caused by op u'loss/generator/mul_1', defined at:
  File "./train.py", line 71, in <module>
    model.build()
  File "/home/suzil/home/kai/text-generation/seqgan-text-tensorflow/model.py", line 475, in build
    gen_op = self.get_generator_op(g_seq, g_preds, g_classes, g_weights)
  File "/home/suzil/home/kai/text-generation/seqgan-text-tensorflow/model.py", line 423, in get_generator_op
    gen_reward = tf.log(g_preds) * reward
  File "/home/suzil/anaconda2/envs/new/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 794, in binary_op_wrapper
    return func(x, y, name=name)
  File "/home/suzil/anaconda2/envs/new/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 1015, in _mul_dispatch
    return gen_math_ops._mul(x, y, name=name)
  File "/home/suzil/anaconda2/envs/new/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1625, in _mul
    result = _op_def_lib.apply_op("Mul", x=x, y=y, name=name)
  File "/home/suzil/anaconda2/envs/new/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
    op_def=op_def)
  File "/home/suzil/anaconda2/envs/new/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/home/suzil/anaconda2/envs/new/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1226, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Incompatible shapes: [32,100,44] vs. [32,100,100,1]
         [[Node: loss/generator/mul_1 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"](loss/generator/Log, loss/generator/ExpandDims)]]
         [[Node: loss/generator/add/_139 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_10_loss/generator/add", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Below is my exported environment:

(new) suzil@horus:~/home/kai/text-generation/seqgan-text-tensorflow$ conda env export
name: new
channels:
- defaults
dependencies:
- ca-certificates=2017.08.26=h1d4fec5_0
- certifi=2017.11.5=py27h71e7faf_0
- libedit=3.1=heed3624_0
- libffi=3.2.1=hd88cf55_4
- libgcc-ng=7.2.0=h7cc24e2_2
- libstdcxx-ng=7.2.0=h7a57d05_2
- ncurses=6.0=h9df7e31_2
- openssl=1.0.2m=h26d622b_1
- pip=9.0.1=py27ha730c48_4
- python=2.7.14=hdd48546_24
- readline=7.0=ha6073c6_4
- setuptools=36.5.0=py27h68b189e_0
- sqlite=3.20.1=hb898158_2
- tk=8.6.7=hc745277_3
- wheel=0.30.0=py27h2bc6bb2_1
- zlib=1.2.11=ha838bed_2
- pip:
  - appdirs==1.4.3
  - funcsigs==1.0.2
  - mock==2.0.0
  - numpy==1.12.1
  - packaging==16.8
  - pbr==2.0.0
  - protobuf==3.2.0
  - pyparsing==2.2.0
  - six==1.10.0
  - tensorflow==1.0.1
  - tensorflow-gpu==1.0.1
prefix: /home/suzil/anaconda2/envs/new
jenniferSun27 commented 6 years ago

I've got the same problem with using --only-cpu command, how to fix it?

suzil commented 6 years ago

I was able to run someone's fork without a problem: https://github.com/carrotflakes/seqgan-text-tensorflow

It uses TF 1.3 + Python3 (its requirements.txt is out-of-date).

SheezyGuo commented 5 years ago

@suzil I met the same error,it works for me,thanks a lot.