repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/radam.py
""" --- title: Rectified Adam (RAdam) optimizer summary: A simple PyTorch implementation/tutorial of RAdam optimizer. --- # Rectified Adam (RAdam) optimizer This implementation is based on [the official implementation](https://github.com/LiyuanLucasLiu/RAdam) of the paper [On the Variance of the Adaptive Learning Rat...
11,243
38.591549
134
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/adam_warmup_cosine_decay.py
""" --- title: Adam optimizer with warm-up and cosine decay summary: A PyTorch implementation/tutorial of Adam optimizer with warm-up and cosine decay for GPT. --- # Adam Optimizer with Warmup and Cosine Decay This extends [AMSGrad optimizer](adam.html) and adds a warmup stage. """ import math from typing import Dict...
3,679
36.55102
121
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/mnist_experiment.py
""" --- title: MNIST example to test the optimizers summary: This is a simple MNIST example with a CNN model to test the optimizers. --- # MNIST example to test the optimizers """ import torch.nn as nn import torch.utils.data from labml_helpers.module import Module from labml import experiment, tracker from labml.con...
4,063
28.449275
87
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/adam.py
""" --- title: Adam Optimizer summary: A simple PyTorch implementation/tutorial of Adam optimizer --- # Adam Optimizer This is a [PyTorch](https://pytorch.org) implementation of popular optimizer *Adam* from paper [Adam: A Method for Stochastic Optimization](https://arxiv.org/abs/1412.6980v9). *Adam* update is, \b...
8,609
39.046512
118
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/performance_test.py
""" --- title: Test performance of Adam implementations summary: This experiment compares performance of Adam implementations. --- # Performance testing Adam ``` TorchAdam warmup...[DONE] 222.59ms TorchAdam...[DONE] 1,356.01ms MyAdam warmup...[DONE] 119.15ms MyAdam...[DONE] 1,192.89ms ``` [![Open In Colab](https://c...
1,608
27.732143
163
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/__init__.py
""" --- title: Optimizers summary: > A set of PyTorch implementations/tutorials of popular gradient descent based optimizers. Currently includes Adam, AMSGrad and RAdam optimizers. --- # Optimizers ## Optimizer Implementations * [Adam Optimizer](adam.html) * [AMSGrad Optimizer](amsgrad.html) * [Adam Optimizer with ...
8,108
36.892523
112
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/optimizers/configs.py
""" --- title: Configurable optimizer module summary: This implements a configurable module for optimizers. --- # Configurable Optimizer """ from typing import Tuple import torch from labml.configs import BaseConfigs, option, meta_config from labml_nn.optimizers import WeightDecay class OptimizerConfigs(BaseConfi...
4,805
31.693878
90
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/utils/tokenizer.py
from typing import Callable from labml.configs import BaseConfigs, option class TokenizerConfigs(BaseConfigs): """ <a id="OptimizerConfigs"> ## Optimizer Configurations </a> """ tokenizer: Callable = 'character' def __init__(self): super().__init__(_primary='tokenizer') @optio...
970
18.039216
66
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/utils/__init__.py
""" --- title: Utilities summary: A bunch of utility functions and classes --- # Utilities """ import copy from torch.utils.data import Dataset, IterableDataset from labml_helpers.module import M, TypedModuleList def clone_module_list(module: M, n: int) -> TypedModuleList[M]: """ ## Clone Module Make...
1,548
22.830769
116
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/rl/ppo/experiment.py
""" --- title: PPO Experiment with Atari Breakout summary: Annotated implementation to train a PPO agent on Atari Breakout game. --- # PPO Experiment with Atari Breakout This experiment trains Proximal Policy Optimization (PPO) agent Atari Breakout game on OpenAI Gym. It runs the [game environments on multiple proce...
15,265
35.96368
173
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/rl/ppo/__init__.py
""" --- title: Proximal Policy Optimization - PPO summary: > An annotated implementation of Proximal Policy Optimization - PPO algorithm in PyTorch. --- # Proximal Policy Optimization - PPO This is a [PyTorch](https://pytorch.org) implementation of [Proximal Policy Optimization - PPO](https://arxiv.org/abs/1707.0634...
7,536
35.410628
173
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/rl/ppo/gae.py
""" --- title: Generalized Advantage Estimation (GAE) summary: A PyTorch implementation/tutorial of Generalized Advantage Estimation (GAE). --- # Generalized Advantage Estimation (GAE) This is a [PyTorch](https://pytorch.org) implementation of paper [Generalized Advantage Estimation](https://arxiv.org/abs/1506.02438)...
3,032
33.862069
96
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/rl/dqn/experiment.py
""" --- title: DQN Experiment with Atari Breakout summary: Implementation of DQN experiment with Atari Breakout --- # DQN Experiment with Atari Breakout This experiment trains a Deep Q Network (DQN) to play Atari Breakout game on OpenAI Gym. It runs the [game environments on multiple processes](../game.html) to sampl...
9,352
35.968379
109
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/rl/dqn/model.py
""" --- title: Deep Q Network (DQN) Model summary: Implementation of neural network model for Deep Q Network (DQN). --- # Deep Q Network (DQN) Model """ import torch from torch import nn from labml_helpers.module import Module class Model(Module): """ ## Dueling Network ⚔️ Model for $Q$ Values We are ...
3,277
30.219048
106
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/rl/dqn/__init__.py
""" --- title: Deep Q Networks (DQN) summary: > This is a PyTorch implementation/tutorial of Deep Q Networks (DQN) from paper Playing Atari with Deep Reinforcement Learning. This includes dueling network architecture, a prioritized replay buffer and double-Q-network training. --- # Deep Q Networks (DQN) This...
6,291
36.452381
115
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/label_smoothing_loss.py
""" --- title: Label Smoothing Loss summary: > This is an implementation of label smoothing loss, that can be used as an alternative to cross entropy loss for improved accuracy. --- # Label Smoothing Loss """ import matplotlib.pyplot as plt import numpy as np import torch import torch.nn as nn from labml_helpers....
2,210
30.585714
76
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/utils.py
""" --- title: Utilities for Transformer summary: A bunch of utility functions and classes for transformers. --- # Utilities for Transformer """ import torch def subsequent_mask(seq_len): """ ## Subsequent mask to mask out data from future (subsequent) time steps """ mask = torch.tril(torch.ones(seq...
538
18.25
80
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/feed_forward.py
""" --- title: Position-wise Feed-Forward Network (FFN) summary: Documented reusable implementation of the position wise feedforward network. --- # Position-wise Feed-Forward Network (FFN) This is a [PyTorch](https://pytorch.org) implementation of position-wise feedforward network used in transformer. FFN consists ...
3,582
36.715789
107
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/mha.py
""" --- title: Multi-Headed Attention (MHA) summary: > This implements the Multi-Headed Attention used in transformers using PyTorch with explanations. --- # Multi-Headed Attention (MHA) This is a tutorial/implementation of multi-headed attention from paper [Attention Is All You Need](https://arxiv.org/abs/1706.0...
6,881
34.112245
116
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/positional_encoding.py
""" --- title: Fixed Positional Encodings summary: > Implementation with explanation of fixed positional encodings as described in paper Attention is All You Need. --- # Fixed Positional Encodings The positional encoding encodes the position along the sequence into a vector of size `d_model`. \begin{align} PE_{...
2,327
28.468354
102
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/models.py
""" --- title: Transformer Encoder and Decoder Models summary: > These are PyTorch implementations of Transformer based encoder and decoder models, as well as other related modules. --- # Transformer Encoder and Decoder Models """ import math import torch import torch.nn as nn from labml_helpers.module import Mod...
7,999
33.334764
116
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/__init__.py
""" --- title: Transformers summary: > This is a collection of PyTorch implementations/tutorials of transformers and related techniques. --- # Transformers This module contains [PyTorch](https://pytorch.org/) implementations and explanations of original transformer from paper [Attention Is All You Need](https://a...
3,550
35.989583
129
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/configs.py
""" --- title: Configurable Transformer Components summary: These are configurable components that can be re-used quite easily. --- # Configurable Transformer Components """ import copy import torch.nn as nn from labml.configs import BaseConfigs, option, calculate, aggregate from labml_helpers.module import Module f...
10,324
30.574924
114
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/aft/experiment.py
""" --- title: Attention Free Transformer (AFT) Experiment summary: This experiment trains an Attention Free Transformer (AFT) based model on Tiny Shakespeare dataset. --- # [Attention Free Transformer (AFT)](index.html) Experiment This is an annotated PyTorch experiment to train a [AFT model](index.html). This is b...
4,988
29.054217
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/aft/__init__.py
""" --- title: An Attention Free Transformer summary: > This is an annotated implementation/tutorial of the AFT (Attention Free Transformer) in PyTorch. --- # An Attention Free Transformer This is a [PyTorch](https://pytorch.org) implementation of the paper [An Attention Free Transformer](https://papers.labml.ai/pa...
8,600
35.6
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/fast_weights/experiment.py
""" --- title: Train Fast Weights Transformer summary: This is training code with notes for a Fast Weights Transformer. --- # Train Fast Weights Transformer This trains a fast weights transformer model for auto-regression. Here’s a Colab notebook for training a fast weights transformer on Tiny Shakespeare dataset. ...
3,830
31.466102
192
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/fast_weights/token_wise.py
""" --- title: Fast Weight Systems summary: > This is an annotated implementation/tutorial of Linear Transformers Are Secretly Fast Weight Memory Systems in PyTorch. --- """ from typing import Optional import torch from torch import nn from labml_helpers.module import Module from labml_nn.transformers.fast_weight...
4,216
31.19084
95
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/fast_weights/__init__.py
""" --- title: Linear Transformers Are Secretly Fast Weight Memory Systems summary: > This is an annotated implementation/tutorial of Linear Transformers Are Secretly Fast Weight Memory Systems in PyTorch. --- # Fast weights transformer The paper [Linear Transformers Are Secretly Fast Weight Memory Systems in PyT...
12,989
38.483283
192
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/gmlp/experiment.py
""" --- title: Pay Attention to MLPs (gMLP) Experiment summary: This experiment trains a gMLP based model on Tiny Shakespeare dataset. --- # [Pay Attention to MLPs (gMLP)](index.html) Experiment This is an annotated PyTorch experiment to train a [gMLP model](index.html). The paper also applies a Stochastic Depth reg...
3,281
27.293103
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/gmlp/__init__.py
""" --- title: Pay Attention to MLPs (gMLP) summary: > This is an annotated implementation/tutorial of Pay Attention to MLPs (gMLP) in PyTorch. --- # Pay Attention to MLPs (gMLP) This is a [PyTorch](https://pytorch.org) implementation of the paper [Pay Attention to MLPs](https://papers.labml.ai/paper/2105.08050). ...
6,152
37.45625
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/knn/train_model.py
""" --- title: Train Autoregressive Transformer summary: This is training code with notes for a basic auto-regressive transformer. --- # Train Autoregressive Transformer This trains a simple [transformer](../../) model for auto-regression. """ import torch from labml import experiment from labml.configs import optio...
4,481
29.910345
96
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/knn/eval_knn.py
""" --- title: Evaluate k-nearest neighbor language model summary: > This runs the kNN model and merges the kNN results with transformer output to achieve better results than just using the transformer. --- # Evaluate k-nearest neighbor language model """ from typing import Optional, List import faiss import nump...
5,907
36.392405
120
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/knn/__init__.py
""" --- title: k-Nearest Neighbor Language Models summary: > This is a simple PyTorch implementation/tutorial of the paper Generalization through Memorization: Nearest Neighbor Language Models using FAISS. It runs a kNN model on the final transformer layer embeddings to improve the loss of transformer based lan...
1,934
42.977273
107
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/knn/build_index.py
""" --- title: Build FAISS index for k-NN search summary: This builds the FAISS index with the transformer embeddings. --- # Build FAISS index for k-NN search We want to build the index of $\big(f(c_i), w_i\big)$. We store $f(c_i)$ and $w_i$ in memory mapped numpy arrays. We find $f(c_i)$ nearest to $f(c_t)$ using [F...
5,712
35.388535
120
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/xl/experiment.py
""" --- title: Transformer XL Experiment summary: This experiment trains a transformer XL model on tiny Shakespeare dataset. --- # Transformer XL Experiment This is an annotated PyTorch experiment to train a transformer xl model. """ from typing import List import torch import torch.nn as nn from labml.logger import...
8,779
32.257576
102
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/xl/__init__.py
""" --- title: Transformer XL summary: > Documented implementation with explanations of a Transformer-XL model. --- # Transformer XL This is an implementation of [Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context](https://arxiv.org/abs/1901.02860) in [PyTorch](https://pytorch.org). Transfor...
5,422
36.923077
182
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/xl/relative_mha.py
""" --- title: Relative Multi-Headed Attention summary: > Documented implementation with explanations of Relative Multi-Headed Attention from paper Transformer-XL. --- # Relative Multi-Headed Attention This is an implementation of relative multi-headed attention from paper [Transformer-XL: Attentive Language Mode...
6,230
39.72549
110
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/basic/autoregressive_experiment.py
""" --- title: Transformer Auto-Regression Experiment summary: > This trains a simple transformer model on NLP auto-regression. --- # Transformer Auto-Regression Experiment This trains a simple transformer introduced in [Attention Is All You Need](https://arxiv.org/abs/1706.03762) on an NLP auto-regression task (wi...
4,430
27.587097
110
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/switch/experiment.py
""" --- title: Switch Transformer Experiment summary: This experiment trains a small switch transformer on tiny Shakespeare dataset. --- # Switch Transformer Experiment This is an annotated PyTorch experiment to train a switch transformer. """ import torch import torch.nn as nn from labml import experiment, tracker...
8,280
34.088983
111
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/switch/__init__.py
""" --- title: Switch Transformer summary: > This is an annotated implementation/tutorial a miniature version of Switch Transformer in PyTorch. --- # Switch Transformer This is a miniature [PyTorch](https://pytorch.org) implementation of the paper [Switch Transformers: Scaling to Trillion Parameter Models with Simp...
9,937
40.932489
186
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/fnet/experiment.py
""" --- title: FNet Experiment summary: This experiment trains a FNet based model on AG News dataset. --- # [FNet](index.html) Experiment This is an annotated PyTorch experiment to train a [FNet model](index.html). This is based on [general training loop and configurations for AG News classification task](../../expe...
4,328
26.75
118
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/fnet/__init__.py
""" --- title: "FNet: Mixing Tokens with Fourier Transforms" summary: > This is an annotated implementation/tutorial of FNet in PyTorch. --- # FNet: Mixing Tokens with Fourier Transforms This is a [PyTorch](https://pytorch.org) implementation of the paper [FNet: Mixing Tokens with Fourier Transforms](https://arxiv....
3,492
36.967391
120
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/feedback/experiment.py
""" --- title: Train Feedback Transformer summary: This is training code with notes for a feedback transformer. --- # Train Feedback Transformer This trains a [feedback transformer](index.html) model for auto-regression. You can pick the original feedback transformer or the new version where the keys and values are p...
4,885
33.167832
188
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/feedback/__init__.py
""" --- title: Feedback Transformer summary: > This is an annotated implementation/tutorial the Feedback Transformer in PyTorch. --- # Feedback Transformer This is a [PyTorch](https://pytorch.org) implementation of the paper [Accessing Higher-level Representations in Sequential Transformers with Feedback Memory](ht...
19,846
36.376648
188
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/gpt/__init__.py
""" --- title: GPT summary: > Implementation/tutorial of GPT model and training code. --- # GPT This is a tutorial/implementation of [OpenAI GPT architecture](https://openai.com/blog/better-language-models/) in [PyTorch](https://pytorch.org). We got a bunch of implementation details from [minGPT](https://github.com...
8,665
31.456929
183
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/mlm/experiment.py
""" --- title: Masked Language Model Experiment summary: This experiment trains Masked Language Model (MLM) on Tiny Shakespeare dataset. --- # [Masked Language Model (MLM)](index.html) Experiment This is an annotated PyTorch experiment to train a [Masked Language Model](index.html). """ from typing import List impor...
10,183
31.641026
110
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/mlm/__init__.py
""" --- title: Masked Language Model summary: > This is an annotated implementation/tutorial of the Masked Language Model in PyTorch. --- # Masked Language Model (MLM) This is a [PyTorch](https://pytorch.org) implementation of the Masked Language Model (MLM) used to pre-train the BERT model introduced in the paper...
6,396
44.049296
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/compressive/experiment.py
""" --- title: Compressive Transformer Experiment summary: This experiment trains a compressive transformer model on tiny Shakespeare dataset. --- # Compressive Transformer Experiment This is an annotated PyTorch experiment to train a compressive transformer model. """ from typing import List, Tuple, NamedTuple impo...
13,020
35.886686
120
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/compressive/__init__.py
""" --- title: Compressive Transformer summary: > Documented implementation with explanations of a Compressive Transformer model. --- # Compressive Transformer This is an implementation of [Compressive Transformers for Long-Range Sequence Modelling](https://arxiv.org/abs/1911.05507) in [PyTorch](https://pytorch.o...
13,740
39.774481
191
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/vit/experiment.py
""" --- title: Train a Vision Transformer (ViT) on CIFAR 10 summary: > Train a Vision Transformer (ViT) on CIFAR 10 --- # Train a [Vision Transformer (ViT)](index.html) on CIFAR 10 [![View Run](https://img.shields.io/badge/labml-experiment-brightgreen)](https://app.labml.ai/run/8b531d9ce3dc11eb84fc87df6756eb8f) ""...
2,861
28.505155
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/vit/__init__.py
""" --- title: Vision Transformer (ViT) summary: > A PyTorch implementation/tutorial of the paper "An Image Is Worth 16x16 Words: Transformers For Image Recognition At Scale" --- # Vision Transformer (ViT) This is a [PyTorch](https://pytorch.org) implementation of the paper [An Image Is Worth 16x16 Words: Transfor...
8,071
36.198157
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/mlp_mixer/experiment.py
""" --- title: MLP Mixer experiment summary: This experiment trains MLP Mixer on Tiny Shakespeare dataset. --- # [MLP Mixer](index.html) Experiment This is an annotated PyTorch experiment to train a [MLP Mixer Model](index.html). """ from labml import experiment from labml.configs import option from labml_nn.transfo...
3,030
25.12931
86
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/mlp_mixer/__init__.py
""" --- title: "MLP-Mixer: An all-MLP Architecture for Vision" summary: > This is an annotated implementation/tutorial of MLP-Mixer: An all-MLP Architecture for Vision in PyTorch. --- # MLP-Mixer: An all-MLP Architecture for Vision This is a [PyTorch](https://pytorch.org) implementation of the paper [MLP-Mixer: An ...
2,956
35.506173
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/glu_variants/experiment.py
""" --- title: Gated Linear Units and Variants summary: > Train an auto-regressive transformer with Gated Linear Units and variants for the position-wise feedforward network (FFN). --- # Gated Linear Units and Variants This trains a simple [transformer](../../) model for auto-regression. We try different variants...
4,296
31.067164
100
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/transformers/glu_variants/simple.py
""" --- title: Gated Linear Units and Variants summary: > Train an auto-regressive transformer with Gated Linear Units and variants for the position-wise feedforward network (FFN). --- # Gated Linear Units and Variants This trains a simple [transformer](../../) model for auto-regression. We try different variants...
11,935
37.503226
188
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/distillation/large.py
""" --- title: Train a large model on CIFAR 10 summary: > Train a large model on CIFAR 10 for distillation. --- # Train a large model on CIFAR 10 This trains a large model on CIFAR 10 for [distillation](index.html). [![View Run](https://img.shields.io/badge/labml-experiment-brightgreen)](https://app.labml.ai/run/...
2,558
26.815217
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/distillation/small.py
""" --- title: Train a small model on CIFAR 10 summary: > Train a small model on CIFAR 10 to test how much distillation benefits. --- # Train a small model on CIFAR 10 This trains a small model on CIFAR 10 to test how much [distillation](index.html) benefits. [![View Run](https://img.shields.io/badge/labml-experi...
2,498
27.078652
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/distillation/__init__.py
""" --- title: Distilling the Knowledge in a Neural Network summary: > PyTorch implementation and tutorial of the paper Distilling the Knowledge in a Neural Network. --- # Distilling the Knowledge in a Neural Network This is a [PyTorch](https://pytorch.org) implementation/tutorial of the paper [Distilling the Kno...
8,572
33.849593
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/dcgan/__init__.py
""" --- title: Deep Convolutional Generative Adversarial Networks (DCGAN) summary: A simple PyTorch implementation/tutorial of Deep Convolutional Generative Adversarial Networks (DCGAN). --- # Deep Convolutional Generative Adversarial Networks (DCGAN) This is a [PyTorch](https://pytorch.org) implementation of paper [...
3,894
31.190083
129
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/original/experiment.py
""" --- title: Generative Adversarial Networks experiment with MNIST summary: This experiment generates MNIST images using multi-layer perceptron. --- # Generative Adversarial Networks experiment with MNIST """ from typing import Any import torch import torch.nn as nn import torch.utils.data from torchvision import ...
7,964
30.113281
116
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/original/__init__.py
""" --- title: Generative Adversarial Networks (GAN) summary: A simple PyTorch implementation/tutorial of Generative Adversarial Networks (GAN) loss functions. --- # Generative Adversarial Networks (GAN) This is an implementation of [Generative Adversarial Networks](https://arxiv.org/abs/1406.2661). The generator, $...
4,927
37.80315
120
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/stylegan/experiment.py
""" --- title: StyleGAN 2 Model Training summary: > An annotated PyTorch implementation of StyleGAN2 model training code. --- # [StyleGAN 2](index.html) Model Training This is the training code for [StyleGAN 2](index.html) model. ![Generated Images](generated_64.png) *<small>These are $64 \times 64$ images generat...
17,574
36.553419
130
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/stylegan/__init__.py
""" --- title: StyleGAN 2 summary: > An annotated PyTorch implementation of StyleGAN2. --- # StyleGAN 2 This is a [PyTorch](https://pytorch.org) implementation of the paper [Analyzing and Improving the Image Quality of StyleGAN](https://arxiv.org/abs/1912.04958) which introduces **StyleGAN 2**. StyleGAN 2 is an im...
36,581
37.588608
118
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/wasserstein/__init__.py
r""" --- title: Wasserstein GAN (WGAN) summary: A simple PyTorch implementation/tutorial of Wasserstein Generative Adversarial Networks (WGAN) loss functions. --- # Wasserstein GAN (WGAN) This is an implementation of [Wasserstein GAN](https://arxiv.org/abs/1701.07875). The original GAN loss is based on Jensen-Shanno...
4,738
33.591241
182
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/wasserstein/gradient_penalty/experiment.py
""" --- title: WGAN-GP experiment with MNIST summary: This experiment generates MNIST images using convolutional neural network. --- # WGAN-GP experiment with MNIST """ import torch from labml import experiment, tracker # Import configurations from [Wasserstein experiment](../experiment.html) from labml_nn.gan.wasse...
2,780
30.965517
120
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/wasserstein/gradient_penalty/__init__.py
r""" --- title: Gradient Penalty for Wasserstein GAN (WGAN-GP) summary: > An annotated PyTorch implementation/tutorial of Improved Training of Wasserstein GANs. --- # Gradient Penalty for Wasserstein GAN (WGAN-GP) This is an implementation of [Improved Training of Wasserstein GANs](https://arxiv.org/abs/1704.00028...
2,822
32.607143
115
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/gan/cycle_gan/__init__.py
""" --- title: Cycle GAN summary: > A simple PyTorch implementation/tutorial of Cycle GAN introduced in paper Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks. --- # Cycle GAN This is a [PyTorch](https://pytorch.org) implementation/tutorial of the paper [Unpaired Image-to-Image Tran...
28,903
36.537662
180
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/resnet/experiment.py
""" --- title: Train a ResNet on CIFAR 10 summary: > Train a ResNet on CIFAR 10 --- # Train a [ResNet](index.html) on CIFAR 10 [![View Run](https://img.shields.io/badge/labml-experiment-brightgreen)](https://app.labml.ai/run/fc5ad600e4af11ebbafd23b8665193c1) """ from typing import List, Optional from torch import ...
2,238
25.341176
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/resnet/__init__.py
""" --- title: Deep Residual Learning for Image Recognition (ResNet) summary: > A PyTorch implementation/tutorial of Deep Residual Learning for Image Recognition (ResNet). --- # Deep Residual Learning for Image Recognition (ResNet) This is a [PyTorch](https://pytorch.org) implementation of the paper [Deep Residual L...
13,477
40.343558
131
py
robust-OT
robust-OT-main/robust StyleGAN 2/labml_nn/activations/swish.py
import torch from torch import nn from labml_helpers.module import Module class Swish(Module): def __init__(self): super().__init__() self.sigmoid = nn.Sigmoid() def forward(self, x: torch.Tensor) -> torch.Tensor: return x * self.sigmoid(x)
277
18.857143
55
py
aiida-yambo
aiida-yambo-master/docs/source/conf.py
# -*- coding: utf-8 -*- # # aiida-wannier90 documentation build configuration file, created by # sphinx-quickstart on Fri Oct 10 02:14:52 2014. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated fil...
12,954
32.389175
271
py
pymanoid
pymanoid-master/doc/src/conf.py
# -*- coding: utf-8 -*- # # pymanoid documentation build configuration file, created by # sphinx-quickstart on Fri Jan 13 14:41:18 2017. import os import sys sys.path.insert(0, os.path.abspath("../..")) sys.path.insert(0, os.path.abspath("../../examples")) sys.path.insert(0, os.path.abspath("../../examples/contact_st...
8,576
27.685619
79
py
metaMIMIC
metaMIMIC-main/4_metaMIMIC_columns/metaMIMIC_columns.py
### metaMIMIC columns # Below code is supposed to be run using the CSV file created with 'metaMIMIC data script'. import os import numpy as np import pandas as pd import xgboost as xgb import dalex as dx from sklearn.impute import SimpleImputer from sklearn.model_selection import cross_val_score, StratifiedKFold ## S...
2,291
34.8125
106
py
metaMIMIC
metaMIMIC-main/6_metaMIMIC_experiment_bayes/metaMIMIC_experiment_bayes.py
### metaMIMIC experiment 3 import os, time import numpy as np import pandas as pd from sklearn.impute import SimpleImputer import xgboost as xgb from sklearn.model_selection import StratifiedKFold import scipy, skopt if os.path.isfile('./results.csv'): print('Results file already exists, aborting execution.') ...
3,747
41.11236
414
py
metaMIMIC
metaMIMIC-main/5_metaMIMIC_experiment_3/metaMIMIC_experiment_3.py
### metaMIMIC experiment 4 import os, time import pandas as pd import xgboost as xgb from sklearn.model_selection import StratifiedKFold, cross_val_score param_sets_raw = pd.read_csv('./grid.csv').drop(['param_index', 'missing'], axis=1).iloc[1:,].to_dict('records') param_sets = [] for param_set in param_sets_raw: ...
1,929
41.888889
160
py
metaMIMIC
metaMIMIC-main/3_metaMIMIC_experiment_2/metaMIMIC_experiment_2.py
### metaMIMIC experiment 2 import time, os.path import pandas as pd import numpy as np from sklearn.impute import SimpleImputer import xgboost as xgb from sklearn.model_selection import StratifiedKFold, cross_val_score if os.path.isfile('./results.csv'): print('Results file already exists, aborting execution.') ...
2,907
48.288136
150
py
metaMIMIC
metaMIMIC-main/2_metaMIMIC_experiment_1/metaMIMIC_experiment_1.py
### metaMIMIC experiment 1 import time, os.path import numpy as np import pandas as pd from sklearn.impute import SimpleImputer import xgboost as xgb from sklearn.model_selection import StratifiedKFold, cross_val_score data = pd.read_csv('../1_metaMIMIC_data/metaMIMIC.csv') if os.path.isfile('./results.csv'): pr...
1,777
41.333333
145
py
unified-generative-zoo
unified-generative-zoo-main/main.py
import logging import os import torch import datasets import transformers from transformers import ( HfArgumentParser, set_seed, ) from utils.config_utils import get_config from utils.program_utils import get_model, get_preprocessor, get_evaluator, get_visualizer from preprocess.to_model import get_multi_task_...
4,296
28.840278
109
py
unified-generative-zoo
unified-generative-zoo-main/generate.py
import torch import argparse import logging import os from PIL import Image import json from tqdm import tqdm from utils.config_utils import get_config from model.gan_wrapper.get_gan_wrapper import get_gan_wrapper logger = logging.getLogger(__name__) def parse_args(): parser = argparse.ArgumentParser(descriptio...
1,773
25.088235
103
py
unified-generative-zoo
unified-generative-zoo-main/trainer/trainer.py
import os from pathlib import Path import time import datetime import json import re import logging import warnings import random import math import collections.abc import shutil from typing import Dict, Union, Any, Optional, List, Tuple import numpy as np import torch import torch.nn as nn from torch.utils.data import...
47,834
41.709821
129
py
unified-generative-zoo
unified-generative-zoo-main/evaluation/utils.py
import numpy as np import torch import cv2 from torchvision import utils def save_image(image_path, image): assert image.dim() == 3 and image.shape[0] == 3 utils.save_image(image, image_path) def ssim(img1, img2): assert img1.shape == img2.shape assert img1.ndim == 2 and img2.ndim == 2 C1 = (0....
1,123
29.378378
89
py
unified-generative-zoo
unified-generative-zoo-main/evaluation/clip_coverage.py
import torch from tqdm import tqdm import torch.nn.functional as F import lpips class Evaluator(object): def __init__(self, args, meta_args): self.args = args self.meta_args = meta_args self.lpips_loss = lpips.LPIPS(net='vgg').cuda() def evaluate(self, images, model, weighted_loss,...
2,776
33.283951
156
py
unified-generative-zoo
unified-generative-zoo-main/evaluation/multi_task.py
import os import numpy as np import torch from utils.program_utils import get_evaluator from utils.config_utils import get_config class Evaluator(object): def __init__(self, meta_args): self.meta_args = meta_args def evaluate(self, images, model, weighted_loss, losses, dataset, split): assert...
2,818
38.152778
94
py
unified-generative-zoo
unified-generative-zoo-main/preprocess/to_model.py
import math from typing import Dict from copy import deepcopy import numpy as np from pprint import pprint from random import shuffle from torch.utils.data import Dataset def upsample(data, weight): n_data = len(data) assert weight >= 1 integral = list(range(n_data)) * int(math.floor(weight)) residua...
4,981
32.436242
97
py
unified-generative-zoo
unified-generative-zoo-main/preprocess/empty_small_eval.py
import torch from datasets import DatasetDict from torch.utils.data import Dataset class Preprocessor(object): def __init__(self, args, meta_args): self.args = args self.meta_args = meta_args def preprocess(self, raw_datasets: DatasetDict, cache_root: str): assert len(raw_datasets) =...
2,128
24.650602
99
py
unified-generative-zoo
unified-generative-zoo-main/preprocess/empty_256.py
import torch from datasets import DatasetDict from torch.utils.data import Dataset class Preprocessor(object): def __init__(self, args, meta_args): self.args = args self.meta_args = meta_args def preprocess(self, raw_datasets: DatasetDict, cache_root: str): assert len(raw_datasets) =...
2,130
24.674699
99
py
unified-generative-zoo
unified-generative-zoo-main/visualization/single_image.py
import os import math from utils.file_utils import save_images import torch.nn.functional as F class Visualizer(object): def __init__(self, args): self.args = args def visualize(self, images, model, description: str, save_dir: ...
1,060
20.653061
46
py
unified-generative-zoo
unified-generative-zoo-main/visualization/single_image_8.py
import os import math from utils.file_utils import save_images import torch.nn.functional as F class Visualizer(object): def __init__(self, args): self.args = args def visualize(self, images, model, description: str, save_dir: ...
923
19.086957
45
py
unified-generative-zoo
unified-generative-zoo-main/utils/dist_utils.py
import torch import numpy as np def truncated_gumbel(logit, truncation): """truncated_gumbel :param logit: Location of the Gumbel variable (e.g., log probability) :param truncation: Value of Maximum Gumbel """ # Note: In our code, -inf shows up for zero-probability events, which is # handled i...
2,466
33.263889
117
py
unified-generative-zoo
unified-generative-zoo-main/utils/file_utils.py
import os import blobfile as bf import torch from torchvision import utils from PIL import Image def save_images(images: torch.Tensor, output_dir: str, file_prefix: str, nrows: int, iteration: int) -> None: utils.save_image( images, os.path.join(output_dir, f"{file_prefix}_{str(iteration).zfill(6...
1,005
27.742857
109
py
unified-generative-zoo
unified-generative-zoo-main/model/langevin_dynamics.py
import torch import torch.nn as nn import numpy as np from .model_utils import requires_grad, MAX_SAMPLE_SIZE from .gan_wrapper.get_gan_wrapper import get_gan_wrapper from .energy.get_energy import get_energy, parse_key class LangevinDynamics(nn.Module): def __init__(self, args): super(LangevinDynamics,...
5,464
33.808917
101
py
unified-generative-zoo
unified-generative-zoo-main/model/energy/clip_guide.py
import torch import torch.nn as nn import torchvision.transforms as transforms import clip from ..model_utils import requires_grad from ..lib.diffaug.DiffAugment_pytorch import DiffAugment POLICY = 'color,translation,resize,cutout' class CLIPEnergy(nn.Module): def __init__(self, text, clip_models, clip_model_w...
3,599
28.268293
109
py
unified-generative-zoo
unified-generative-zoo-main/model/energy/class_condition.py
from collections import OrderedDict import torch import torch.nn as nn import torch.nn.functional as F from ..lib.celeba.classifier import Classifier from ..model_utils import requires_grad class ClassEnergy(nn.Module): def __init__(self, classes, binaries, weights): super(ClassEnergy, self).__init__() ...
1,581
26.754386
66
py
unified-generative-zoo
unified-generative-zoo-main/model/energy/prior_z.py
import torch.nn as nn class PriorZEnergy(nn.Module): def __init__(self): super(PriorZEnergy, self).__init__() @ staticmethod def prepare_inputs(**kwargs): return { 'z': kwargs['z'], } def forward(self, z): if z.ndim == 2: prior_z_loss = 0.5 * (...
491
20.391304
55
py
unified-generative-zoo
unified-generative-zoo-main/model/energy/id_single.py
import torch from torch import nn from PIL import Image from torchvision.transforms import ToTensor, Compose, Resize from ..model_utils import requires_grad from ..lib.id_recognition.model_irse import Backbone RESOLUTION = 112 # Resolution depends on the center crop AND 256 below. class IDSingleEnergy(nn.Module): ...
2,211
29.30137
110
py
unified-generative-zoo
unified-generative-zoo-main/model/lib/stylenerf/renderer.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """Wrap the generator to render a sequence of images""" import torch import torch.nn.functional as F import numpy as np from torch import random import tqdm import copy import trimesh class Renderer(object): def __init__(self, generator, di...
3,534
39.170455
130
py
unified-generative-zoo
unified-generative-zoo-main/model/lib/stylenerf/legacy.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
16,511
50.439252
154
py
unified-generative-zoo
unified-generative-zoo-main/model/lib/stylenerf/training/stylenerf.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import copy import math import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import grad from training.networks import * from dnnlib.camera import * from dnnlib.geometry import ( positional_encoding, upsampl...
115,584
47.728921
148
py
unified-generative-zoo
unified-generative-zoo-main/model/lib/stylenerf/training/augment.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
26,372
60.048611
366
py
unified-generative-zoo
unified-generative-zoo-main/model/lib/stylenerf/training/data_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import PIL.Image import torch import cv2, albumentations import numpy as np def save_image(img, filename): img = (img.permute(0, 2, 3, 1) * 127.5 + 128).clamp(0, 255).to(torch.uint8) PIL.Image.fromarray(img[0].cpu().numpy(), 'RGB').save(f...
1,253
31.153846
89
py