Comments (1)
fixed
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
schedule = 'EDM'
if schedule == 'VESDE':
sigma_min = 0.02
sigma_max = 100
rho = 0
elif schedule == 'EDM':
sigma_min = 0.002
sigma_max = 80
rho = 7.0
def gauss_norm(x):
return np.exp(-x**2/2)/np.sqrt(2*np.pi)
def pred_x0_theory(x,sigma_t):
c = np.array([
[-1],
[ 1],
])
nominator = 0
denominator = 0
for i in range(c.shape[0]):
nominator += c[i] * gauss_norm((x-c[i])/sigma_t)
denominator += gauss_norm((x-c[i])/sigma_t)
return nominator / (denominator + 0)
# define the ODE
def model(x, t):
def s_t(t):
return 1
def s_t_p(t):
return 0
def sigma_t(t):
if schedule == 'VESDE':
# return self.sigma_min**2 * (self.sigma_max**2/self.sigma_min**2)**t
return np.sqrt(t)
elif schedule == 'EDM':
# rho_inv = 1.0 / self.rho
# sigmas = self.sigma_min**rho_inv + t * (
# self.sigma_max**rho_inv - self.sigma_min**rho_inv
# )
# sigmas = sigmas**self.rho
# return sigmas
return t
def sigma_t_p(t, h=1e-5):
return (sigma_t(t + h) - sigma_t(t - h)) / (2. * h)
first_term = s_t_p(t) / s_t(t) * x
score = (pred_x0_theory(x/s_t(t), sigma_t(t)) - x) / sigma_t(t)**2
second_term = s_t(t)**2 * sigma_t_p(t) * sigma_t(t) * score
dxdt = first_term - second_term
return dxdt
# time points
t = np.linspace(0.001,25,10000)
batch_size = 30
noise_init = 0.001
# Initial conditions
x1_values = np.random.normal(1, noise_init, (batch_size,))
x1m_values = np.random.normal(-1, noise_init, (batch_size,))
x0_values = np.concatenate((x1_values, x1m_values))
# For each initial condition, solve the ODE and plot the solution
for x0 in x0_values:
x = odeint(model, x0, t)
plt.plot(t, x, 'orange')
plt.xlabel('t')
plt.ylabel('x')
plt.title('Trajectories of the ODE')
plt.show()
from edm.
Related Issues (20)
- params[x] in this process with sizes [x, x] appears not to match sizes of the same param in process 0 HOT 2
- VP checkpoints are trained using VE-scaling? HOT 2
- About the Checkpoint
- Could you please provide us imagenet-uncond checkpoint?
- Can not reproduct the result in Table 2. HOT 5
- Question about Augmentation HOT 1
- ERROR when using multi-gpu training HOT 7
- Question about parameter tuning HOT 1
- On checkpoint for 256*256 images
- Different Phases of Sampling
- About hyper-parameters selection
- AssertionError: Torch not compiled with CUDA enabled
- Zero initialization of convolutions HOT 1
- Deterministic sampling and sampling steps
- Wrong beta_D coefficient for VP during sampling? HOT 1
- How to select options shown in Table2 for training VP/VE models HOT 1
- DataLoader worker (pid xxxx) is killed by signal HOT 1
- .
- Is the original loss of VP/VE implemented (i.e. network predict epsilon)? HOT 1
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 edm.