Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4595d448 authored by CORNILLET Remi's avatar CORNILLET Remi
Browse files

Test + comparaison initiale vs optimisée vs optimal

parent 84d30d2e
No related branches found
No related tags found
No related merge requests found
......@@ -86,7 +86,7 @@ def optim_w(w_init, h, data, sigma, dictionary, reg, ent, rho1, rho2, cost,
ent = ent, rho1 = rho1, rho2=rho2, cost = cost, method = method, numItermax= numItermax,
thr = thr, verbose = verbose)
print(init_pb)
print("Coût initial : " + str(float(init_pb)))
n, r = w_init.shape
_, m = h.shape
......
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -9,28 +9,9 @@ m = 4
r = 2
rho1 = 0.1
aim = tn.ones(n, m) + tn.rand(n,m)
aim = simplex_norm(aim)
#dictionary = tn.tensor([[0.05, 0.05],[0.9, 0.05], [0.05, 0.9]], dtype=tn.float64)
dictionary = tn.abs(tn.rand(n,2, dtype=tn.float64))
dictionary = simplex_norm(dictionary)
#w = tn.tensor([[0.9, 0.05],[0.05, 0.05], [0.05, 0.9]], dtype=tn.float64)
w = tn.ones(n, r) + tn.rand(n,r)
w = simplex_norm(w)
h = tn.ones(r, m) + tn.rand(r,m)
h = simplex_norm(h)
data = dictionary@h
sigma = [0,1]
reg = 0.1
ent = 0.1
rho2 = 0.1
cost = tn.zeros((n, n), dtype=tn.float64)
......@@ -40,21 +21,43 @@ for i in range(n):
matK = compute_matK(cost, ent)
out = pb_dual(aim, w, rho1, h, data, sigma, dictionary, reg, ent, matK)
out2 = grad1_pb_dual(aim, w, rho1, h, data, ent, matK)
print(w)
print(dictionary)
out3 = optim_w(w, h, data, sigma, dictionary, reg, ent, rho1, rho2, cost)
print(out3)
out4 = pb(w = out3, h = h, sigma = sigma, data = data, dictionary = dictionary, reg = reg,
ent = ent, rho1 = rho1, rho2=rho2, cost = cost)
print(out4)
\ No newline at end of file
for i in range(100):
aim = tn.ones(n, m) + tn.rand(n,m)
aim = simplex_norm(aim)
#dictionary = tn.tensor([[0.05, 0.05],[0.9, 0.05], [0.05, 0.9]], dtype=tn.float64)
dictionary = tn.abs(tn.rand(n,2, dtype=tn.float64))
dictionary = simplex_norm(dictionary)
#w = tn.tensor([[0.9, 0.05],[0.05, 0.05], [0.05, 0.9]], dtype=tn.float64)
w = tn.ones(n, r) + tn.rand(n,r)
w = simplex_norm(w)
h = tn.ones(r, m) + tn.rand(r,m)
h = simplex_norm(h)
data = dictionary@h
out = pb_dual(aim, w, rho1, h, data, sigma, dictionary, reg, ent, matK)
out2 = grad1_pb_dual(aim, w, rho1, h, data, ent, matK)
#print(w)
#print(dictionary)
out3 = optim_w(w, h, data, sigma, dictionary, reg, ent, rho1, rho2, cost)
#print(out3)
out4 = pb(w = out3, h = h, sigma = sigma, data = data, dictionary = dictionary, reg = reg,
ent = ent, rho1 = rho1, rho2=rho2, cost = cost)
print("Coût après optim : " + str(float(out4)))
print("Coût optimal : " + str(float(pb(w = dictionary, h = h, sigma = sigma, data = data, dictionary = dictionary, reg = reg,
ent = ent, rho1 = rho1, rho2=rho2, cost = cost))))
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment