Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix size-incompatible #2

Open
HelloSeeing opened this issue Feb 19, 2019 · 1 comment
Open

Matrix size-incompatible #2

HelloSeeing opened this issue Feb 19, 2019 · 1 comment

Comments

@HelloSeeing
Copy link

Hi,
Thanks for your sharing! I met an error while running your code with the following command:

$ python aae_mnist.py --train --ncode 2 --dist_type gaussian

It turns out to be:

[step: 100] loss: 152.4328 d_loss: 1.9309 g_loss: 3.7884
[step: 200] loss: 130.0870 d_loss: 1.8414 g_loss: 2.8809
[step: 300] loss: 118.0664 d_loss: 1.6845 g_loss: 2.2411
[step: 400] loss: 111.2656 d_loss: 1.5877 g_loss: 1.9333
==== epoch: 0, lr:0.0002 ====
[step: 468] loss: 108.2857 d_loss: 1.5520 g_loss: 1.7980
[Valid]: [step: 468] loss: 89.4752
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1322, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1307, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1409, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Matrix size-incompatible: In[0]: [2,400], In[1]: [2,1000]
	 [[Node: AE_1/decoder/decoder_FC/linear1/xw_plus_b/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](AE_1/MultivariateNormalDiag/sample/affine_linear_operator/forward/DistributionShape_1/undo_make_batch_of_event_sample_matrices/rotate_transpose/transpose, AE/decoder/decoder_FC/linear1/weights/read)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aae_mnist.py", line 356, in <module>
    train()
  File "aae_mnist.py", line 272, in train
    trainer.valid_epoch(sess, dataflow=valid_data, summary_writer=writer)
  File "../src/helper/trainer.py", line 428, in valid_epoch
    gen_im = sess.run(self._generate_op)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 900, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1135, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run
    run_metadata)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Matrix size-incompatible: In[0]: [2,400], In[1]: [2,1000]
	 [[Node: AE_1/decoder/decoder_FC/linear1/xw_plus_b/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](AE_1/MultivariateNormalDiag/sample/affine_linear_operator/forward/DistributionShape_1/undo_make_batch_of_event_sample_matrices/rotate_transpose/transpose, AE/decoder/decoder_FC/linear1/weights/read)]]

Caused by op 'AE_1/decoder/decoder_FC/linear1/xw_plus_b/MatMul', defined at:
  File "aae_mnist.py", line 356, in <module>
    train()
  File "aae_mnist.py", line 247, in train
    valid_model.create_generate_model(b_size=400)
  File "../src/models/aae.py", line 172, in create_generate_model
    self.layers['generate'] = (self.decoder(decoder_in) + 1. ) / 2.
  File "../src/models/aae.py", line 206, in decoder
    wd=self._wd, name='decoder_FC', init_w=INIT_W)
  File "../src/models/modules.py", line 35, in decoder_FC
    L.linear(name='linear1', nl=nl)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 183, in func_with_args
    return func(*args, **current_args)
  File "../src/models/layers.py", line 105, in linear
    act = tf.nn.xw_plus_b(inputs, weights, biases)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 2219, in xw_plus_b
    mm = math_ops.matmul(x, weights)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 2014, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 4279, in mat_mul
    name=name)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3414, in create_op
    op_def=op_def)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1740, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Matrix size-incompatible: In[0]: [2,400], In[1]: [2,1000]
	 [[Node: AE_1/decoder/decoder_FC/linear1/xw_plus_b/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/device:GPU:0"](AE_1/MultivariateNormalDiag/sample/affine_linear_operator/forward/DistributionShape_1/undo_make_batch_of_event_sample_matrices/rotate_transpose/transpose, AE/decoder/decoder_FC/linear1/weights/read)]]

Could you please help me with this problem? Thanks!

@mathshangw
Copy link

excuse me did you solve it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants