apsys commited on
Commit
5c89480
1 Parent(s): f7ca7f4
Files changed (3) hide show
  1. __pycache__/normflows.cpython-310.pyc +0 -0
  2. app.py +9 -5
  3. normflows.py +1 -1
__pycache__/normflows.cpython-310.pyc CHANGED
Binary files a/__pycache__/normflows.cpython-310.pyc and b/__pycache__/normflows.cpython-310.pyc differ
 
app.py CHANGED
@@ -6,13 +6,16 @@ import seaborn as sns
6
  import pandas as pd
7
 
8
  uploaded_file = st.file_uploader("Choose original dataset")
9
- bw = st.number_input('Scale',value=3.05)
 
 
 
10
 
11
 
12
 
13
- def compute():
14
- api = nflow(dim=8,latent=16,dataset=uploaded_file)
15
- api.compile(optim=torch.optim.ASGD,bw=bw,lr=0.0001,wd=None)
16
 
17
  my_bar = st.progress(0)
18
 
@@ -39,5 +42,6 @@ def compute():
39
 
40
 
41
  if uploaded_file is not None:
42
- samples=compute()
 
43
  st.download_button('Download generated CSV', pd.DataFrame(samples).to_csv(), 'text/csv')
 
6
  import pandas as pd
7
 
8
  uploaded_file = st.file_uploader("Choose original dataset")
9
+ col1,col2,col3 = st.columns(3)
10
+ bw = col1.number_input('Scale',value=3.05)
11
+ wd = col2.number_input('Weight Decay',value=0.0002)
12
+ iters = col3.number_input('Iterations',value=400)
13
 
14
 
15
 
16
+ def compute(dim):
17
+ api = nflow(dim=dim,latent=16,dataset=uploaded_file)
18
+ api.compile(optim=torch.optim.ASGD,bw=bw,lr=0.0001,wd=wd)
19
 
20
  my_bar = st.progress(0)
21
 
 
42
 
43
 
44
  if uploaded_file is not None:
45
+ dim = pd.read_csv(uploaded_file).shape[-1]
46
+ samples=compute(dim)
47
  st.download_button('Download generated CSV', pd.DataFrame(samples).to_csv(), 'text/csv')
normflows.py CHANGED
@@ -330,7 +330,7 @@ class nflow():
330
  z_k, sum_log_det = self.model(samples)
331
  log_p_x = self.density.log_prob(z_k)
332
  # Reverse KL since we can evaluate target density but can't sample
333
- loss = (-sum_log_det - (log_p_x)).mean()
334
 
335
  self.opt.zero_grad()
336
  loss.backward()
 
330
  z_k, sum_log_det = self.model(samples)
331
  log_p_x = self.density.log_prob(z_k)
332
  # Reverse KL since we can evaluate target density but can't sample
333
+ loss = (-sum_log_det - (log_p_x)).mean()/self.density.n
334
 
335
  self.opt.zero_grad()
336
  loss.backward()