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
// VAE by modifying official autoencoder code | |
// https://github.com/tensorflow/swift-models/blob/2fa11ba1d28ef09454af9da77e22b585cf3e5b7b/Autoencoder/main.swift | |
// Copyright 2019 The TensorFlow Authors. All Rights Reserved. | |
// | |
// 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 | |
// |
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
struct Kollection<T> { | |
var array: Array<T> | |
let indices: [Int] | |
subscript(indice: Int) -> T { | |
get { | |
precondition(indices.contains(indice)) | |
return array[indice] | |
} | |
set { |
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 torch | |
import torch.nn as nn | |
import torch.nn.init as init | |
class MinibatchDiscrimination(nn.Module): | |
def __init__(self, in_features, out_features, kernel_dims, mean=False): | |
super().__init__() | |
self.in_features = in_features | |
self.out_features = out_features | |
self.kernel_dims = kernel_dims |
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 tensorflow as tf | |
from keras import backend as K | |
config = tf.ConfigProto() | |
config.gpu_options.allow_growth=True | |
sess = tf.Session(config=config) | |
K.set_session(sess) |
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
#!/usr/bin/env python | |
import numpy as np | |
from keras.models import Sequential | |
from keras.layers import InputLayer, Reshape, Flatten, Dense | |
from keras.layers.convolutional import Conv2D, MaxPooling2D, Conv2DTranspose | |
from keras.layers.normalization import BatchNormalization | |
from keras.layers.advanced_activations import ELU | |
from keras.datasets import cifar10 | |
from keras.optimizers import Adam |
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
#!/usr/bin/env python | |
import numpy as np | |
from keras.models import Sequential | |
from keras.layers import InputLayer | |
from keras.backend import image_dim_ordering, set_image_dim_ordering | |
from pixel_shuffler import PixelShuffler | |
batch_size = 6 | |
in_height = 4 |
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
""" | |
The MIT License (MIT) | |
Copyright (c) 2018 Takehiro Araki. | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
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
#!/usr/bin/env python | |
from keras.models import Sequential | |
from keras.layers import Dense | |
import numpy as np | |
def set_trainable(model, trainable): | |
model.trainable = trainable | |
for layer in model.layers: | |
layer.trainable = trainable |