@@ -32,7 +32,7 @@ import Control.Monad(forM_, replicateM, zipWithM)
32
32
import Control.Monad.IO.Class (liftIO )
33
33
34
34
import qualified TensorFlow.Core as TF
35
- import qualified TensorFlow.GenOps.Core as TF (conv2DBackpropInput' , max , maximum , tile , pad , batchToSpaceND , spaceToBatchND , squeeze , sqrt , slice , shape )
35
+ import qualified TensorFlow.GenOps.Core as TF (conv2DBackpropInput' , max , maximum , resizeBilinear' , tile , pad , batchToSpaceND , spaceToBatchND , squeeze , sqrt , slice , shape )
36
36
import qualified TensorFlow.Gradient as TF
37
37
import qualified TensorFlow.Ops as TF hiding (zeroInitializedVariable , shape )
38
38
import qualified TensorFlow.Output as TF
@@ -429,6 +429,22 @@ testTile2DGrad = testCase "testTileGrad2D" $ do
429
429
shapeX @=? (shapeDX :: V. Vector Int32 )
430
430
V. fromList [6 , 6 , 6 , 6 , 6 , 6 :: Float ] @=? (dx :: V. Vector Float )
431
431
432
+ testResizeBilinearGrad :: Test
433
+ testResizeBilinearGrad = testCase " testResizeBilinearGrad" $ do
434
+ (dx, shapeDX, shapeX) <- TF. runSession $ do
435
+ let shape = TF. vector [1 , 2 , 2 , 1 :: Int32 ]
436
+ x <- TF. render $ TF. fill shape (TF. scalar (1 :: Float ))
437
+ let outSize = TF. vector [4 , 4 :: Int32 ]
438
+ align = TF. opAttr " align_corners" .~ True
439
+ y = TF. resizeBilinear' align x outSize
440
+
441
+ [dx] <- TF. gradients y [x]
442
+ TF. run (dx, TF. shape dx, TF. shape x)
443
+ shapeX @=? (shapeDX :: V. Vector Int32 )
444
+ let expect = V. fromList [4 , 4 , 4 , 4 :: Float ]
445
+ near = 0.00001 > (V. sum $ V. zipWith (-) expect (dx :: V. Vector Float ))
446
+ near @=? True
447
+
432
448
matMulGradient :: Test
433
449
matMulGradient = testCase " matMulGradients" $ do
434
450
@@ -553,6 +569,7 @@ main = defaultMain
553
569
, testFillGrad
554
570
, testTileGrad
555
571
, testTile2DGrad
572
+ , testResizeBilinearGrad
556
573
, matMulGradient
557
574
, matMulGradGrad
558
575
, matMulTransposeGradient (False , False )
0 commit comments