Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the mechanism of automatic derivation in tensorflow 2

Shulou Source: shulou.com Published: 2022-06-01 08:53:25 09月26日 Update

This article will explain in detail what the mechanism of automatic derivation in tensorflow 2 is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Import tensorflow as tf

Import numpy as np

# f (x) = derivative of a*x**2 + biconx + c

X = tf.Variable (0.0, name='x', dtype=tf.float32)

A = tf.constant (1. 0)

B = tf.constant (- 1.5)

C = tf.constant (1.0)

With tf.GradientTape () as tape:

Y = a * tf.pow (xmem2) + b * x + c

Dy_dx = tape.gradient (ymemery x)

Print (dy_dx)

It can be calculated that dy_dx = 2*a*x + b = 2 "1.0" 0.0 + (- 1.5) =-1.5

What we need to know is

(1) how GradienTape traces the function transformation path in the middle of y = a * tf.pow (XMagol 2) + b * x + c.

(2) how to find the derivative of the basic function block.

(3) how to realize the rule of derivation of compound function.

So much for the automatic derivation mechanism in tensorflow 2. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Derivation function mechanism content derivative article more knowledge article good rule quality path finding reference transformation help related tracking Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Technology Shulou Tech Info OPPO Reno MariaDB