| |
| """MagNet 2.0 |
| |
| Automatically generated by Colab. |
| |
| Original file is located at |
| https://colab.research.google.com/drive/1n4ADxn-u0nAkYm6mKMzzhiH1vl97qImr |
| """ |
|
|
|
|
|  |
|
|
| import torch |
| import torch.nn as nn |
| import torch.optim as optim |
| import matplotlib.pyplot as plt |
|
|
| wealth_distribution = torch.randn(32, 24, 1) |
| target_direction = torch.randn(32, 24, 1) |
|
|
| class WealthTransferModelWithVPN(nn.Module): |
| def __init__(self, input_size, hidden_size, lstm_hidden_size, output_size, vpn_size): |
| super(WealthTransferModelWithVPN, self).__init__() |
| self.fc1 = nn.Linear(input_size, hidden_size) |
| self.relu = nn.ReLU() |
|
|
| self.lstm = nn.LSTM(hidden_size, lstm_hidden_size, batch_first=True) |
|
|
| self.fc2 = nn.Linear(lstm_hidden_size, output_size) |
|
|
| self.vpn_layer = nn.Linear(output_size, vpn_size) |
| self.decrypt_layer = nn.Linear(vpn_size, output_size) |
|
|
| def forward(self, x, target): |
| x = torch.cat((x, target), dim=1) |
|
|
| x = self.relu(self.fc1(x)) |
|
|
| x, _ = self.lstm(x) |
|
|
| x = self.fc2(x) |
|
|
| encrypted_output = torch.sigmoid(self.vpn_layer(x)) |
|
|
| decrypted_output = self.decrypt_layer(encrypted_output) |
|
|
| return decrypted_output |
|
|
| input_size = wealth_distribution[-1] + target_direction.shape[-1] |
| hidden_size = 64 |
| lstm_hidden_size = 32 |
| output_size = wealth_distribution.shape[-1] |
| vpn_size = 128 |
|
|
| model = WealthTransferWithVPN(input_size, hidden_sizse, lstm_hidden_size, vpn_size) |
|
|
|
|
| with torch.no_grad(): |
| output_signal = model(wealth_distribution, target_direction) |
|
|
| wealth_waveform = output_signal[0].squeeze().numpy() |
|
|
| hours = list(range(24)) |
|
|
| plt.figure(figsize=(10, 5)) |
| plt.plot(hours, wealth_waveform, label='Wealth Transfer Signal over 24 hours', marker='o') |
| plt.title('Wealth Transfer Signal in 24-Hour Intervals') |
| plt.xlabel('Hour of the Day') |
| plt.ylabel('Wealth Signal Intensity') |
| plt.xticks(hours) |
| plt.grid(True) |
| plt.legend() |
| plt.show() |
| |
|
|
|
|