2020
10-08
10-08
TensorFlow Autodiff自动微分详解
如下所示:withtf.GradientTape(persistent=True)astape:z1=f(w1,w2+2.)z2=f(w1,w2+5.)z3=f(w1,w2+7.)z=[z1,z3,z3][tape.gradient(z,[w1,w2])forzin(z1,z2,z3)]输出结果[[<tf.Tensor:id=56906,shape=(),dtype=float32,numpy=40.0>,<tf.Tensor:id=56898,shape=(),dtype=float32,numpy=10.0>],[<tf.Tensor:id=56919,shape=(),dtype=float32,numpy=46.0>,<tf.Tensor:id=56911,shape...
继续阅读 >