summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorNicolas Courty <Nico@MacBook-Pro-de-Nicolas.local>2016-11-07 23:45:38 +0100
committerNicolas Courty <Nico@MacBook-Pro-de-Nicolas.local>2016-11-07 23:45:38 +0100
commit8097bdda7c0fbd469eecb55fc0a1e93dd53b7fb8 (patch)
treeedc3f210a533a0b9125e97cca7b0dab5e4dfda0d /examples
parent194d3668f963a0e0deccca8e2bc5bc638af2193d (diff)
gcg
Diffstat (limited to 'examples')
-rw-r--r--examples/demo_OTDA_classes.py2
-rw-r--r--examples/demo_optim_OTreg.py19
2 files changed, 17 insertions, 4 deletions
diff --git a/examples/demo_OTDA_classes.py b/examples/demo_OTDA_classes.py
index f61625a..8a97c80 100644
--- a/examples/demo_OTDA_classes.py
+++ b/examples/demo_OTDA_classes.py
@@ -56,7 +56,7 @@ da_lpl1.fit(xs,ys,xt,reg=lambd,eta=eta)
xstg=da_lpl1.interp()
#%% plot interpolated source samples
-pl.figure(4)
+pl.figure(4,(15,10))
param_img={'interpolation':'nearest','cmap':'jet'}
diff --git a/examples/demo_optim_OTreg.py b/examples/demo_optim_OTreg.py
index 0a8c583..a49b00c 100644
--- a/examples/demo_optim_OTreg.py
+++ b/examples/demo_optim_OTreg.py
@@ -31,7 +31,7 @@ G0=ot.emd(a,b,M)
pl.figure(3)
ot.plot.plot1D_mat(a,b,G0,'OT matrix G0')
-#%% Example with Frobenisu norm regularization
+#%% Example with Frobenius norm regularization
def f(G): return 0.5*np.sum(G**2)
def df(G): return G
@@ -43,7 +43,7 @@ Gl2=ot.optim.cg(a,b,M,reg,f,df,verbose=True)
pl.figure(3)
ot.plot.plot1D_mat(a,b,Gl2,'OT matrix Frob. reg')
-#%% Examlple with entropic regularization
+#%% Example with entropic regularization
def f(G): return np.sum(G*np.log(G))
def df(G): return np.log(G)+1
@@ -53,4 +53,17 @@ reg=1e-3
Ge=ot.optim.cg(a,b,M,reg,f,df,verbose=True)
pl.figure(4)
-ot.plot.plot1D_mat(a,b,Ge,'OT matrix Entrop. reg') \ No newline at end of file
+ot.plot.plot1D_mat(a,b,Ge,'OT matrix Entrop. reg')
+
+#%% Example with Frobenius norm + entropic regularization with gcg
+
+def f(G): return 0.5*np.sum(G**2)
+def df(G): return G
+
+reg1=1e-3
+reg2=1e-3
+
+Gel2=ot.optim.gcg(a,b,M,reg1,reg2,f,df,verbose=True)
+
+pl.figure(5)
+ot.plot.plot1D_mat(a,b,Gel2,'OT entropic + matrix Frob. reg') \ No newline at end of file