MCPcopy Create free account
hub / github.com/pytorch/pytorch / _rff_hypothesis_test

Method _rff_hypothesis_test

caffe2/python/layers_test.py:1680–1693  ·  view source on GitHub ↗

Runs hypothesis test for Semi Random Features layer. Inputs: rff_output -- output of net after running random fourier features layer X -- input data W -- weight parameter from train_init_net b -- bias parameter

(rff_output, X, W, b, scale)

Source from the content-addressed store, hash-verified

1678 def testRandomFourierFeatures(self, batch_size, input_dims, output_dims, bandwidth):
1679
1680 def _rff_hypothesis_test(rff_output, X, W, b, scale):
1681 '''
1682 Runs hypothesis test for Semi Random Features layer.
1683
1684 Inputs:
1685 rff_output -- output of net after running random fourier features layer
1686 X -- input data
1687 W -- weight parameter from train_init_net
1688 b -- bias parameter from train_init_net
1689 scale -- value by which to scale the output vector
1690 '''
1691 output = workspace.FetchBlob(rff_output)
1692 output_ref = scale * np.cos(np.dot(X, np.transpose(W)) + b)
1693 npt.assert_allclose(output, output_ref, rtol=1e-3, atol=1e-3)
1694
1695 X = np.random.random((batch_size, input_dims)).astype(np.float32)
1696 scale = np.sqrt(2.0 / output_dims)

Callers

nothing calls this directly

Calls 3

dotMethod · 0.80
cosMethod · 0.45
transposeMethod · 0.45

Tested by

no test coverage detected