module testing.einsum.einsum_ml#

Short summary#

module mlprodict.testing.einsum.einsum_ml

Functions used to predict the cost of a transposition.

source on GitHub

Functions#

function

truncated documentation

_edit_distance

_is_rotation

_relu

compute_transposition_features

Given a shape and a permutation, computes many features used to predict the cost of the transposition.

predict_transposition_cost

Given a shape and a permutation, predicts the cost of the transposition.

Documentation#

Functions used to predict the cost of a transposition.

source on GitHub

mlprodict.testing.einsum.einsum_ml._edit_distance(mot1, mot2)#
mlprodict.testing.einsum.einsum_ml._is_rotation(perm)#
mlprodict.testing.einsum.einsum_ml._relu(x, origin=0)#
mlprodict.testing.einsum.einsum_ml.compute_transposition_features(shape, perm)#

Given a shape and a permutation, computes many features used to predict the cost of the transposition.

Parameters:
  • shape – shape

  • perm – permutation

Returns:

dictionary of features

<<<

import pprint
from mlprodict.testing.einsum.einsum_ml import (
    compute_transposition_features)

pprint.pprint(
    compute_transposition_features((3, 5, 7), (2, 1, 0)))

>>>

    {'CST_': -1,
     'begin': -1,
     'dbegin': 0,
     'dend': 0,
     'dim': 3,
     'discont': 2,
     'edit': 2,
     'end': -1,
     'end16': -16,
     'end32': -32,
     'ibegin16': -0.0,
     'ibegin2': -0.0,
     'ibegin32': -0.0,
     'ibegin4': -0.0,
     'ibegin64': -0.0,
     'ibegin8': -0.0,
     'iend16': -0.0,
     'iend2': -0.0,
     'iend32': -0.0,
     'iend4': -0.0,
     'iend64': -0.0,
     'iend8': -0.0,
     'middle': 105,
     'rbegin': -0.009523809523809525,
     'rdiscont': -0.01904761904761905,
     'redit': 0.6666666666666666,
     'rend': -0.009523809523809525,
     'rend16': -0.1523809523809524,
     'rend32': -0.3047619047619048,
     'rev': 1,
     'rmiddle': 1.0,
     'rot': 0,
     'size': 105}

source on GitHub

mlprodict.testing.einsum.einsum_ml.predict_transposition_cost(shape, perm, coefs=None)#

Given a shape and a permutation, predicts the cost of the transposition.

Parameters:
  • shape – shape

  • perm – permutation

  • coefs – trained coefficients or None to get the default ones

Returns:

dictionary of features

<<<

import pprint
from mlprodict.testing.einsum.einsum_ml import (
    compute_transposition_features)

pprint.pprint(
    compute_transposition_features((3, 5, 7), (2, 1, 0)))

>>>

    {'CST_': -1,
     'begin': -1,
     'dbegin': 0,
     'dend': 0,
     'dim': 3,
     'discont': 2,
     'edit': 2,
     'end': -1,
     'end16': -16,
     'end32': -32,
     'ibegin16': -0.0,
     'ibegin2': -0.0,
     'ibegin32': -0.0,
     'ibegin4': -0.0,
     'ibegin64': -0.0,
     'ibegin8': -0.0,
     'iend16': -0.0,
     'iend2': -0.0,
     'iend32': -0.0,
     'iend4': -0.0,
     'iend64': -0.0,
     'iend8': -0.0,
     'middle': 105,
     'rbegin': -0.009523809523809525,
     'rdiscont': -0.01904761904761905,
     'redit': 0.6666666666666666,
     'rend': -0.009523809523809525,
     'rend16': -0.1523809523809524,
     'rend32': -0.3047619047619048,
     'rev': 1,
     'rmiddle': 1.0,
     'rot': 0,
     'size': 105}

source on GitHub