Open TiankaiHang opened 1 month ago
flow matching | logSNR 分布
import numpy as np import matplotlib.pyplot as plt def sech(x): return 1 / np.cosh(x) def new_function(x): return np.exp(x/2) / (2 * (1 + np.exp(x/2))**2) # 创建 λ 值的范围 lambda_values = np.linspace(-10, 10, 1000) # 计算两个函数的值 y1 = sech(lambda_values / 2) / (2 * np.pi) y2 = new_function(lambda_values) # 创建图表 plt.figure(figsize=(12, 6)) plt.plot(lambda_values, y1, label='sech(λ/2) / (2π)') plt.plot(lambda_values, y2, label='e^(λ/2) / [2(1 + e^(λ/2))^2]') plt.title('Comparison of Two Functions') plt.xlabel('λ') plt.ylabel('Function Value') plt.legend() plt.grid(True) # 添加 x 轴和 y 轴 plt.axhline(y=0, color='k', linestyle='-', linewidth=0.5) plt.axvline(x=0, color='k', linestyle='-', linewidth=0.5) # 保存图表 plt.savefig('function_comparison.png', dpi=300, bbox_inches='tight') plt.close() print("图表已保存为 'function_comparison.png'")
flow matching | logSNR 分布