本文介紹一下對一篇用neural network做inverse design的工作的學習课兄。
文章地址:Nanophotonic particle simulation and inverse design using artificial neural networks距辆;
代碼地址:https://github.com/iguanaus/ScatterNet
Scatter Net
'.\|/.'
(\ /)
- -O- -
(/ \)
,'/|\'.
Scatter Net
An example repository of using machine learning to solve a physics problem. Based on the work presented in, Nanophotonic Particle Simulation and Inverse Design Using Artificial Neural Networks (https://arxiv.org/abs/1712.03222). This repository is specifically designed for solving inverse design problems, particularly surrounding photonics and optics.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. This example will also generate Table I in the paper, and Figure 2,3, and 4.
Prerequisites
To run the Matlab code, Matlab will need to be installed. For this code, we used Matlab R2017a. Note that the project can be done without Matlab, but comparisons of speed and data generation cannot be done unless Matlab is installed.
(數(shù)據(jù)可以用matlab生成亲怠,提供的analytical的解出alternative的多層球的散射譜)
This codebase is based on Python 2.7, and the pip packages used are shown in the requirements.txt file. To run this on AWS, use AMI ami-52bb0c32, and a p2.xlarge instance.
代碼用的是python2.7寫的;并且用的是GPU來計算某筐;我們沒有GPU所以只用CPU計算武学。requirements中給出了很多packges,我們并沒有全部安裝挡爵。一般是運行起來之后,缺什么包再補充就好了
Installing
- Copy the github repo to your computer, and install the pip requirements.
git clone https://github.com/iguanaus/ScatterNet.git
cd ScatterNet
pip install -r requirements.txt
并沒有全部安裝requirements中的文件甚垦。我們用anaconda創(chuàng)建了一個python2.7的環(huán)境茶鹃,然后再安裝conda install matplotlib
,conda install tensorfolw==1.14
,conda install scikit-learn
三個包就可以了
- Option 1: Fetch the data
cd data
sh fetchData.sh
- Option 2: View and Generate the data
scatter_sim_1_plot_data.m
scatter_sim_2_gen_data.m
有兩種獲取數(shù)據(jù)的方法,Option 1是直接下載數(shù)據(jù)艰亮,Option 2 是用matlab自己生成數(shù)據(jù)
- Option 1: Fetch the models
cd results
sh fetchResults.sh
- Option 2: Train the models (Table I)
sh demo.sh
有兩種獲取model的方法闭翩。一種是作者訓練好了的可以直接下載(option 1),另一種是用demo.sh的腳本文件調用python自己訓練
- Compare spetrums (Figure 2)
sh demo_compareSpect.sh
- Perform Inverse Design (Figure 3)
sh demo_matchSpect.sh
- Perform Optimization (Figure 4)
sh demo_designSpect.sh
Structure
ScatteringNet_Matlab:
This is the matlab code repository, intended to be run on a cluster or a high performance computer. Depends on matlab.
ScatteringNet_Tensorflow:
This is the tensorflow/python repository, intended to be run on a computer with a GPU and tensorflow capabilities.
Flow:
- scatter_0_generate_spectrum
Pick the settings for your data in the scatter_0_generate_spectrum. - scatter_1_plot_sample
Run the scatter_1_plot_sample to get an idea of what the data looks like.
Make sure the data set is hollistics enough/has interesting features within it.
Save these graphs, so you have an idea of what the data looks like.
plotLoss.py is your friend.
Use the pullFiles.sh script to pull the data locally from the server. - scatter_2_generate_train
Once you have that, run the scatter_2_generate_train on a cluster
I recommend first changing the settings, then pushing it to the server. - scatter_net_1_train
Once you have the data, run the scatter_net_1_train to train the neural network on a GPU.
Graph the loss. - scatter_net_2_compareSpects
Once you have the trained neural network, run the scatter_net_2_compareSpects.py to sample some spects and see what they are.
Run plotSpects.py to see what these spectrums look like. - scatter_3_generate_single_test
Pick a spectrum, generate the data, move it over to the other repository. - scatter_net_3_matchSpect
See how it matches the spectrum. - scatter_4_graph_geometry
See how it did - scatter_net_4_design.py
Pick an optimal figure of merit, and then run this. - scatter_5_graph_desired
Graph the desired on top.
Contributing
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- Hat tip to anyone who's code was used
- Inspiration
- etc
Scatter Net
'.\|/.'
(\ /)
- -O- -
(/ \)
,'/|\'.
MIT Department of Physics. All rights reserved.
Version 1.0 - 06/10/2017
Produced and used by John Peurifoy. Assistance and guidance provided by: Li Jing, Yichen Shen, and Yi Yang. Updates and code fixes provided by Samuel Kim.
A product of a collaboration between Max Tegmark's and Marin Soljacic's group.
Originally created 04/24/2017