soft_constraint

KGE.constraint.soft_constraint(X, p, value, axis)[source]

Soft constraint

Soft constraint that described in TransH:

\[regularization ~ term = \sum \left[ \left\| \textbf{X} \right\|_p^2 - value \right]_+\]

where \([x]_+ = max(0,x)\)

Parameters
  • X (tf.Tensor) – Tensor to be constraint

  • p (int) – p-norm

  • value (float) – restrict value

  • axis (int or tuple) – along what axis

Returns

regularization term

Return type

tf.Tensor