Giter Site home page Giter Site logo

glonet's Introduction

Global optimization based on generative nerual networks (GLOnet)

Requirements

We recommend using python3 and a virtual environment

virtualenv -p python3 .env
source .env/bin/activate
pip install -r requirements.txt

When you're done working on the project, deactivate the virtual environment with deactivate.

A matlab engine for python is needed for EM simulation. Please refer to MathWorks Pages for installation.

Path of RETICOLO should be added in the main.py

Training the GLOnet

You can change the parameters by editing Params.json in results folder.

If you want to train the network, simply run

python main.py 

or

python main.py --output_dir results --wavelength 900 --angle 60

to specify non-default output folder or parameters

Results

All results will store in output_dir/ folder.

-figures/  (figures of generated devices and loss function curve)

-model/    (all weights of the generator)

-outputs/  (500 generated devices in `.mat` format)

-history.mat

-train.log

Citation

If you use this code for your research, please cite:

Simulator-based training of generative models for the inverse design of metasurfaces.
Jiaqi Jiang, Jonathan A. Fan

Global Optimization of Dielectric Metasurfaces Using a Physics-Driven Neural Network.
Jiaqi Jiang, Jonathan A. Fan

glonet's People

Contributors

jiaqi-jiang avatar twhughes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

glonet's Issues

Undefined function 'retio' for input arguments of type 'double'.

Program error prompt:

GradientFromSolver_1D_parallel
Undefined function 'retio' for input arguments of type 'double'.

Error using GradientFromSolver_1D (line 34)
Undefined function 'retio' for input arguments of type 'double'.

Error in GradientFromSolver_1D_parallel (line 9)
parfor n = 1:N

Is the retio function undefined?

Reticolo res0 input

in the repository GLOnet/solvers/Eval_Eff_1D.m, line 17 input for res0 is -1 saying that its for the polarization

parm = res0(-1); % TE polarization. For TM : parm=res0(-1) parm.res1.champ = 1; % the electromagnetic field is calculated accurately %parm.res1.trace = 1; % show the texture

but when I check the reticolo res0.m file the input is supposes to dims and there is a 'pol' in the struct when dim=2

`
if nargin<1;dim=2;end;
if dim==2;% 2 D
sym=struct('x',[],'y',[],'pol',0);
parm1=struct('angles',1,'trace',0,'xlimite',[],'ylimite',[],'nx',100,'ny',100,'calcul',1,'champ',0,'ftemp',1,'fperm',[],'sog',1,'li',1);
else;% 1 D
sym=struct('x',[]);
parm1=struct('trace',0,'xlimite',[],'nx',1000,'calcul',1,'champ',1,'ftemp',0,'fperm',[],'sog',1);

end;
parm2=struct('cals',1,'cale',1,'calef',1,'tolh',1.e-6,'tolb',1.e-6,'retss',3,'retgg',0,'result',1);
parm3=struct('npts',10,'cale',[1:6],'calo',i,'sens',1,'caltab',0,'gauss',0,'gauss_x',10,'gauss_y',nan,'trace',0,'champs',[1:6,0],'apod_champ',0);
parm=struct('dim',dim,'sym',sym,'res1',parm1,'res2',parm2,'res3',parm3);
`

I am a bit confused h
ere if there is any error in the code or my understanding. Please help!!

Version of Python and supporting libraries?

Hi, thanks for sharing the code. I encountered the following error while running the code at the training progress of 49%:

File "C:\Users\user\GLOnet\train_and_evaluate.py", line 240, in visualize_generated_images
    save_image(imgs_2D, fig_path, n_row, range=(-1, 1))

  File "C:\Installation\anaconda3\lib\site-packages\torch\autograd\grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)

  File "C:\Installation\anaconda3\lib\site-packages\torchvision\utils.py", line 136, in save_image
    im.save(fp, format=format)

  File "C:\Installation\anaconda3\lib\site-packages\PIL\Image.py", line 2224, in save
    if format.upper() not in SAVE:

AttributeError: 'int' object has no attribute 'upper'

I think it could due to the difference in the versions of Python and the libraries, since no library version are written in requirement.txt.

My python version is 3.8.8 and the library versions are as follows:

GLOnet> pip freeze
colorama==0.4.4
cycler==0.11.0
fonttools==4.28.1
kiwisolver==1.3.2
matplotlib==3.5.0
numpy==1.21.4
packaging==21.2
Pillow==8.4.0
pyparsing==2.4.7
python-dateutil==2.8.2
scipy==1.7.2
setuptools-scm==6.3.2
six==1.16.0
tomli==1.2.2
torch==1.10.0
torchvision==0.11.1
tqdm==4.62.3
typing==3.7.4.3
typing_extensions==4.0.0

Could you please indicate the proper Python/library versions to run the code successfully?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.