我想使用带有 bilstm 层的 RNN,并使用 pytorch 进行蛋白质嵌入。它适用于线性层,但当我使用 Bilstm 时,出现运行时错误。抱歉,如果不清楚,这是我的第一篇出版物,如果有人可以帮助我,我将不胜感激。
from collections import Counter, OrderedDict
from typing import Optional
import numpy as np
import pytorch_lightning as pl
import torch
import torch.nn.functional as F # noqa
from deepchain import log
from sklearn.model_selection import train_test_split
from sklearn.utils.class_weight import compute_class_weight
from torch import Tensor, nn
num_layers=2
hidden_size=256
from torch.utils.data import DataLoader, TensorDataset
def classification_dataloader_from_numpy(
x: np.ndarray, y: np.array, batch_size: int = 32
) -> DataLoader:
"""Build a dataloader from numpy for classification problem
This dataloader …Run Code Online (Sandbox Code Playgroud)