UNC-optics / DeepCGH

A Python/TensorFlow implementation of DeepCGH, a framework for unsupervised deep learning-based computer-generated holography.
Other
88 stars 26 forks source link

model parameter quantization #2

Open chrisvdt opened 1 year ago

chrisvdt commented 1 year ago

model parameter quantization is missing in tutorial code. Please add.


KeyError Traceback (most recent call last) Input In [6], in <cell line: 1>() ----> 1 dcgh = DeepCGH(data, model)

File D:\Git\DeepCGH\deepcgh.py:763, in DeepCGH.init(self, data_params, model_params) 761 self.shape = data_params['shape'] 762 self.plane_distance = model_params['plane_distance'] --> 763 self.quantization = 2**model_params['quantization'] 764 self.n_kernels = model_params['n_kernels'] 765 self.IF = model_params['int_factor']

KeyError: 'quantization'

hosseybposh commented 1 year ago

are you having this issue on the main branch? I double-checked the demo files and the google colab tutorial they all seem to have this parameter and run smoothly on my end.

chrisvdt commented 1 year ago

Hi Hossein,

I am trying to run your tutorial.ipynb in jupyter notebook; 'quantization' Is missing in your model parameters.

model = {'path' : 'DeepCGH_Models/Disks',# the path to the saved model 'plane_distance':0.005,# the physical distance between depth planes when we're doing 3D holography

physical setup parameters

    'wavelength':1e-6,# the wavelength of the laser (both simulations and experiments)
    'pixel_size':0.000015,# size of the SLM pixel sizes
    'int_factor':16,# the interleaving factor
     # CNN model and training parameters
    'n_kernels':[ 64, 128, 256],# the number of kernels in the U-Net model (see the manuscript)
    'input_name':'target',# name of the input layer in the U-Net model
    'output_name':'phi_slm',# name of the output layer
    'lr' : 1e-7,# learning rate of the optimizer
    'batch_size' : 8,
    'epochs' : 1,
    'shuffle' : 8,# determine how many samples are going to be shuffled
    'token' : '64',# string to be attached to the name of the model to differentiate it from similar models
    'max_steps' : 5000 # maxmimum number of batches/steps to be processed
    }

Dr. C. van der Togt

Data manager Netherlands Institute for Neuroscience Meibergdreef 47 1105BA Amsterdam The Netherlands From: Hossein Eybposh @.> Sent: Monday, 19 December 2022 16:49 To: UNC-optics/DeepCGH @.> Cc: Chris van der Togt @.>; Author @.> Subject: Re: [UNC-optics/DeepCGH] model parameter quantization (Issue #2)

are you having this issue on the main branch? I double-checked the demo files and the google colab tutorial they all seem to have this parameter and run smoothly on my end.

- Reply to this email directly, view it on GitHubhttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FUNC-optics%2FDeepCGH%2Fissues%2F2%23issuecomment-1357869792&data=05%7C01%7Cc.vandertogt%40nin.knaw.nl%7Cd94a79bddb834fb9e7a308dae1d87bb1%7Cac4b0eb0811e4ab0acca8a87079290dc%7C0%7C0%7C638070617156490668%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=VTK%2BEhLAmgbXiGkh8XCTPaGj4E1cXpH2NMH70PfJZnA%3D&reserved=0, or unsubscribehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABIQZHGCME3LNQWDJUNQSF3WOB7U7ANCNFSM6AAAAAATDMERJI&data=05%7C01%7Cc.vandertogt%40nin.knaw.nl%7Cd94a79bddb834fb9e7a308dae1d87bb1%7Cac4b0eb0811e4ab0acca8a87079290dc%7C0%7C0%7C638070617156490668%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=NeeYty0YRebK7U4d%2BHT25YVYqymGpOImruL3Ldsox4I%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.**@.>>

chrisvdt commented 1 year ago

So the tutorial is giving me losts of errors, even after fixing the previous issues. I've downloaded the main branch btw.

chrisvdt commented 1 year ago

Also the demo_deepcgh.py does not work for me . I'm using a windows system, with python 3.10, Now the problem is with writing files for the test dataset; (maybe a problem with the slashes?)

Node: 'save/SaveV2' Failed to create a NewWriteableFile: D:\Git\DeepCGH\DeepCGH_Models/Disks\Model_Disk_SHP(512, 512, 3)_IF16_Dst0.05_WL1.04e-06_PS9.2e-06_CNTFalse_DCGH\model.ckpt-0_temp\part-00000-of-00001.data-00000-of-00001.tempstate9062918209809844052 : The system cannot find the path specified. ; No such process

chrisvdt commented 1 year ago

Indeed a backslash problem. Now this step fails; reconstruction = propagate(phase).numpy() at --> 131 ypred = tf.concat(values = frames, axis = -1)

InvalidArgumentError: ConcatOp : Dimension 3 in both shapes must be equal: shape[0] = [1,512,512,512,1] vs. shape[1] = [1,512,512,1,1] [Op:ConcatV2] name: concat

the three frames that are generated in propagate have the following dimensions; (1, 512, 512, 512, 1) (1, 512, 512, 1, 1) (1, 512, 512, 512, 1) and therefore cannot be concatenated.

And sinds this is the only difference : cf_slm *= H i'm assuming it goes wrong here.

Using keras 2.9 and tensorflow 2.9.1 2 with python 3.10.4 on windows 10

hosseybposh commented 1 year ago

thank you for flagging this, I'll get back to you asap.

About the missing parameter, I'm the owner of the google colab code and on my end the parameter is provided which should reflect on your code as well. I'll double check