EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

+8617853885483
网课代修代上,cs代写代考
数据结构代写
您的位置: 主页 > 编程案例 > 数据结构代写 >
代做数据结构:julia算法代写 数据读取| 优化算法 - 作业代写, 北美代写, 台灣代寫 - 数据结构代做
发布时间:2021-07-25 14:05:39浏览次数:
function SPD1_VR(data::Array{ :Real, 2}, label::Array{ :Real, 1}, l1::Real, l2::Real;max_epoch::Int=100, eta::Real=1e-3, tau::Real=5e-1)n, d = size(data)x, y = zeros(d), zeros(n)ret = zeros(max_epoch)println("SPD1-VR: eta=$eta, tau=$tau")for epoch = 1 : max_epochfunc_val = norm(max.(1 .- (data * x) .* label, 0))^2 / n + l1 * norm(x, 1) + 0.5 * l2 * norm(x)^2ret[epoch] = func_valsparsity = norm(x, 0) / dprintln("Epoch: $epoch, Func_Val: $func_val, Sparsity: $sparsity")grad_x, grad_y = data' * y / n, data * x / dx_tilde, y_tilde = copy(x), copy(y)for _ = 1 : n*di, j = rand(1 : n), rand(1 : d)a, x_tmp = data[i,j], x[j]x[j] = proximal_mapping(x[j] - eta * (a * (y[i] - y_tilde[i]) + grad_x[j]), l1, l2, eta)y[i] = dual_prox(y[i] + tau * (a * (x[j] - x_tilde[j]) + grad_y[i]), label[i], tau / d)return retfunction SPD1_VR_AIS(data::Array{ :Real, 2}, label::Array{ :Real, 1}, l1::Real, l2::Real;max_epoch::Int=100, eta::Real=1e-3, tau::Real=5e-1)n, d = size(data)x, y = zeros(d), zeros(n)ret = zeros(max_epoch)G_x, bsvec_x, prob_x = ones(d), ones(d), ones(d)G_y, bsvec_y, prob_y = ones(n), ones(n), ones(n)size_sample_x, size_sample_y = 2*d, 2*nsample_x, sample_y = zeros(size_sample_x), zeros(size_sample_y)alpha0, alpha1 = 0.1, 0.8println("SPD1-VR-AIS: eta=$eta, tau=$tau")for epoch = 1 : max_epochfunc_val = norm(max.(1 .- (data * x) .* label, 0))^2 / n + l1 * norm(x, 1) + 0.5 * l2 * norm(x)^2ret[epoch] = func_valsparsity = norm(x, 0) / dprintln("Epoch: $epoch, Func_Val: $func_val, Sparsity: $sparsity")grad_x, grad_y = data' * y / n, data * x / dx_tilde, y_tilde = copy(x), copy(y)if epoch 1for i = 1 : nyi = dual_prox(y[i] + tau * grad_y[i], label[i], tau / d)G_y[i] = norm(yi-y[i])for j = 1 : dxj = proximal_mapping(x[j] - eta * grad_x[j], l1, l2, eta)G_x[j] = norm(xj-x[j])alpha2 = alpha0 + alpha1 * epoch / max_epochprob_x = (alpha2 / sum(G_x)) .* G_x + ((1 - alpha2) / d) .* ones(d)prob_y = (alpha2 / sum(G_y)) .* G_y + ((1 - alpha2) / n) .* ones(n)temp = 0for i = 1 : dbsvec_x[i] = temp + prob_x[i]temp = bsvec_x[i]temp = 0for i = 1 : nbsvec_y[i] = temp + prob_y[i]temp = bsvec_y[i]for i = 1 : size_sample_xrandnum = rand()left, right = 0, dwhile left + 1 rightmid = convert(Int64,floor((left + right) / 2))if randnum bsvec_x[mid]left = midright = midsample_x[i] = rightfor i = 1 : size_sample_yrandnum = rand()left, right = 0, nwhile left + 1 rightmid = convert(Int64,floor((left + right) / 2))if randnum bsvec_y[mid]left = midright = midsample_y[i] = rightfor _ = 1 : n*dindex_x, index_y = rand(1 : size_sample_x), rand(1 : size_sample_y)i, j = convert(Int64,sample_y[index_y]), convert(Int64,sample_x[index_x])a, x_tmp = data[i,j], x[j]eta_i = eta / (n * prob_y[i])tau_j = tau / (d * prob_x[j])x[j] = proximal_mapping(x[j] - eta_i * (a * (y[i] - y_tilde[i]) + grad_x[j]), l1, l2, eta_i)y[i] = dual_prox(y[i] + tau_j * (a * (x[j] - x_tilde[j]) + grad_y[i]), label[i], tau_j / d)return ret

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。