mirror of
https://github.com/MPCStats/zk-stats-demo.git
synced 2026-01-08 21:28:00 -05:00
fix: make js generate correct notebook
This commit is contained in:
@@ -7,14 +7,13 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"import torch\n",
|
||||
"from zkstats.core import (\n",
|
||||
" prover_gen_settings,\n",
|
||||
" prover_gen_proof,\n",
|
||||
" verifier_setup,\n",
|
||||
" verifier_verify,\n",
|
||||
")\n",
|
||||
"from zkstats.computation import computation_to_model, State\n",
|
||||
"from zkstats.computation import computation_to_model\n",
|
||||
"\n",
|
||||
"cwd = os.getcwd()\n",
|
||||
"\n",
|
||||
@@ -62,6 +61,10 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# This is just a dummy computation. Replace it with user's computation\n",
|
||||
"#\n",
|
||||
"# import torch\n",
|
||||
"# from zkstats.computation import State\n",
|
||||
"#\n",
|
||||
"# def computation(state: State, x: list[torch.Tensor]):\n",
|
||||
"# x_0 = x[0]\n",
|
||||
"# out_0 = state.median(x_0)\n",
|
||||
|
||||
@@ -30,8 +30,14 @@ export async function generateJupyterNotebookForComputation(computation: string,
|
||||
async function exampleDownloadNotebook() {
|
||||
const name = "mean";
|
||||
const date = Date.now();
|
||||
const computation = `from zkstats.models import MeanModel
|
||||
Model = MeanModel`
|
||||
const computation = `import torch
|
||||
from zkstats.computation import State
|
||||
|
||||
def computation(state: State, x: list[torch.Tensor]):
|
||||
x_0 = x[0]
|
||||
out_0 = state.median(x_0)
|
||||
out_1 = state.median(x_0)
|
||||
return state.mean(torch.tensor([out_0, out_1]).reshape(1,-1,1))`
|
||||
const notebook = await generateJupyterNotebookForComputation(computation, templateNotebook)
|
||||
// Download for testing
|
||||
const element = document.createElement("a");
|
||||
|
||||
Reference in New Issue
Block a user