JavaScript

Tensorflow.js – tf.asinh()

Tensorflow.js is a framework in Javascript that supports the tf.asinh() function that converts all the numeric values to inverse hyperbolic sine values present in a tensor.

Tf.asinh() Function

The tf.asinh() is used to return the inverse hyperbolic sine values from a given tensor. It takes only one parameter, i.e. tensor, that has numbers.

Syntax:
tf.asinh(tensor_input)

Parameter:
The tensor_input is a tensor that has numbers.
It can be 1or 2 dimensional.

Let’s explore the different examples of this method.

Example 1:
Let’s create a one-dimensional tensor in js that has some values and return the inverse hyperbolic sine values.

<html>
<!--   CDN Link that delivers the Tensorflow.js framework -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>

<body>
<center><h1>Tensorflow.js - tf.asinh() </h1></center>
<script>

let values = tf.tensor1d([23,45,0,45]);

//actual tensor
document.write("Actual Tensor: ",values);

document.write("<br>");
document.write("<br>");

//apply asinh() on the above tensor
document.write("Tensor with Inverse Hyperbolic Sine Values: "+tf.asinh(values));
</script>

</body>
</html>

Output:

The inverse hyperbolic sine values were returned from the given one-dimensional tensor.

Example 2:
Let’s create a tensor that has 2 dimensions in js with 5 rows and 2 columns and return the inverse hyperbolic cosine values.

<html>
<!--   CDN Link that delivers the Tensorflow.js framework -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>

<body>
<center><h1>Tensorflow.js - tf.asinh() </h1></center>
<script>

let values = tf.tensor2d([[0,null],[10,NaN],[45,82],[34,undefined],[67,43]]);
//actual tensor
document.write("Actual Tensor: ",values);

document.write("<br>");
document.write("<br>");

//apply asinh() on the above tensor
document.write("Tensor with Inverse Hyperbolic Sine Values: "+tf.asinh(values));
</script>

</body>
</html>

Output:

The inverse hyperbolic sine values were returned from the given one-dimensional tensor.

Example 3:
In this case, we will consider the decimal values. Let’s create a tensor that has 2 dimensions in js with 5 rows and 2 columns and return the inverse hyperbolic sine values.

<html>
<!--   CDN Link that delivers the Tensorflow.js framework -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>

<body>
<center><h1>Tensorflow.js - tf.asinh() </h1></center>
<script>

let values = tf.tensor2d([[4.80,0],[45.10,null],[46.785,8.2],[31.4,5.6],[6.87,43.76]]);//actual tensor
document.write("Actual Tensor: ",values);

document.write("<br>");
document.write("<br>");

//apply asinh() on the above tensor
document.write("Tensor with Inverse Hyperbolic Sine Values: "+tf.asinh(values));
</script>

</body>
</html>

Output:

The inverse hyperbolic sine values were returned from the given one-dimensional tensor.

Conclusion

In this Tensorflow.js tutorial, we learned how to return the values from the actual values using the tf.asinh() function present in one/two dimensional tensors with three examples. Make sure that the CDN Link is provided inside the script tag in each and every code.

About the author

Gottumukkala Sravan Kumar

B tech-hon's in Information Technology; Known programming languages - Python, R , PHP MySQL; Published 500+ articles on computer science domain