神经纳米光学项目

想想怎么在工位的电脑把代码跑通?

  1. 装一个虚拟的Python环境
    https://www.tensorflow.org/install/pip?hl=zh-cn
python3 -m venv --system-site-packages ./venv
source ./venv/bin/activate  # sh, bash, or zsh

pip install tensorflow
https://www.tensorflow.org/install/pip?hl=zh-cn
  1. 想切换python环境
    出现的问题:
    解决办法:
    https://github.com/pyenv/pyenv/wiki#suggested-build-environment
sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

2.np.int已经弃用的问题

Traceback (most recent call last):
 File "/home/wangfeng/len/Neural_Nano-Optics/train.py", line 268, in <module>
   main()
 File "/home/wangfeng/len/Neural_Nano-Optics/train.py", line 265, in main
   train(args)
 File "/home/wangfeng/len/Neural_Nano-Optics/train.py", line 141, in train
   params = solver.initialize_params(args)
 File "/home/wangfeng/len/Neural_Nano-Optics/metasurface/solver.py", line 68, in initialize_params
   dim = np.int(2 * (np.size(params['theta_base']) - 1) - 1)
 File "/home/wangfeng/.pyenv/versions/3.9.6/lib/python3.9/site-packages/numpy/__init__.py", line 324, in __getattr__
   raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
   https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

解决方案:
1:直接把所有的num.int更改为int(把solver中的文件更改了就可以往下运行)
3. 运行出现如下问题

2023-11-06 14:47:16.266900: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-11-06 14:47:16.266933: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-11-06 14:47:16.266953: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-11-06 14:47:16.273688: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-11-06 14:47:16.273916: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-11-06 14:47:17.199122: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow_addons/utils/tfa_eol_msg.py:23: UserWarning: 

TensorFlow Addons (TFA) has ended development and introduction of new features.
TFA has entered a minimal maintenance and release mode until a planned end of life in May 2024.
Please modify downstream libraries to take dependencies from other repositories in our TensorFlow community (e.g. Keras, Keras-CV, and Keras-NLP). 

For more information see: https://github.com/tensorflow/addons/issues/2807 

 warnings.warn(
Namespace(train_dir='./training/data/train/', test_dir='./training/data/test/', save_dir='./training/ckpt/', save_freq=50, log_freq=20, ckpt_dir=None, max_to_keep=2, loss_mode='L1', batch_weights=[1.0, 1.0, 1.0], Norm_loss_weight=1.0, P_loss_weight=0.1, Spatial_loss_weight=0.0, vgg_layers='block2_conv2,block3_conv2', steps=1000000000, aug_rotate=True, real_psf='./experimental/data/psf/psf.npy', psf_mode='SIM_PSF', conv_mode='SIM', conv='patch_size', do_taper=True, offset=True, normalize_psf=True, theta_base=[0.0, 5.0, 10.0, 15.0], num_coeffs=8, use_general_phase=False, metasurface='log_asphere', s1=0.0009, s2=0.0014, alpha=270.176968209, target_wavelength=5.11e-07, bound_val=1000.0, a_poisson=4e-05, b_sqrt=1e-05, mag=8.1, Phase_iters=0, Phase_lr=0.005, Phase_beta1=0.9, G_iters=10, G_lr=0.0001, G_beta1=0.9, G_network='FP', snr_opt=False, snr_init=3.0)
def phase_func(x,a2,a4,a6,a8,a10,a12,a14,a16): return a2*x**2 + a4*x**4 + a6*x**6 + a8*x**8 + a10*x**10 + a12*x**12 + a14*x**14 + a16*x**16
Image width: 720
PSF width: 144
Load width: 432
Network width: 288
Out width: 144
2023-11-06 14:47:18.593611: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 783595104 exceeds 10% of free system memory.
2023-11-06 14:47:18.762003: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 783595104 exceeds 10% of free system memory.
2023-11-06 14:47:18.936329: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 783595104 exceeds 10% of free system memory.
2023-11-06 14:47:19.046757: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 783595104 exceeds 10% of free system memory.
2023-11-06 14:47:19.162077: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 783595104 exceeds 10% of free system memory.
Initial Phase: [-4.82957979e+02  1.43471675e+02 -6.03414766e+01  2.97263591e+01
-1.53686807e+01  7.17143053e+00 -2.42156961e+00  4.08067083e-01]
Image width: 720
Traceback (most recent call last):
 File "/home/wangfeng/len/Neural_Nano-Optics/train.py", line 268, in <module>
   main()
 File "/home/wangfeng/len/Neural_Nano-Optics/train.py", line 265, in main
   train(args)
 File "/home/wangfeng/len/Neural_Nano-Optics/train.py", line 234, in train
   train_ds = iter(train_dataset_sim(params['out_width'], params['load_width'], args))
 File "/home/wangfeng/len/Neural_Nano-Optics/dataset.py", line 22, in train_dataset_sim
   ds = ds.map(load_fn, num_parallel_calls=tf.data.experimental.AUTOTUNE)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2268, in map
   return map_op._map_v2(
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/data/ops/map_op.py", line 40, in _map_v2
   return _ParallelMapDataset(
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/data/ops/map_op.py", line 148, in __init__
   self._map_func = structured_function.StructuredFunctionWrapper(
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/data/ops/structured_function.py", line 265, in __init__
   self._function = fn_factory()
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/eager/polymorpip install --upgrade pipphic_function/polymorphic_function.py", line 1222, in get_concrete_function
   concrete = self._get_concrete_function_garbage_collected(*args, **kwargs)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py", line 1192, in _get_concrete_function_garbage_collected
   self._initialize(args, kwargs, add_initializers_to=initializers)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py", line 694, in _initialize
   self._concrete_variable_creation_fn = tracing_compilation.trace_function(
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compilation.py", line 178, in trace_function
   concrete_function = _maybe_define_function(
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compilation.py", line 284, in _maybe_define_function
   concrete_function = _create_concrete_function(
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compilation.py", line 308, in _create_concrete_function
   traced_func_graph = func_graph_module.func_graph_from_py_func(
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/framework/func_graph.py", line 1059, in func_graph_from_py_func
   func_outputs = python_func(*func_args, **func_kwargs)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py", line 597, in wrapped_fn
   out = weak_wrapped_fn().__wrapped__(*args, **kwds)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/data/ops/structured_function.py", line 231, in wrapped_fn
   ret = wrapper_helper(*args)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/data/ops/structured_function.py", line 161, in wrapper_helper
   ret = autograph.tf_convert(self._func, ag_ctx)(*nested_args)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py", line 693, in wrapper
   raise e.ag_error_metadata.to_exception(e)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py", line 690, in wrapper
   return converted_call(f, args, kwargs, options=options)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py", line 439, in converted_call
   result = converted_f(*effective_args, **kwargs)
 File "/tmp/__autograph_generated_fileznv548sq.py", line 33, in tf__load_fn
   image = ag__.converted_call(ag__.ld(tf).image.resize_with_crop_or_pad, (ag__.ld(image), ag__.ld(image_width_padded), ag__.ld(image_width_padded)), None, fscope)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py", line 377, in converted_call
   return _call_unconverted(f, args, kwargs, options)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py", line 460, in _call_unconverted
   return f(*args)
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
   raise e.with_traceback(filtered_tb) from None
 File "/home/wangfeng/len/Neural_Nano-Optics/venv/lib/python3.9/site-packages/tensorflow/python/framework/op_def_library.py", line 589, in _ExtractInputsAndAttrs
   raise TypeError(
TypeError: in user code:

   File "/home/wangfeng/len/Neural_Nano-Optics/dataset.py", line 15, in load_fn  *
       image = tf.image.resize_with_crop_or_pad(image, image_width_padded, image_width_padded)

   TypeError: Input 'y' of 'Minimum' Op has type int32 that does not match type int64 of argument 'x'.
  1. 数据类型不匹配的问题
 TypeError: Input 'y' of 'Minimum' Op has type int32 that does not match type int64 of argument 'x'.

这个错误和上面的还有点不一样,没有找到GreaterEqual的函数定义

TypeError: Input 'y' of 'GreaterEqual' Op has type int64 that does not match type int32 of argument 'x'.
  1. root下执行的错误(应该不是root下执行才有的问题)
2023-11-06 16:40:17.935654: W tensorflow/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 783595104 exceeds 10% of free system memory.
Killed

每次只能运行一次就得重启才能重新运行

重新建一个虚拟的Python环境

教程:https://blog.51cto.com/u_16213456/7511357

将之前的虚拟环境进行删除

rm -r venv

安装tensorflow

刚开始安装的是2.2.0

出现如下问题:

ImportError: cannot import name 'keras_tensor'

####解决方法
安装更高的版本
为什么系统自动安装的是2.6.2呢?

安装pip出现的问题

(venv) wangfeng@wangfeng-HP-ProDesk-680-G6-PCI-Microtower-PC:~/len/Neural_Nano-Optics$ sudo apt-get install python-pip
[sudo] password for wangfeng: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  grim ibus-data ibus-gtk4 libflashrom1 libftdi1-2 libllvm13 python-pkginfo-doc python3-cachecontrol python3-cachy python3-cleo
  python3-clikit python3-crashtest python3-distlib python3-filelock python3-ibus-1.0 python3-msgpack python3-packaging python3-pastel
  python3-pip-whl python3-pkginfo python3-platformdirs python3-poetry-core python3-pylev python3-requests-toolbelt
  python3-setuptools-whl python3-shellingham python3-tomlkit python3-wheel python3-wheel-whl
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python-pkg-resources python-setuptools python2 python2-minimal python2.7
  python2.7-minimal
Suggested packages:
  python-setuptools-doc python2-doc python-tk python2.7-doc
Recommended packages:
  python2-dev
The following packages will be REMOVED:
  python3-pip python3-poetry python3-virtualenv
The following NEW packages will be installed:
  libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python-pip python-pkg-resources python-setuptools python2 python2-minimal
  python2.7 python2.7-minimal
0 upgraded, 10 newly installed, 3 to remove and 3 not upgraded.
Need to get 5,488 kB of archives.
After this operation, 14.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] yy
Get:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 libpython2.7-minimal amd64 2.7.18-13ubuntu1.1 [347 kB]
Get:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 python2.7-minimal amd64 2.7.18-13ubuntu1.1 [1,394 kB]
Get:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 python2-minimal amd64 2.7.18-3 [20.8 kB]
Get:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 libpython2.7-stdlib amd64 2.7.18-13ubuntu1.1 [1,977 kB]
Get:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 python2.7 amd64 2.7.18-13ubuntu1.1 [250 kB]
Get:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 libpython2-stdlib amd64 2.7.18-3 [7,432 B]
Get:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 python2 amd64 2.7.18-3 [9,098 B]
Get:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 python-pkg-resources all 44.1.1-1.2ubuntu0.22.04.1 [128 kB]
Get:9 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 python-setuptools all 44.1.1-1.2ubuntu0.22.04.1 [334 kB]
Get:10 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 python-pip all 20.3.4+dfsg-4 [1,021 kB]
Fetched 5,488 kB in 1s (3,967 kB/s)    
(Reading database ... 259308 files and directories currently installed.)
Removing python3-poetry (1.1.12+dfsg-1ubuntu1) ...
Removing python3-virtualenv (20.13.0+ds-2) ...
Removing python3-pip (22.0.2+dfsg-1ubuntu0.3) ...
Selecting previously unselected package libpython2.7-minimal:amd64.
(Reading database ... 258289 files and directories currently installed.)
Preparing to unpack .../0-libpython2.7-minimal_2.7.18-13ubuntu1.1_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.18-13ubuntu1.1) ...
Selecting previously unselected package python2.7-minimal.
Preparing to unpack .../1-python2.7-minimal_2.7.18-13ubuntu1.1_amd64.deb ...
Unpacking python2.7-minimal (2.7.18-13ubuntu1.1) ...
Selecting previously unselected package python2-minimal.
Preparing to unpack .../2-python2-minimal_2.7.18-3_amd64.deb ...
Unpacking python2-minimal (2.7.18-3) ...
Selecting previously unselected package libpython2.7-stdlib:amd64.
Preparing to unpack .../3-libpython2.7-stdlib_2.7.18-13ubuntu1.1_amd64.deb ...
Unpacking libpython2.7-stdlib:amd64 (2.7.18-13ubuntu1.1) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../4-python2.7_2.7.18-13ubuntu1.1_amd64.deb ...
Unpacking python2.7 (2.7.18-13ubuntu1.1) ...
Selecting previously unselected package libpython2-stdlib:amd64.
Preparing to unpack .../5-libpython2-stdlib_2.7.18-3_amd64.deb ...
Unpacking libpython2-stdlib:amd64 (2.7.18-3) ...
Setting up libpython2.7-minimal:amd64 (2.7.18-13ubuntu1.1) ...
Setting up python2.7-minimal (2.7.18-13ubuntu1.1) ...
Linking and byte-compiling packages for runtime python2.7...
Setting up python2-minimal (2.7.18-3) ...
Selecting previously unselected package python2.
(Reading database ... 259032 files and directories currently installed.)
Preparing to unpack .../python2_2.7.18-3_amd64.deb ...
Unpacking python2 (2.7.18-3) ...
Selecting previously unselected package python-pkg-resources.
Preparing to unpack .../python-pkg-resources_44.1.1-1.2ubuntu0.22.04.1_all.deb ...
Unpacking python-pkg-resources (44.1.1-1.2ubuntu0.22.04.1) ...
Selecting previously unselected package python-setuptools.
Preparing to unpack .../python-setuptools_44.1.1-1.2ubuntu0.22.04.1_all.deb ...
Unpacking python-setuptools (44.1.1-1.2ubuntu0.22.04.1) ...
Selecting previously unselected package python-pip.
Preparing to unpack .../python-pip_20.3.4+dfsg-4_all.deb ...
Unpacking python-pip (20.3.4+dfsg-4) ...
Setting up libpython2.7-stdlib:amd64 (2.7.18-13ubuntu1.1) ...
Setting up python2.7 (2.7.18-13ubuntu1.1) ...
Setting up libpython2-stdlib:amd64 (2.7.18-3) ...
Setting up python2 (2.7.18-3) ...
Setting up python-pkg-resources (44.1.1-1.2ubuntu0.22.04.1) ...
Setting up python-setuptools (44.1.1-1.2ubuntu0.22.04.1) ...
Setting up python-pip (20.3.4+dfsg-4) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
(venv) wangfeng@wangfeng-HP-ProDesk-680-G6-PCI-Microtower-PC:~/len/Neural_Nano-Optics$ pip --version
bash: /home/wangfeng/len/Neural_Nano-Optics/venv/bin/pip: No such file or directory
(venv) wangfeng@wangfeng-HP-ProDesk-680-G6-PCI-Microtower-PC:~/len/Neural_Nano-Optics$ cd sudo apt-get install python3-pip
bash: cd: too many arguments
(venv) wangfeng@wangfeng-HP-ProDesk-680-G6-PCI-Microtower-PC:~/len/Neural_Nano-Optics$ sudo apt-get install python3-pip
[sudo] password for wangfeng: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  grim ibus-data ibus-gtk4 libflashrom1 libftdi1-2 libllvm13 libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib
  python-pkg-resources python-pkginfo-doc python-setuptools python2 python2-minimal python2.7 python2.7-minimal python3-cachecontrol
  python3-cachy python3-cleo python3-clikit python3-crashtest python3-distlib python3-filelock python3-ibus-1.0 python3-msgpack
  python3-packaging python3-pastel python3-pip-whl python3-pkginfo python3-platformdirs python3-poetry-core python3-pylev
  python3-requests-toolbelt python3-setuptools-whl python3-shellingham python3-tomlkit python3-wheel-whl
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  python-pip
The following NEW packages will be installed:
  python3-pip
0 upgraded, 1 newly installed, 1 to remove and 4 not upgraded.
Need to get 1,305 kB of archives.
After this operation, 2,151 kB of additional disk space will be used.
Do you want to continue? [Y/n] yy
Get:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates/universe amd64 python3-pip all 22.0.2+dfsg-1ubuntu0.3 [1,305 kB]
Fetched 1,305 kB in 1s (1,445 kB/s)    
(Reading database ... 259679 files and directories currently installed.)
Removing python-pip (20.3.4+dfsg-4) ...
Selecting previously unselected package python3-pip.
(Reading database ... 259178 files and directories currently installed.)
Preparing to unpack .../python3-pip_22.0.2+dfsg-1ubuntu0.3_all.deb ...
Unpacking python3-pip (22.0.2+dfsg-1ubuntu0.3) ...
Setting up python3-pip (22.0.2+dfsg-1ubuntu0.3) ...
Processing triggers for man-db (2.10.2-1) ...

新建虚拟环境

##需要安装的包
TensorFlow >= 2.2
TensorFlow Probability = 0.10.0
TensorFlow Addons
1:怎么把显卡安排上,如果没有找到代码中修改为cpu

2:内存的问题怎么解决

相关的技术

vscode连接远程服务器

https://www.matpool.com/supports/doc-vscode-connect-matpool/#2-%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5%E9%85%8D%E7%BD%AE

云服务器的环境

在这里插入图片描述

在这里插入图片描述

对比下配置的环境和文章中的环境算力的区别

在这里插入图片描述

下一步的解决方案:尝试用学校的集群

在vscode中运行test.ipynb代码

切换成之前设置的环境

在这里插入图片描述

❯ conda install -n Neural_Nano-Optics-master ipykernel --update-deps --force-reinstall
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: | Solving environment| done
done


==> WARNING: A newer version of conda exists. <==
  current version: 23.3.1
  latest version: 24.1.2

Please update conda by running

    $ conda update -n base -c defaults conda

Or to minimize the number of packages updated during conda update use

     conda install conda=24.1.2



## Package Plan ##

  environment location: /Users/wf/opt/anaconda3/envs/Neural_Nano-Optics-master

  added / updated specs:
    - appnope
    - backcall
    - ca-certificates
    - certifi
    - decorator
    - ipykernel
    - ipython
    - ipython_genutils
    - jedi
    - jupyter_client
    - jupyter_core
    - libcxx
    - libffi
    - libsodium
    - ncurses
    - openssl
    - parso
    - pexpect
    - pickleshare
    - pip
    - prompt-toolkit
    - ptyprocess
    - pygments
    - python-dateutil
    - python=3.6
    - pyzmq
    - readline
    - setuptools
    - six
    - sqlite
    - tk
    - tornado
    - traitlets
    - wcwidth
    - wheel
    - xz
    - zeromq
    - zlib


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    appnope-0.1.2              |py36hecd8cb5_1001          10 KB
    ca-certificates-2023.12.12 |       hecd8cb5_0         127 KB
    entrypoints-0.3            |           py36_0          12 KB
    intel-openmp-2023.1.0      |   ha357a0b_43548         638 KB
    ipykernel-5.3.4            |   py36h5ca1d4c_0         179 KB
    ipython-7.16.1             |   py36h5ca1d4c_0        1001 KB
    jedi-0.17.0                |           py36_0         775 KB
    jupyter_client-7.1.2       |     pyhd3eb1b0_0          93 KB
    jupyter_core-4.8.1         |   py36hecd8cb5_0          74 KB
    nest-asyncio-1.5.1         |     pyhd3eb1b0_0          10 KB
    openssl-1.1.1w             |       hca72f7f_0         2.8 MB
    pyzmq-22.2.1               |   py36h23ab428_1         416 KB
    tornado-6.1                |   py36h9ed2024_0         588 KB
    traitlets-4.3.3            |   py36hecd8cb5_0         140 KB
    xz-5.4.5                   |       h6c40b1e_0         366 KB
    ------------------------------------------------------------
                                           Total:         7.2 MB

The following NEW packages will be INSTALLED:

  backcall           pkgs/main/noarch::backcall-0.2.0-pyhd3eb1b0_0 
  jedi               pkgs/main/osx-64::jedi-0.17.0-py36_0 
  nest-asyncio       pkgs/main/noarch::nest-asyncio-1.5.1-pyhd3eb1b0_0 
  parso              pkgs/main/noarch::parso-0.8.3-pyhd3eb1b0_0 
  pip                pkgs/main/osx-64::pip-21.2.2-py36hecd8cb5_0 
  prompt-toolkit     pkgs/main/noarch::prompt-toolkit-3.0.20-pyhd3eb1b0_0 

The following packages will be REMOVED:

  prompt_toolkit-1.0.15-py_1
  python_abi-3.6-2_cp36m
  simplegeneric-0.8.1-py_1

The following packages will be UPDATED:

  appnope            conda-forge::appnope-0.1.2-py36h79c66~ --> pkgs/main::appnope-0.1.2-py36hecd8cb5_1001 
  certifi             conda-forge::certifi-2016.9.26-py36_0 --> pkgs/main::certifi-2021.5.30-py36hecd8cb5_0 
  intel-openmp                      2023.1.0-ha357a0b_43547 --> 2023.1.0-ha357a0b_43548 
  ipython                 conda-forge::ipython-5.8.0-py36_1 --> pkgs/main::ipython-7.16.1-py36h5ca1d4c_0 
  jupyter_client     conda-forge/osx-64::jupyter_client-5.~ --> pkgs/main/noarch::jupyter_client-7.1.2-pyhd3eb1b0_0 
  jupyter_core       conda-forge/noarch::jupyter_core-4.5.~ --> pkgs/main/osx-64::jupyter_core-4.8.1-py36hecd8cb5_0 
  pexpect            conda-forge/osx-64::pexpect-4.8.0-py3~ --> pkgs/main/noarch::pexpect-4.8.0-pyhd3eb1b0_3 
  ptyprocess         conda-forge::ptyprocess-0.7.0-pyhd3de~ --> pkgs/main::ptyprocess-0.7.0-pyhd3eb1b0_2 
  pyzmq              conda-forge::pyzmq-19.0.2-py36hd52991~ --> pkgs/main::pyzmq-22.2.1-py36h23ab428_1 
  six                  conda-forge::six-1.16.0-pyh6c4a22f_0 --> pkgs/main::six-1.16.0-pyhd3eb1b0_1 
  wcwidth            conda-forge::wcwidth-0.1.9-pyh9f0ad1d~ --> pkgs/main::wcwidth-0.2.5-pyhd3eb1b0_0 
  xz                                       5.4.2-h6c40b1e_0 --> 5.4.5-h6c40b1e_0 

The following packages will be SUPERSEDED by a higher-priority channel:

  ca-certificates    conda-forge::ca-certificates-2024.2.2~ --> pkgs/main::ca-certificates-2023.12.12-hecd8cb5_0 
  decorator          conda-forge::decorator-5.1.1-pyhd8ed1~ --> pkgs/main::decorator-5.1.1-pyhd3eb1b0_0 
  entrypoints        conda-forge/noarch::entrypoints-0.4-p~ --> pkgs/main/osx-64::entrypoints-0.3-py36_0 
  ipykernel          conda-forge::ipykernel-5.5.5-py36h495~ --> pkgs/main::ipykernel-5.3.4-py36h5ca1d4c_0 
  ipython_genutils   conda-forge::ipython_genutils-0.2.0-p~ --> pkgs/main::ipython_genutils-0.2.0-pyhd3eb1b0_1 
  libsodium          conda-forge::libsodium-1.0.18-hbcb390~ --> pkgs/main::libsodium-1.0.18-h1de35cc_0 
  openssl            conda-forge::openssl-1.1.1w-h8a1eda9_0 --> pkgs/main::openssl-1.1.1w-hca72f7f_0 
  pickleshare        conda-forge::pickleshare-0.7.5-py_1003 --> pkgs/main::pickleshare-0.7.5-pyhd3eb1b0_1003 
  pygments           conda-forge::pygments-2.12.0-pyhd8ed1~ --> pkgs/main::pygments-2.11.2-pyhd3eb1b0_0 
  python-dateutil    conda-forge::python-dateutil-2.8.2-py~ --> pkgs/main::python-dateutil-2.8.2-pyhd3eb1b0_0 
  tornado            conda-forge::tornado-6.1-py36hfa26744~ --> pkgs/main::tornado-6.1-py36h9ed2024_0 
  traitlets          conda-forge/noarch::traitlets-4.3.3-p~ --> pkgs/main/osx-64::traitlets-4.3.3-py36hecd8cb5_0 


Proceed ([y]/n)? y


Downloading and Extracting Packages
                                                                                                                                                                    
                                                                                                                                                                    
Preparing transaction: done                                                                                                                                         
Verifying transaction: done                                                                                                                                         
Executing transaction: done 

启动jupyter的过程出现错误

2024-02-27 21:53:31.151 [error] Supported versions are 3.7 and above.

安装tensorflow-gpu2.6.0出现错误,转为安装tensorflow2.6.0

❯ pip install tensorflow-addons==0.19.0
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tensorflow-addons==0.19.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b9/03/d2731201d9119e47849ac33f0fa0332a970fc2267f7ea4a802dce5c8e5c7/tensorflow_addons-0.19.0-cp37-cp37m-macosx_10_14_x86_64.whl (12.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.6/12.6 MB 4.6 MB/s eta 0:00:00
Requirement already satisfied: packaging in /Users/wf/opt/anaconda3/envs/Neural_Nano-Optics-master/lib/python3.7/site-packages (from tensorflow-addons==0.19.0) (22.0)
Collecting typeguard>=2.7
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bb/bd/dc7da80c95c920ee2b575e64901b5962ca4a1271b5f3cf6c27242aa0aafc/typeguard-4.1.2-py3-none-any.whl (33 kB)
Requirement already satisfied: importlib-metadata>=3.6 in /Users/wf/opt/anaconda3/envs/Neural_Nano-Optics-master/lib/python3.7/site-packages (from typeguard>=2.7->tensorflow-addons==0.19.0) (6.7.0)
Collecting typing-extensions>=4.7.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Requirement already satisfied: zipp>=0.5 in /Users/wf/opt/anaconda3/envs/Neural_Nano-Optics-master/lib/python3.7/site-packages (from importlib-metadata>=3.6->typeguard>=2.7->tensorflow-addons==0.19.0) (3.15.0)
Installing collected packages: typing-extensions, typeguard, tensorflow-addons
  Attempting uninstall: typing-extensions
    Found existing installation: typing-extensions 3.7.4.3
    Uninstalling typing-extensions-3.7.4.3:
      Successfully uninstalled typing-extensions-3.7.4.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow 2.6.0 requires typing-extensions~=3.7.4, but you have typing-extensions 4.7.1 which is incompatible.

公司电脑配置环境(按照飞书上的配置也是ok的)

DIFFERENTIABLE CAMERAS AND DISPLAYS

本课程介绍可微波传播方法,并描述其在相机 和显示器上的应用。具体来说,显示器和相机的光学组件被视为可微层,类似于神经网络层,可以与成像/显示系统的计算块联合训练。

作者

曾学森是普林斯顿大学Felix Heide教授指导的博士研究生,他在卡内基梅隆大学获得电气和计算机工程学士学位。伊桑的研究主要集中在光学,机器学习,优化计算成像和全息显示。他曾在Adobe Research的Marc Levoy团队和Aswin Sankaranarayanan教授的图像科学实验室实习。伊桑在纳米光学方面的工作已被光学与光子学新闻重点报道,并在Vice新闻,BBC, NSF发现文件和Jimmy Fall等国际媒体上有专题报道

introduce

我们将引入全新的光学系统,将笨重的相机缩小到盐粒大小。为此,我们将介绍一些方法,通过计算和光学上的障碍来实现这一努力。听众将了解严格的耦合波分析(RCWA)和快速逼近RCWA的方法,同时保持端到端可微性。观众还将了解将传统滤波器与现代机器学习相结合的最先进的反卷积方法,以及如何将这些方法与元表面仿真块集成在一起。

limitation

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

基于特征的图像矫正

在这里插入图片描述

设计阶段要优化参数,然后进行制造

在这里插入图片描述

使用真实的psf来进行微调

在这里插入图片描述

衡量标准

在这里插入图片描述

反卷积方法

在这里插入图片描述
However, they can often accentuate sensor noise as shown here.
Furthermore, these algorithms have limited design freedom because they
don’t employ very many free parameters.
In contrast, recent works in deep learning have shown that neural
networks can also perform deconvolution and that their rich design space can
enable learning of a wide variety of features that facilitate reconstruction.
However, their performance on unseen examples is oftentimes
inconsistent and these methods cannot handle very large aberrations.

In order to remedy this, we combine these two domains.
We propose a feature based deconvolution method that employs a traditional inverse
filter together with neural networks for feature extraction and refinement.
This combination allows us to learn effective features that facilitate
the inverse filter’s deconvolution while still utilizing the knowledge of

调试代码

args.py


solver.py

以下参数的作用

# Units and tensor dimensions.
  params['nanometers'] = 1E-9
  params['degrees']    = np.pi / 180

  # Upsampling for Fourier optics propagation
  params['upsample']      = 1
  params['normalize_psf'] = args.normalize_psf

# 这部分的逻辑
if args.offset:
      dim = np.int(2 * (np.size(params['theta_base']) - 1) - 1)

# image_width
# Square input image width based on max field angle (20 degrees)
  image_width = params['f'] * np.tan(20.0 * np.pi / 180.0) * np.sqrt(2) # 因为视场角是相对于对角线计算的。
  image_width = image_width * params['magnification'] / params['sensor_pixel']
  params['image_width'] = np.int(2*dim * np.ceil(image_width / (2*dim) ))

parser.add_argument('--metasurface'      , type=str  , default='log_asphere', help='Metasurface initialization')

parser.add_argument('--offset'       , type=str2bool, default=True, help='True to use offset convolution mode')
Initial Phase: [-4.82957980e+02  1.43471694e+02 -6.03416497e+01  2.97270925e+01
 -1.53703397e+01  7.17348910e+00 -2.42289121e+00  4.08410202e-01]
Image width: 720

训练阶段

训练G

疑问

1:初始相位的拟合

p_fit, _ = scp_opt.curve_fit(params['phase_func'], x, phase_slice, bounds=(-args.bound_val, args.bound_val))

是否需要进行Phase_iters

vscode打开tensorboard

https://blog.csdn.net/qq_44874691/article/details/125841108

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值