{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceType":"competition","sourceId":118765,"databundleVersionId":15231210,"isSourceIdPinned":false}],"dockerImageVersionId":31287,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"pip install torch biopython pandas numpy einops","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-28T08:02:14.284686Z","iopub.execute_input":"2026-02-28T08:02:14.284956Z","iopub.status.idle":"2026-02-28T08:02:17.591837Z","shell.execute_reply.started":"2026-02-28T08:02:14.284935Z","shell.execute_reply":"2026-02-28T08:02:17.591075Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install -q einops","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-28T08:02:17.59348Z","iopub.execute_input":"2026-02-28T08:02:17.593744Z","iopub.status.idle":"2026-02-28T08:02:20.747433Z","shell.execute_reply.started":"2026-02-28T08:02:17.593717Z","shell.execute_reply":"2026-02-28T08:02:20.746624Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import Dataset, DataLoader\nfrom sklearn.model_selection import KFold\nfrom tqdm.auto import tqdm","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-28T08:02:20.748753Z","iopub.execute_input":"2026-02-28T08:02:20.749041Z","iopub.status.idle":"2026-02-28T08:02:20.753691Z","shell.execute_reply.started":"2026-02-28T08:02:20.749004Z","shell.execute_reply":"2026-02-28T08:02:20.75296Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"class RNADataset(Dataset):\n    def __init__(self, df, is_train=True):\n        self.df = df\n        self.is_train = is_train\n        \n    def __len__(self):\n        return len(self.df)\n    \n    def __getitem__(self, idx):\n        seq = torch.tensor(self.df.iloc[idx][\"padded\"], dtype=torch.long)\n        \n        if self.is_train:\n            target = torch.tensor(self.df.iloc[idx].target, dtype=torch.float32)\n            return seq, target\n        \n        return seq","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-28T08:02:20.75538Z","iopub.execute_input":"2026-02-28T08:02:20.755656Z","iopub.status.idle":"2026-02-28T08:02:20.771772Z","shell.execute_reply.started":"2026-02-28T08:02:20.755636Z","shell.execute_reply":"2026-02-28T08:02:20.771191Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"class RNA3DFoldModel(nn.Module):\n    def __init__(self):\n        super().__init__()\n        \n        self.embedding = nn.Embedding(4, 128)\n        \n        encoder_layer = nn.TransformerEncoderLayer(\n            d_model=128,\n            nhead=8,\n            dim_feedforward=256,\n            batch_first=True\n        )\n        \n        self.encoder = nn.TransformerEncoder(encoder_layer, num_layers=4)\n        \n        self.head = nn.Sequential(\n            nn.Linear(128, 256),\n            nn.ReLU(),\n            nn.Linear(256, 3)\n        )\n        \n    def forward(self, x):\n        x = self.embedding(x)\n        x = self.encoder(x)\n        x = self.head(x)\n        return x","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-02-28T08:02:20.773465Z","iopub.execute_input":"2026-02-28T08:02:20.773712Z","iopub.status.idle":"2026-02-28T08:02:20.789978Z","shell.execute_reply.started":"2026-02-28T08:02:20.773691Z","shell.execute_reply":"2026-02-28T08:02:20.789326Z"}},"outputs":[],"execution_count":null}]}