Comments (3)
Hi Wei,
Unfortunately we don't have a Tanh function since we don't know of a closed-form expression to compute the kernel with this activation.
Currently you could try the following workarounds:
-
Use
stax.Erf()
instead, which is very similar to Tanh and has a closed-form kernel expression. -
Use the original
jax.experimental.stax
(accessed asnt.stax.ostax
in the snippet below) to construct the network and use NT to compute the Monte Carlo estimate of the kernel, e.g.
from neural_tangents import stax, monte_carlo_kernel_fn
from jax import random
init_fn, apply_fn = stax.ostax.serial(stax.ostax.Dense(512), stax.ostax.Tanh)
kernel_fn = monte_carlo_kernel_fn(init_fn, apply_fn,
key=random.PRNGKey(1), n_samples=100)
kernel_fn(x1=random.normal(random.PRNGKey(1), (10, 40)),
x2=random.normal(random.PRNGKey(2), (20, 40)),
get=('nngp', 'ntk'))
- You could look into approximating the intractable integrals with a lookup table as was done in https://arxiv.org/pdf/1711.00165.pdf (sec 2.5; https://github.com/brain-research/nngp/blob/42a5fb523653c0a213851628bc3ca0b78a2e8d1c/nngp.py#L307), but this would likely require a lot of effort to implement (NT does not support this currently).
Let me know if any of this helps!
from neural-tangents.
Hi Roman,
Many thanks for your reply. The second method works for Tanh function very well.
I just have a suggestion for your consideration.
If erf(x) changes to erf(\sqrt{\pi}/2 x), it is going to look more like the Tanh function, in the context of
the mean field theory (https://arxiv.org/abs/1802.09979). Since the intersection between critical line and \sigma_b = 0 is \sigma_w=1 for both erf(\sqrt{\pi}/2 x) and Tanh.
Best regards,
Wei
from neural-tangents.
Sorry for huge delay, FYI @SiuMath added this option in d7fc2db
from neural-tangents.
Related Issues (20)
- The analytical output of GP can not fit the result of NNGP generated by the nt.predict.gp_inference HOT 1
- Question: Relu Kernel Computation HOT 3
- Question: Connection MLE "parametrized" GP in infinite Width Limit vs minimizing MSE "parametrized" Kernel in infinite Width HOT 4
- Question regarding OOM issues HOT 3
- Question regarding lr in Neural Tangents Cookbook
- eNTK implementation uses deprecated xla attribute HOT 2
- Colab notebooks issue HOT 2
- How to obtain aleatoric uncertainty? HOT 2
- How to compute the empirical after kernel? HOT 1
- pip install issues HOT 2
- Erf function goes beyond [-1,1] HOT 2
- using stax.Cos(a=1.0, b=1.0, c=0.0) to get kernel from conv layer gives error HOT 2
- NTK is not PD
- stax.serial PSDness HOT 1
- How to use batch to gradient_descent_mse_ensemble ? HOT 1
- NTK/NNGP behavior in the infinite regime when weights are drawn from Gaussians with high standard deviation HOT 7
- NKT_mean output Nan, when the number of training sample is increased HOT 3
- Inefficient jacobian computation for embedding layers. HOT 1
- Question regarding the cookbook
- Calling the empirical kernel function with different parameters returns same result
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neural-tangents.