# 高速化された深層学習関数の出力のチェック

この例では、高速化された関数の出力が基になる関数の出力と一致するかどうかをチェックする方法を説明します。

`accfun = dlaccelerate(@myUnsupportedFun)`
```accfun = AcceleratedFunction with properties: Function: @myUnsupportedFun Enabled: 1 CacheSize: 50 HitRate: 0 Occupancy: 0 CheckMode: 'none' CheckTolerance: 1.0000e-04 ```

`clearCache(accfun)`

`accfun.CheckMode = 'tolerance'`
```accfun = AcceleratedFunction with properties: Function: @myUnsupportedFun Enabled: 1 CacheSize: 50 HitRate: 0 Occupancy: 0 CheckMode: 'tolerance' CheckTolerance: 1.0000e-04 ```

1 の配列を `dlarray` 入力として指定し、高速化された関数を評価します。

```dlX = dlarray(ones(3,3)); dlY = accfun(dlX)```
```dlY = 3×3 dlarray 1.8147 1.9134 1.2785 1.9058 1.6324 1.5469 1.1270 1.0975 1.9575 ```

`dlY = accfun(dlX)`
```Warning: Accelerated outputs differ from underlying function outputs. ```
```dlY = 3×3 dlarray 1.8147 1.9134 1.2785 1.9058 1.6324 1.5469 1.1270 1.0975 1.9575 ```

`accfun2 = dlaccelerate(@mySupportedFun);`

`clearCache(accfun2)`

`accfun2.CheckMode = 'tolerance';`

`dlY = accfun2(dlX)`
```dlY = 3×3 dlarray 1.7922 1.0357 1.6787 1.9595 1.8491 1.7577 1.6557 1.9340 1.7431 ```
`dlY = accfun2(dlX)`
```dlY = 3×3 dlarray 1.3922 1.7060 1.0462 1.6555 1.0318 1.0971 1.1712 1.2769 1.8235 ```

```accfun1.CheckMode = 'none'; accfun2.CheckMode = 'none';```

### 関数の例

```function out = myUnsupportedFun(dlX) sz = size(dlX); noise = rand(sz); out = dlX + noise; end```

```function out = mySupportedFun(dlX) sz = size(dlX); noise = rand(sz,'like',dlX); out = dlX + noise; end```