Skip to content

Commit

Permalink
Write initial.json for reproduction in Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Jihoon Song authored and Jihoon Song committed May 26, 2023
1 parent cbf3d23 commit 55e23d0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ref_cnn/generate_cnn_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
from enum import Enum
import re
import os

# Encoder
class Encoder(JSONEncoder):
Expand Down Expand Up @@ -149,7 +150,7 @@ class Layer(Enum):

initial = x.flatten().astype(np.float32, copy=False)

data = {
initial = {
"v": 1,
"dim": shape,
"data": initial
Expand Down Expand Up @@ -356,8 +357,16 @@ class Layer(Enum):

print("\nfinal output:", x)

# create json files
if not os.path.exists('../src/json/'):
os.makedirs('../src/json/')

initial_data = json.dumps(initial, cls=Encoder)
with open('../src/json/initial.json', "w") as f:
print('\ncreated initial.json in the proto-neural-zkp/src/json folder')
f.write(initial_data)

model_data = json.dumps(model, cls=Encoder)
with open('../src/json/model.json', "w") as f:
print('\ncreated model.json in the proto-neural-zkp/src/json folder')
print('created model.json in the proto-neural-zkp/src/json folder')
f.write(model_data)

0 comments on commit 55e23d0

Please sign in to comment.