From e64531a4fcf0692e276903dc01530708e74b73d0 Mon Sep 17 00:00:00 2001 From: josemanuel22 Date: Sun, 11 Feb 2024 17:01:01 +0100 Subject: [PATCH 1/2] add comments CostFunction --- examples/CostFunction.jl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/examples/CostFunction.jl b/examples/CostFunction.jl index d3a3498..b0e2f57 100644 --- a/examples/CostFunction.jl +++ b/examples/CostFunction.jl @@ -1,6 +1,35 @@ using ThreadsX using Plots +""" +This script defines two Julia functions, `proxi_cost_function` and `real_cost_function`, +intended for computing the cost function of a model in relation to a target function. +Both functions calculate the cost for varying parameters `m` (slope) and `b` (intercept) +across a grid defined by a mesh of these parameters. + +- `proxi_cost_function` takes a meshgrid, a model function, a target function, a number of +parameter combinations (`K`), and a number of samples for Monte Carlo integration +(`n_samples`). It returns a vector of losses for each combination of mesh parameters. +The function estimates the loss by generating samples, applying the model and target +functions to these samples, and then computing a loss based on the divergence of the +model's output from the target's output. + +- `real_cost_function` is similar to `proxi_cost_function` but calculates the cost based on +a direct comparison of the model's output against the target function over the specified +mesh. It also involves counting occurrences within a specified window to compute the loss. + +Both functions illustrate a method for evaluating the performance of a model function +against a target, useful in optimization and machine learning contexts to adjust model +parameters (`m` and `b`) to minimize the loss. + +Additionally, the script includes a demonstration of how to use these functions with a +simple linear model (`model(x; m, b) = m * x + b`) and a predefined `real_model`. It +prepares a mesh of parameters around an initial guess for `m` and `b`, computes losses +using both the proxy and real cost functions, and plots the resulting cost function +landscape to visualize areas of minimum loss, facilitating the understanding of how well +the model approximates the target function across different parameter combinations. +""" + """ proxi_cost_function(mesh, model, target, K, n_samples) From 255382e5abc032cef9793d585bcc1d31d0248e8c Mon Sep 17 00:00:00 2001 From: josemanuel22 Date: Sun, 11 Feb 2024 17:11:50 +0100 Subject: [PATCH 2/2] Change doc iun gan.md --- docs/src/gan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/gan.md b/docs/src/gan.md index 67fd27b..a05128a 100644 --- a/docs/src/gan.md +++ b/docs/src/gan.md @@ -2,6 +2,6 @@ In this repository, we have included a folder with different generative adversarial networks, GANs: [vanilla GAN](https://arxiv.org/pdf/1406.2661.pdf), [WGAN](https://arxiv.org/pdf/1701.07875.pdf), [MMD-GAN](https://arxiv.org/pdf/1705.08584.pdf). -In the first two cases, we have used the implementation from this [repoistory](https://github.com/AdarshKumar712/FluxGAN), with some minor changes. In the last case, we have rewritten the original [code](https://github.com/OctoberChang/MMD-GAN) written in Python to Julia. +In the first two cases, we have used the implementation from this [repository](https://github.com/AdarshKumar712/FluxGAN), with some minor changes. In the last case, we have rewritten the original [code](https://github.com/OctoberChang/MMD-GAN) written in Python to Julia. The goal is to test that the AdapativeBlockLearning methods can work as regularizers for the solutions proposed by the GANs, providing a solution to the Helvetica scenario. \ No newline at end of file