resonator
- torchhd.resonator(input: VSATensor, estimates: VSATensor, domains: VSATensor) VSATensor[source]
A step of the resonator network that factorizes the input.
Given current estimates for each factor, it returns the next estimates for those factors.
- Parameters:
- Shapes:
Input: \((*, d)\)
Estimates: \((*, n, d)\)
Domains: \((*, n, m, d)\)
Output: \((*, n, d)\)
Examples:
>>> X = torchhd.random(5, 100) >>> Y = torchhd.random(5, 100) >>> Z = torchhd.random(5, 100) >>> domains = torch.stack((X, Y, Z), dim=0) >>> domains.shape torch.Size([3, 5, 100]) >>> x_hat = torchhd.multiset(X) >>> y_hat = torchhd.multiset(Y) >>> z_hat = torchhd.multiset(Z) >>> estimates = torch.stack((x_hat, y_hat, z_hat), dim=0) >>> estimates.shape torch.Size([3, 100]) >>> # look at similarity of estimates with the domain >>> torchhd.dot_similarity(estimates.unsqueeze(-2), domains).squeeze(-2) MAPTensor([[112., 80., 136., 106., 106.], [ 98., 102., 100., 110., 74.], [116., 94., 104., 112., 82.]]) >>> # Create the combined symbol >>> s = X[0].bind(Y[1]).bind(Z[3]) >>> # resonator step >>> estimates = torchhd.resonator(s, estimates, domains) >>> # look at similarity of new estimates with the domain >>> torchhd.dot_similarity(estimates.unsqueeze(-2), domains).squeeze(-2) MAPTensor([[100., 8., 8., -2., -2.], [-18., 70., 44., -6., 14.], [ 8., 2., 4., 100., -2.]]) >>> # resonator step >>> estimates = torchhd.resonator(s, estimates, domains) >>> # look at similarity of new estimates with the domain >>> torchhd.dot_similarity(estimates.unsqueeze(-2), domains).squeeze(-2) MAPTensor([[100., 8., 8., -2., -2.], [ 4., 100., 14., 0., -16.], [ 8., 2., 4., 100., -2.]])