Tensorflow.js tf.inTopKAsync() Function
Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.
The .inTopKAsync() function is used to check if the stated targets are in the given top K predictions.
tf.inTopKAsync(predictions, targets, k?)
- predictions: It is the stated 2-D or upper tensor input whose last size is not lesser than k and it can be of type tf.Tensor, TypedArray, or Array.
- targets: It is the stated 1-D or upper tensor input and it can be of type tf.Tensor, TypedArray, or Array.
- k: It is the alternative number of top elements which are to be considered for calculating precision. The by default value is 1 and it is of type number.
Return Value: It returns Promise tf.Tensor object.
Tensor [false, true]
Tensor [true, true]