This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, torch, torch.nn as nn, torch.utils.data as data, torchvision as tv, torch.nn.functional as F | |
import lightning as L | |
from pathlib import Path | |
def find_latest_checkpoint(artifacts_dir): | |
# Logic holds only for default TensorBoardLogger | |
versions_dir = Path(artifacts_dir, "lightning_logs") | |
if not versions_dir.is_dir(): | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lightning as L | |
import torch | |
import torch.nn.functional as F | |
from lightning.pytorch.demos import Transformer, WikiText2 | |
from torch.utils.data import DataLoader, random_split | |
import os | |
from time import sleep | |
class LanguageModel(L.LightningModule): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright The Lightning AI team. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# main.py | |
# ! pip install torchvision | |
import torch, torch.nn as nn, torch.utils.data as data, torchvision as tv, torch.nn.functional as F | |
import lightning as L | |
# -------------------------------- | |
# Step 1: Define a LightningModule | |
# -------------------------------- | |
# A LightningModule (nn.Module subclass) defines a full *system* | |
# (ie: an LLM, diffusion model, autoencoder, or simple image classifier). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright The Lightning AI team. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tarfile | |
import torch | |
import torchvision.transforms.functional as fn | |
from PIL import Image | |
from tqdm import tqdm as tq | |
FOLDER_IN = "/data/imagenet" | |
FOLDER_OUT = "/data/imagenet-final" | |
FILENAME = "ILSVRC2012_img_{}.tar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This gist describes the steps process to add a private bucket on Lightning AI | |
# 1. Go on your AWS account and search for IAM | |
# 2. From the left tab, create a policy on AWS with the following JSON. Replace the bucket with yours. | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "PermissionForObjectOperations", | |
"Effect": "Allow", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import ReactDOM from 'react-dom/client'; | |
import './index.css'; | |
function calculateWinner(squares) { | |
const lines = [ | |
[0, 1, 2], | |
[3, 4, 5], | |
[6, 7, 8], | |
[0, 3, 6], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import torch | |
from torch.utils.data import DataLoader, Dataset | |
from pytorch_lightning import LightningModule, Trainer | |
class RandomDataset(Dataset): | |
def __init__(self, size, length): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path as ops | |
from lightning import LightningApp | |
from lightning_hpo import HPOCloudCompute, Sweep | |
from lightning_hpo.algorithm.optuna import OptunaAlgorithm | |
from lightning_hpo.distributions.distributions import Categorical, IntUniform, LogUniform, Uniform | |
app = LightningApp( | |
Sweep( |
NewerOlder