4ce2c3150094471ffa0c1a34ad9c337dfec85152,tensorflow_lattice/python/lattice_lib.py,,_project_partial_range_dominance,#Any#Any#Any#Any#,1280

Before Change


  dom_dim_size = lattice_sizes[dom_dim]
  weak_dim_size = lattice_sizes[weak_dim]
  i, j = constraint_group
  layers = _unstack_2d(weights, dom_dim, weak_dim)
  difference = ((layers[i][weak_dim_size - 1] - layers[i][0]) -
                (layers[dom_dim_size - 1][j] - layers[0][j]))
  if (i == 0 or i == dom_dim_size - 1) and (j == 0 or j == weak_dim_size - 1):
    correction = tf.maximum(difference / 2, 0)
    if i == 0:
      layers[dom_dim_size - 1][j] += correction
    else:
      layers[0][j] -= correction
    if j == 0:
      layers[i][weak_dim_size - 1] -= correction
    else:
      layers[i][0] += correction
  else:
    correction = tf.maximum(difference / 4, 0)
    layers[i][weak_dim_size - 1] -= correction
    layers[i][0] += correction
    layers[dom_dim_size - 1][j] += correction
    layers[0][j] -= correction

  return _stack_2d(layers, dom_dim, weak_dim)


def _project_partial_joint_monotonicity(weights, lattice_sizes,
                                        joint_monotonicity, constraint_group):

After Change


  dom_dim_size = lattice_sizes[dom_dim]
  weak_dim_size = lattice_sizes[weak_dim]
  i, j = constraint_group
  layers = _unstack_nd(weights, [dom_dim, weak_dim])
  difference = ((layers[i][weak_dim_size - 1] - layers[i][0]) -
                (layers[dom_dim_size - 1][j] - layers[0][j]))
  if (i == 0 or i == dom_dim_size - 1) and (j == 0 or j == weak_dim_size - 1):
    correction = tf.maximum(difference / 2, 0)
    if i == 0:
      layers[dom_dim_size - 1][j] += correction
    else:
      layers[0][j] -= correction
    if j == 0:
      layers[i][weak_dim_size - 1] -= correction
    else:
      layers[i][0] += correction
  else:
    correction = tf.maximum(difference / 4, 0)
    layers[i][weak_dim_size - 1] -= correction
    layers[i][0] += correction
    layers[dom_dim_size - 1][j] += correction
    layers[0][j] -= correction

  return _stack_nd(layers, [dom_dim, weak_dim])


def _project_partial_joint_monotonicity(weights, lattice_sizes,
                                        joint_monotonicity, constraint_group):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 18

Instances


Project Name: tensorflow/lattice
Commit Name: 4ce2c3150094471ffa0c1a34ad9c337dfec85152
Time: 2020-04-14
Author: no-reply@google.com
File Name: tensorflow_lattice/python/lattice_lib.py
Class Name:
Method Name: _project_partial_range_dominance


Project Name: tensorflow/lattice
Commit Name: 4ce2c3150094471ffa0c1a34ad9c337dfec85152
Time: 2020-04-14
Author: no-reply@google.com
File Name: tensorflow_lattice/python/lattice_lib.py
Class Name:
Method Name: _project_partial_range_dominance


Project Name: tensorflow/lattice
Commit Name: 4ce2c3150094471ffa0c1a34ad9c337dfec85152
Time: 2020-04-14
Author: no-reply@google.com
File Name: tensorflow_lattice/python/lattice_lib.py
Class Name:
Method Name: _project_partial_joint_monotonicity


Project Name: tensorflow/lattice
Commit Name: 4ce2c3150094471ffa0c1a34ad9c337dfec85152
Time: 2020-04-14
Author: no-reply@google.com
File Name: tensorflow_lattice/python/lattice_lib.py
Class Name:
Method Name: _project_partial_monotonic_dominance


Project Name: tensorflow/lattice
Commit Name: 4ce2c3150094471ffa0c1a34ad9c337dfec85152
Time: 2020-04-14
Author: no-reply@google.com
File Name: tensorflow_lattice/python/lattice_lib.py
Class Name:
Method Name: _project_partial_trapezoid