Skip to content

ValueError: Shape must be rank 2 but is rank 3 for 'MatMul' (op: 'MatMul') with input shapes: [?,1000,2048], [2048,64]. #1

@zhangxgu

Description

@zhangxgu

The error raised when I run this code:
'''
import loupe as lp
import tensorflow as tf
x = tf.placeholder("float", [None,1000,2048])
NetVLAD = lp.NetVLAD(feature_size=2048, max_samples=1000, cluster_size=64,
output_dim=2048, gating=True, add_batch_norm=True,
is_training=True)
NetVLAD.forward(x)
'''
I think this x.shape is #batch_size dot #max_sample dot #feature_size. Should I change line 126 in loupe.py into
'''
cluster_weights = tf.get_variable("cluster_weights",
[1, self.feature_size, self.cluster_size],
initializer = tf.random_normal_initializer(
stddev=1 / math.sqrt(self.feature_size)))
''' ?
But it also lead to other error, can you help me?
Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions