fix: make js generate correct notebook

This commit is contained in:
mhchia
2024-01-26 23:25:41 +08:00
parent 5176de1774
commit 78d00c42ba
2 changed files with 13 additions and 4 deletions

View File

@@ -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",

View File

@@ -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");