Hello,
I’ve converted a tensorflow model to a tensorflow lite model and I’ve used tflite built-in ops(Exp, Greater, Mul, Square, Sub, Sum, Transpose), but I get error:
TF Select ops: AddV2, Exp, Greater, MatMul, Mul, Square, Sub, Sum, Transpose
Details:
tf.AddV2(tensor<1x1xf64>, tensor<f64>) -> (tensor<1x1xf64>) : {device = ""}
tf.Exp(tensor<133x1xf64>) -> (tensor<133x1xf64>) : {device = ""}
tf.Greater(tensor<1x1xf64>, tensor<f64>) -> (tensor<1x1xi1>) : {device = ""}
tf.MatMul(tensor<1x133xf64>, tensor<1x133xf64>) -> (tensor<1x1xf64>) : {transpose_a = false, transpose_b = true}
tf.Mul(tensor<133x1xf64>, tensor<f64>) -> (tensor<133x1xf64>) : {device = ""}
tf.Square(tensor<133x72xf64>) -> (tensor<133x72xf64>) : {device = ""}
tf.Sub(tensor<72xf64>, tensor<133x72xf64>) -> (tensor<133x72xf64>) : {device = ""}
tf.Sum(tensor<133x72xf64>, tensor<i32>) -> (tensor<133x1xf64>) : {device = "", keep_dims = true}
tf.Transpose(tensor<133x1xf64>, tensor<2xi32>) -> (tensor<1x133xf64>)
Why these become the custom ops?
code:
class oneClassSVM(tf.Module):
def __init__(self, dual_coef, intercept, support_vector, gamma):
self.dual_coef = dual_coef
self.intercept = intercept
self.support_vector = support_vector
self.gamma = gamma
@tf.function(input_signature=[tf.TensorSpec(shape=(72), dtype=tf.float64)])
def svm_predict(self, x):
distance = tf.reduce_sum(tf.square(tf.subtract(x, self.support_vector)), axis=1, keepdims=True)
summation = tf.matmul(self.dual_coef, tf.math.exp(tf.multiply(tf.negative(self.gamma), distance)))
predict = 1 if tf.add(summation, self.intercept) > 0 else -1
return predict