ion (x_FM) (m(t) = 0 for t < 0).
时间: 2024-05-31 15:07:21 浏览: 7
The Fourier transform of the current i(t) is given by:
I(f) = X_FM * M(f)
Where X_FM is the Fourier transform of the FM modulating signal and M(f) is the Fourier transform of the message signal. Since the message signal is zero for t < 0, its Fourier transform is given by:
M(f) = ∫[0,∞] m(t) e^(-j2πft) dt
= ∫[0,∞] 0 e^(-j2πft) dt
= 0
Therefore, the Fourier transform of i(t) simplifies to:
I(f) = X_FM * 0
= 0
This means that the FM signal does not have any frequency components other than those present in the modulating signal. In other words, the FM signal is a frequency-shifted version of the modulating signal, with no additional harmonics or sidebands.
相关问题
def train_loop(): step = 0 ax = [] ay = [] plt.ion() PASS_NUM = n_epochs for pass_id in range(PASS_NUM): total_loss_pass = 0 for data in train_reader(): avg_loss_value, = exe.run( fluid.default_main_program(), feed= feeder.feed(data), fetch_list=[avg_loss]) total_loss_pass += avg_loss_value ax.append(pass_id) ay.append(total_loss_pass) plt.clf() plt.plot(ax, ay) plt.pause(0.01) plt.ioff() step += 1 display.clear_output(wait=True) fluid.io.save_inference_model(SAVE_DIRNAME, ['x'], [prediction], exe) train_loop()
这段代码是一个使用 PaddlePaddle 框架进行训练的循环。具体来说,它包含以下步骤:
1. 定义了一个名为 `train_loop` 的函数,表示训练循环。
2. 初始化一些变量,包括 `step` 记录当前训练步数,`ax` 和 `ay` 用于绘制训练过程中的损失曲线,`plt.ion()` 用于打开 pyplot 的交互模式。
3. 循环执行 `PASS_NUM` 次训练,其中 `PASS_NUM` 是训练轮数。在每一轮训练中,遍历训练数据集 `train_reader()` 中的每个样本,计算平均损失值 `avg_loss_value`,并累加到 `total_loss_pass` 中。
4. 将当前轮数 `pass_id` 和累加的平均损失值 `total_loss_pass` 分别添加到 `ax` 和 `ay` 中,用于绘制损失曲线。
5. 使用 `plt.clf()` 清空之前的图像,再使用 `plt.plot(ax, ay)` 绘制当前的损失曲线,使用 `plt.pause(0.01)` 暂停一段时间,使图像得以显示。
6. 使用 `plt.ioff()` 关闭交互模式,`step` 加 1,使用 `display.clear_output(wait=True)` 清空输出界面,进入下一轮训练。
7. 训练结束后,使用 `fluid.io.save_inference_model()` 将训练好的模型保存到指定路径 `SAVE_DIRNAME` 中。
import torch import torch.nn as nn import numpy as np import matplotlib.pyplot as plt from torch import autograd """ 用神经网络模拟微分方程,f(x)'=f(x),初始条件f(0) = 1 """ class Net(nn.Module): def __init__(self, NL, NN): # NL n个l(线性,全连接)隐藏层, NN 输入数据的维数, # NL是有多少层隐藏层 # NN是每层的神经元数量 super(Net, self).__init__() self.input_layer = nn.Linear(1, NN) self.hidden_layer = nn.Linear(NN,int(NN/2)) ## 原文这里用NN,我这里用的下采样,经过实验验证,“等采样”更优。更多情况有待我实验验证。 self.output_layer = nn.Linear(int(NN/2), 1) def forward(self, x): out = torch.tanh(self.input_layer(x)) out = torch.tanh(self.hidden_layer(out)) out_final = self.output_layer(out) return out_final net=Net(4,20) # 4层 20个 mse_cost_function = torch.nn.MSELoss(reduction='mean') # Mean squared error 均方误差求 optimizer = torch.optim.Adam(net.parameters(),lr=1e-4) # 优化器 def ode_01(x,net): y=net(x) y_x = autograd.grad(y, x,grad_outputs=torch.ones_like(net(x)),create_graph=True)[0] return y-y_x # y-y' = 0 # requires_grad=True).unsqueeze(-1) plt.ion() # 动态图 iterations=200000 for epoch in range(iterations): optimizer.zero_grad() # 梯度归0 ## 求边界条件的损失函数 x_0 = torch.zeros(2000, 1) y_0 = net(x_0) mse_i = mse_cost_function(y_0, torch.ones(2000, 1)) # f(0) - 1 = 0 ## 方程的损失函数 x_in = np.random.uniform(low=0.0, high=2.0, size=(2000, 1)) pt_x_in = autograd.Variable(torch.from_numpy(x_in).float(), requires_grad=True) # x 随机数 pt_y_colection=ode_01(pt_x_in,net) pt_all_zeros= autograd.Variable(torch.from_numpy(np.zeros((2000,1))).float(), requires_grad=False) mse_f=mse_cost_function(pt_y_colection, pt_all_zeros) # y-y' = 0 loss = mse_i + mse_f loss.backward() # 反向传播 optimizer.step() # 优化下一步。This is equivalent to : theta_new = theta_old - alpha * derivative of J w.r.t theta if epoch%1000==0: y = torch.exp(pt_x_in) # y 真实值 y_train0 = net(pt_x_in) # y 预测值 print(epoch, "Traning Loss:", loss.data) print(f'times {epoch} - loss: {loss.item()} - y_0: {y_0}') plt.cla() plt.scatter(pt_x_in.detach().numpy(), y.detach().numpy()) plt.scatter(pt_x_in.detach().numpy(), y_train0.detach().numpy(),c='red') plt.pause(0.1)
这是一段 Python 代码,主要是在导入一些库和定义一个神经网络模型类 "Net"。代码中导入了 torch、torch.nn、numpy 和 matplotlib.pyplot 库,并在 "Net" 类中进行了一些初始化。代码还提到了一个微分方程:f(x)' = f(x), 初始条件f(0) = 1, 用神经网络模拟。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)