Skip to content

I have question about loss function. something wrong, i think....? #71

@hhjung1202

Description

@hhjung1202

There seems to be a problem in V_k when calculating the loss in the function.

in capsNet.py at loss function (line 106?)

max_l = tf.square(tf.maximum(0., cfg.m_plus - self.v_length))
max_r = tf.square(tf.maximum(0., self.v_length - cfg.m_minus))

you use self.v_length when calculating max_l and max_r.
self.v_length = tf.sqrt(reduce_sum(tf.square(self.caps2),
axis=2, keepdims=True) + epsilon)
self.caps2 is V_J and V_J's Dim is [batch_size, 10, 16, 1]
V_J = squash(S_J), so all of value in V_J is (-1, 1)

if it calculate self.v_length, the dim of self.v_length is [batch_size, 10, 1, 1] and interval of value is (-4, 4)

so i think, it has to change like this
max_l = tf.square(tf.maximum(0., cfg.m_plus - (self.v_length)/4))
max_r = tf.square(tf.maximum(0., (self.v_length)/4 - cfg.m_minus))

if it is wrong, Can you tell me what 's wrong?

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