1 Star 0 Fork 0

zhoub86/wireless_dl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
receiver.py 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
gouthamvgk 提交于 2019-04-11 01:58 . change class
import torch
import torch.nn as nn
import numpy as np
from torch import optim
import torch.nn.functional as F
import random as rn
import matplotlib.pyplot as plt
import os
class receiver_4(nn.Module):
def __init__(self, num_sym, num_chan, hidden_neurons=50):
super(receiver_4, self).__init__()
self.num_symbols = num_sym
self.num_channels = num_chan
self.lin3 = nn.Linear(self.num_channels*2, hidden_neurons)
self.lin4 = nn.Linear(hidden_neurons, self.num_symbols)
self.lin5 = nn.Linear(self.num_symbols, self.num_symbols)
self.softmax = nn.Softmax(dim=1)
def load_state(self, lin3, lin4, lin5):
self.lin3.load_state_dict(lin3.state_dict())
self.lin4.load_state_dict(lin4.state_dict())
self.lin5.load_state_dict(lin5.state_dict())
def forward(self, inp):
rec_out = self.lin3(inp)
chan_out = F.relu(rec_out)
rec_out = self.lin4(rec_out)
rec_out = F.relu(rec_out)
rec_out = self.lin5(rec_out)
rec_out = self.softmax(rec_out)
return rec_out
class receiver_16(nn.Module):
def __init__(self, num_sym, num_chan, hidden_neurons=100):
super(receiver_16, self).__init__()
self.num_symbols = num_sym
self.num_channels = num_chan
self.lin3 = nn.Linear(self.num_channels*2, hidden_neurons)
self.lin4 = nn.Linear(hidden_neurons, self.num_symbols)
self.lin5 = nn.Linear(self.num_symbols, self.num_symbols)
self.softmax = nn.Softmax(dim=1)
def load_state(self, lin3, lin4, lin5):
self.lin3.load_state_dict(lin3.state_dict())
self.lin4.load_state_dict(lin4.state_dict())
self.lin5.load_state_dict(lin5.state_dict())
def forward(self, inp):
rec_out = self.lin3(inp)
chan_out = F.tanh(rec_out)
rec_out = self.lin4(rec_out)
rec_out = F.tanh(rec_out)
rec_out = self.lin5(rec_out)
rec_out = self.softmax(rec_out)
return rec_out
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zhoub86/wireless_dl.git
git@gitee.com:zhoub86/wireless_dl.git
zhoub86
wireless_dl
wireless_dl
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385