超材料参数提取程序及matlab实现方法

版权申诉
5星 · 超过95%的资源 1 下载量 201 浏览量 更新于2024-10-05 收藏 4KB RAR 举报
资源摘要信息: "Metamaterial-Parameters.rar" 该资源是关于超材料(metamaterials)的一个MATLAB编程包,包含了用于提取超材料参数的程序。超材料是一类具有特殊电磁、声学或热力学属性的人造材料,其特性往往无法通过自然材料直接获得。这类材料能够实现负折射、隐形等现象,因此在物理、材料科学和工程领域中受到了广泛关注。 在超材料的研制过程中,参数提取是一个关键步骤,它涉及到确定材料的电磁特性,如介电常数、磁导率和导磁率等。这些参数通常通过实验手段获得,然后在数值模拟中使用这些参数来预测材料的行为。MATLAB作为一种高效的数值计算和可视化工具,非常适合于这类复杂计算。 本压缩包中包含了以下两个文件: - EMPEx.m:这是一个MATLAB脚本文件,很可能是实现超材料参数提取的核心算法。该脚本应该包含了数据分析和参数提取的逻辑,可能涉及到信号处理、线性代数、数值优化等高级数学操作。 - readme.txt:这是一个文本文件,通常用来提供关于软件包的简要说明、安装指南和使用方法。用户应该仔细阅读该文件,了解如何正确安装和使用该MATLAB程序,包括对系统环境的要求、程序依赖以及如何运行程序等。 提到的“参考的文献”暗示这个程序可能是基于特定学术研究的实现。这些文献为程序的正确性和有效性提供了理论基础,同时能够帮助用户了解提取参数的具体方法和技术细节。在学术研究和工程应用中,参考文献的引用是非常重要的,它为方法的原创性和科学性提供保证。 本资源的标签“matlab_metamaterial”,“metamaterial”,“超材料”,“超材料参数”,“超材料提取”进一步明确了资源的范围和重点。标签中的“matlab_metamaterial”和“metamaterial”强调了使用MATLAB语言和技术来处理超材料相关问题。而“超材料参数”和“超材料提取”则直接指出了该程序的主要功能,即参数提取。 从这些信息中可以看出,该资源对那些从事超材料研究的工程师、科学家、学生等提供了宝贵的实践工具,能够帮助他们更高效地进行超材料的参数分析和提取工作。对于初学者来说,这些程序可能还包含了对超材料参数化建模的教育意义,能够帮助他们理解超材料的复杂性质以及参数对材料行为的影响。 总结来说,该资源是对超材料参数提取领域的一份重要贡献,通过MATLAB平台的封装,为研究者和工程师提供了强大的计算工具。对于学习和应用超材料的科研人员来说,该资源无疑是一个值得探索的宝贵资源。

import tensorflow as tf from im_dataset import train_image, train_label, test_image, test_label from AlexNet8 import AlexNet8 from baseline import baseline from InceptionNet import Inception10 from Resnet18 import ResNet18 import os import matplotlib.pyplot as plt import argparse import numpy as np parse = argparse.ArgumentParser(description="CVAE model for generation of metamaterial") hyperparameter_set = parse.add_argument_group(title='HyperParameter Setting') dim_set = parse.add_argument_group(title='Dim setting') hyperparameter_set.add_argument("--num_epochs",type=int,default=200,help="Number of train epochs") hyperparameter_set.add_argument("--learning_rate",type=float,default=4e-3,help="learning rate") hyperparameter_set.add_argument("--image_size",type=int,default=16*16,help="vector size of image") hyperparameter_set.add_argument("--batch_size",type=int,default=16,help="batch size of database") dim_set.add_argument("--z_dim",type=int,default=20,help="dim of latent variable") dim_set.add_argument("--feature_dim",type=int,default=32,help="dim of feature vector") dim_set.add_argument("--phase_curve_dim",type=int,default=41,help="dim of phase curve vector") dim_set.add_argument("--image_dim",type=int,default=16,help="image size: [image_dim,image_dim,1]") args = parse.parse_args() def preprocess(x, y): x = tf.io.read_file(x) x = tf.image.decode_png(x, channels=1) x = tf.cast(x,dtype=tf.float32) /255. x1 = tf.concat([x, x], 0) x2 = tf.concat([x1, x1], 1) x = x - 0.5 y = tf.convert_to_tensor(y) y = tf.cast(y,dtype=tf.float32) return x2, y train_db = tf.data.Dataset.from_tensor_slices((train_image, train_label)) train_db = train_db.shuffle(100).map(preprocess).batch(args.batch_size) test_db = tf.data.Dataset.from_tensor_slices((test_image, test_label)) test_db = test_db.map(preprocess).batch(args.batch_size) model = ResNet18([2, 2, 2, 2]) model.build(input_shape=(args.batch_size, 32, 32, 1)) model.compile(optimizer = tf.keras.optimizers.Adam(lr = 1e-3), loss = tf.keras.losses.MSE, metrics = ['MSE']) checkpoint_save_path = "./checkpoint/InceptionNet_im_3/checkpoint.ckpt" if os.path.exists(checkpoint_save_path+'.index'): print('------------------load the model---------------------') model.load_weights(checkpoint_save_path) cp_callback = tf.keras.callbacks.ModelCheckpoint(filepath=checkpoint_save_path,save_weights_only=True,save_best_only=True) history = model.fit(train_db, epochs=500, validation_data=test_db, validation_freq=1, callbacks=[cp_callback]) model.summary() acc = history.history['loss'] val_acc = history.history['val_loss'] plt.plot(acc, label='Training MSE') plt.plot(val_acc, label='Validation MSE') plt.title('Training and Validation MSE') plt.legend() plt.show()

2023-05-11 上传