exp_fmt.c

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #include <stdio.h>

void main(void)
 {
   float value = 1.23456;

   printf ("%12.1e/n", value);
   printf ("%12.3e/n", value);
   printf ("%12.5e/n", value);
 }

build_module.sh: BUILD_TIME=$(date +%Y-%m-%dT%H:%M:%S) build_flags+=("--copt=-DKERNEL_BUILD_TIME=\\\"${BUILD_TIME}\\\"") ./tools/bazel --output_user_root="${DEFAULT_CACHE_DIR}" run "${build_flags[@]}" \ "$build_target" -- --dist_dir="${OUT_DIR}/${EXT_MOD_REL}" load("//build/kernel/kleaf:honor_modules.bzl", "define_honor_modules") micro_dump_qcom.bzl: def define_qcom(): define_honor_modules( name = "microdump", out_opt = "CONFIG_HN_MICRODUMP", target_opt = ["canoe"], srcs = native.glob([ "micro_dump.c", "irq_dump.c", "data_print.c", "policy.c", "process_dump.c", "register_dump.c", "stack_dump.c", "bitflip.c", "lock_dump.c", "gki_utils.c", "undef_dump.c", "panic_analyse.c", "micro_meminfo.c", "*.h", ]), conditional_srcs = { "CONFIG_HN_MICRODUMP_ELF": { True: ["elf_dump.c",], }, "CONFIG_HN_MICRODUMP_PANIC_RECORD": { True: ["panic_dump.c",], }, "CONFIG_HN_MICRODUMP_IOW_CHECK": { True: ["iow_check.c",], }, }, dep_modules = [ "//soc-repo:%b/drivers/soc/qcom/debug_symbol", "//soc-repo:%b/drivers/soc/qcom/minidump", ], kconfig = "Kconfig", visibility = ["//visibility:public"], copts = [ '-DKERNEL_BUILD_TIME="\\"$(KERNEL_BUILD_TIME)\\""' ], ) micro_dump.c: static int panic_callback(struct notifier_block *self, unsigned long cmd, void *ptr) { unsigned long type = DIE_TYPE_UNKNOWN; const char *reason = ptr; char *linux_banner; #if IS_ENABLED(CONFIG_QCOM_MINIDUMP) check_microdump_state(); #endif if (!g_microdump_enable) { MD_PRINT("The function is disable!\n"); return NOTIFY_DONE; } if (atomic_inc_and_test(&g_has_panic)) { if (g_exp_info.error_type == DIE_TYPE_UNKNOWN || g_exp_info.error_type == SUB_TYPE_OTHER_DIE) { type = analyse_panic_type(reason); micro_dump_reason_set(reason, type); } /* no die flow, direct panic flow, so need save regs by asm manully */ if (atomic_read(&g_has_die) == -1) { md_get_regs(&g_exp_info.regs); g_exp_info.task = current; MD_PRINT( "%s, task.comm:%s, task.pid:%d, stack:0x%px\n", __func__, g_exp_info.task->comm, g_exp_info.task->pid, (unsigned long *)g_exp_info.task->stack); show_pclr(&g_exp_info.regs); } g_exp_info.panic_cpu = raw_smp_processor_id(); MD_INFO("%s, error type is: 0x%lx\n", __func__, type); linux_banner = (void *)gki_symbol_lookup_name("linux_banner"); if (linux_banner != NULL) MD_INFO("%s\n", linux_banner); MD_INFO("kernel build time:%s\n", KERNEL_BUILD_TIME); } #define MD_INFO(fmt, ...) pr_info(LOG_TAG fmt, ##__VA_ARGS__)
最新发布
11-26
def model_train(batchsize,channel_SNR,noise_init,nl_factor,eq_flag,epsilon,earlystop_epoch):## start training # constellation annimation fig1, ax1 = plt.subplots(figsize=(4,5)) Epoch_list = [] Loss_list = [] min_loss = 1e10 max_GMI = 0 patience = 0 # initialize the noise noise_exp = noise_init[np.newaxis,:] GS_flag_len = len(GS_flag) iter_per_GS_flag = iterations//GS_flag_len GS_flag_index = 0 GS_flag_now = GS_flag[GS_flag_index] PS_flag_now = PS_flag[GS_flag_index] # create two saving figures fig=plt.figure() ax_1 = fig.add_subplot(121) ax_2 = fig.add_subplot(122,projection='3d') for epoch in range(iterations): total_loss = 0 total_loss_Eq = 0 GMI_mean = 0 NGMI_mean = 0 if GS_flag_len>1 and (epoch+1)%iter_per_GS_flag == 0 and (GS_flag_index+1)<GS_flag_len: GS_flag_index += 1 GS_flag_now = GS_flag[GS_flag_index] PS_flag_now = PS_flag[GS_flag_index] for batch in range(0,batchsize): ## get the channel impairments from the Rx data noise_tf = tf.cast(noise_exp, dtype=dtype) ## apply the channel impairments and train the model batch_loss,batch_loss_Eq,NGMI,GMI,entropy_S,p_s,norm_constellation,x = train_step(channel_SNR,noise_tf,GS_flag_now,PS_flag_now,eq_flag,epsilon) ## save the training data x for transmission Tx = get_Tx(channel_SNR,epsilon)[-1] ## Will be substituted by the real channel impairments in the Experiment Rx = channel_ISI_NL(Tx,channel_SNR_db1,channel_FIR,nl_factor=nl_factor,ch_type=channel_type) ## after the transmission, get the Rx data and new noise noise_exp = Rx - Tx noise_exp = noise_exp[np.newaxis,:] ## calculate the loss total_loss_Eq += batch_loss_Eq total_loss += batch_loss GMI_mean += GMI NGMI_mean += NGMI total_loss = total_loss / batchsize total_loss_Eq = total_loss_Eq / batchsize GMI_mean = GMI_mean / batchsize NGMI_mean = NGMI_mean/ batchsize Epoch_list.append(epoch+1) Loss_list.append(total_loss.numpy()) if total_loss < min_loss: min_loss = total_loss manager_Loss.save(checkpoint_number=epoch+1) print('[INFO] New Loss = %.6f, Save new model named ./model_free_training_checkpoints/V6_ckpt_Loss-%d.index'%(min_loss,epoch+1)) if GMI_mean > max_GMI: patience = 0 max_GMI = GMI_mean manager_MI.save(checkpoint_number=epoch+1) print('[INFO] New GMI = %.6f, NGMI = %.6f, Save new model named ./model_free_training_checkpoints/V6_ckpt_MI-%d.index'%(max_GMI,NGMI_mean,epoch+1)) else: patience += 1 if patience > earlystop_epoch: manager_Loss.save(checkpoint_number=epoch+1) print('[INFO] Early stop at epoch %d, loss = %.6f, GMI = %.6f'%(epoch+1,total_loss,GMI_mean)) break if (epoch+1)%displayStep == 0 or epoch == 0: # np.savetxt('training_data_Tx.txt',Tx,fmt='%f') ## draw constellation X = np.real(norm_constellation) Y = np.imag(norm_constellation) ax1.scatter(X,Y,c=cons_colors) ax1.axis('square') ax1.set_title('Constellation Optimization') fig1.canvas.draw() fig1.canvas.flush_events() print('[DEBUG] epoch:{:3d}/{:2d} | loss: {:.2f} | loss_Eq: {:.4f} | GMI: {:.4f} | NGMI: {:.4f} | entropy_S: {:.4f}' .format(epoch+1, iterations, total_loss.numpy(), total_loss_Eq.numpy(), GMI_mean.numpy(), NGMI.numpy(),entropy_S)) ## plot the distribution of PS and GS X, Y=X.ravel(), Y.ravel() bottom=np.zeros_like(X) P=p_s.numpy().ravel() ## specific the colormap width=height=2/np.sqrt(M+5) dz = P offset = dz + np.abs(dz.min()) fracs = offset.astype(float)/offset.max() norm = colors.Normalize(fracs.min(), fracs.max()) color_values = plt.cm.viridis(norm(fracs.tolist())) ## draw ax_1.cla() ax_1.set_title('Constellation Tx') ax_1.scatter(X,Y,s=80) ax_1.axis('square') ax_2.cla() ax_2.bar3d(X, Y, bottom, width, height, P, shade=True, color=color_values,edgecolor='black')# ax_2.set_xlabel('X') ax_2.set_ylabel('Y') ax_2.set_zlabel('Z(value)') # ax_2.set_title('GMI = %.2f, NGMI = %.2f'%(GMI_mean.numpy(),NGMI_mean.numpy())) fig.set_size_inches(20,10) plt.savefig('./figures/32QAM/PS_distribution_epoch%d.png'%(epoch+1),dpi=300) manager_Loss.save(checkpoint_number=epoch+1) Epoch_list = np.reshape(np.stack(Epoch_list),-1) Loss_list = np.reshape(np.stack(Loss_list),-1) return Epoch_list,Loss_list 根据修改后的tran_step对应修改上述代码
08-19
from pythtb import * import numpy as np import matplotlib.pyplot as plt # 定义晶格和轨道 lat = [[1.0, 0.0], [0.0, 1.0]] orb = [[0.0, 0.0], [0.5, 0.0], [0.0, 0.5]] # 增加参数分辨率 t2_values = np.linspace(0.1, 1.0, 300) # t2 的范围 phi_values = np.linspace(0, 2 * np.pi, 300) # phi 的范围 gap_values = np.zeros((len(t2_values), len(phi_values))) # 用于存储能隙大小 # 遍历每个参数值 for i, t2 in enumerate(t2_values): for j, phi in enumerate(phi_values): # 创建模型 my_model = tb_model(2, 2, lat, orb) # 定义跃迁矩阵元 t1 = 1.0 t2_complex = t2 * np.exp(1.j * phi) t3 = 0.2 # 设置跃迁 my_model.set_hop(t1, 0, 1, [0, 0]) my_model.set_hop(t1, 0, 2, [0, 0]) my_model.set_hop(t1, 0, 1, [-1, 0]) my_model.set_hop(t1, 0, 2, [0, -1]) my_model.set_hop(t2_complex, 1, 2, [0, 0]) my_model.set_hop(t2_complex, 2, 1, [-1, 0]) my_model.set_hop(t2_complex, 1, 2, [1, -1]) my_model.set_hop(t2_complex, 2, 1, [0, 1]) my_model.set_hop(t3, 0, 0, [1, 0]) my_model.set_hop(t3, 0, 0, [0, 1]) my_model.set_hop(t3, 1, 1, [1, 0]) my_model.set_hop(t3, 1, 1, [0, 1]) my_model.set_hop(t3, 2, 2, [1, 0]) my_model.set_hop(t3, 2, 2, [0, 1]) # 定义动量路径 path = [[0.0, 0.0], [0.5, 0.0], [0.5, 0.5], [0.0, 0.0]] nk = 201 # 增加k点数量 (k_vec, k_dist, k_node) = my_model.k_path(path, nk) # 计算能带 evals = my_model.solve_all(k_vec) # 计算能隙 gap = np.min(evals[1] - evals[0]) gap_values[i, j] = gap # 创建网格 T2, PHI = np.meshgrid(t2_values, phi_values) # 绘制相图 fig, ax = plt.subplots(figsize=(8, 6)) c = ax.pcolormesh(T2, PHI/np.pi, gap_values.T, cmap='viridis', shading='auto') fig.colorbar(c, ax=ax, label='Gap Size') # 添加等高线(能隙为0) contour = ax.contour(T2, PHI/np.pi, gap_values.T, levels=[0], colors='red', linewidths=2) ax.clabel(contour, inline=True, fontsize=10, fmt="Gap=0") # 其余设置 ax.set_xlabel('$ t_2$', fontsize=12) ax.set_ylabel('$\phi / \pi$', fontsize=12) ax.set_title('Phase Diagram with Gap Contour', fontsize=14) ax.set_ylim(0, 2) # 添加陈数标注 ax.text(0.8, 1.45, 'C=-1', color='red', va='center') ax.text(0.8, 0.6, 'C=1', color='red', va='center') ax.text(0.85, 0.1, 'C=1', color='red', va='center') ax.text(0.85, 1.8, 'C=-1', color='red', va='center') plt.tight_layout() plt.show() 等高线变成白色
07-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值