Skip to content

Instantly share code, notes, and snippets.

View Warvito's full-sized avatar

Walter Hugo Lopez Pinaya Warvito

View GitHub Profile
import torch
from torch import nn
from monai.utils import optional_import
xformers, has_xformers = optional_import("xformers", name="xformers")
class SelfAttentionBlock(nn.Module):
def __init__(
self,
@Warvito
Warvito / PixelCNN_Architecture
Last active March 7, 2020 16:39
PixelCNN Architecture
class ResidualBlock(keras.Model):
"""Residual blocks that compose pixelCNN
Blocks of layers with 3 convolutional layers and one residual connection.
Based on Figure 5 from [1] where h indicates number of filters.
Refs:
[1] - Oord, A. V. D., Kalchbrenner, N., & Kavukcuoglu, K. (2016). Pixel
recurrent neural networks. arXiv preprint arXiv:1601.06759.
"""
@Warvito
Warvito / PixelCNN_maskedCNN
Last active April 19, 2022 10:52
Convolutional layers with masks. Convolutional layers with simple implementation of masks type A and B for autoregressive models.
class MaskedConv2D(keras.layers.Layer):
"""Convolutional layers with masks.
Convolutional layers with simple implementation of masks type A and B for
autoregressive models.
Arguments:
mask_type: one of `"A"` or `"B".`
filters: Integer, the dimensionality of the output space
(i.e. the number of output filters in the convolution).
# -*- coding: utf-8 -*-
"""
This module creates an optimization of hyper-parameters of a DBN using hyperopt library
Check out the library here: https://github.com/hyperopt/hyperopt).
example run:
python hyperopt_exampleMNIST.py --trainSize=10000 --path=...
REFERENCES
[1] - Bergstra, James, Dan Yamins, and David D. Cox. "Hyperopt: A python library for optimizing the hyperparameters of machine learning algorithms." (2013).