Inverse design using neural network(nanoparticle)---Read Me

本文介绍一下对一篇用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.
(数据可以用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

  1. 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创建了一个python2.7的环境,然后再安装conda install matplotlib,conda install tensorfolw==1.14,conda install scikit-learn三个包就可以了

  1. Option 1: Fetch the data
cd data
sh fetchData.sh
  1. Option 2: View and Generate the data
scatter_sim_1_plot_data.m
scatter_sim_2_gen_data.m

有两种获取数据的方法,Option 1是直接下载数据,Option 2 是用matlab自己生成数据

  1. Option 1: Fetch the models
cd results
sh fetchResults.sh
  1. Option 2: Train the models (Table I)
sh demo.sh

有两种获取model的方法。一种是作者训练好了的可以直接下载(option 1),另一种是用demo.sh的脚本文件调用python自己训练

  1. Compare spetrums (Figure 2)
sh demo_compareSpect.sh
  1. Perform Inverse Design (Figure 3)
sh demo_matchSpect.sh
  1. 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:

  1. scatter_0_generate_spectrum
    Pick the settings for your data in the scatter_0_generate_spectrum.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. scatter_3_generate_single_test
    Pick a spectrum, generate the data, move it over to the other repository.
  7. scatter_net_3_matchSpect
    See how it matches the spectrum.
  8. scatter_4_graph_geometry
    See how it did
  9. scatter_net_4_design.py
    Pick an optimal figure of merit, and then run this.
  10. 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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,242评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,769评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,484评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,133评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,007评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,080评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,496评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,190评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,464评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,549评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,330评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,205评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,567评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,889评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,160评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,475评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,650评论 2 335

推荐阅读更多精彩内容