Skip to content

Instantly share code, notes, and snippets.

Fontconfig warning: "/etc/fonts/fonts.conf", line 102: unknown element "blank"
Fontconfig warning: "/etc/fonts/conf.avail/66-wqy-zenhei-sharp-no13px.conf", line 11: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.avail/66-wqy-zenhei-sharp.conf", line 10: Having multiple values in <test> isn't supported and may not work as expected
state: update-not-available
import torch
import torch.nn as nn
import torch.optim as optim
from torch.autograd import Variable
class MyLoss(torch.nn.Module):
def __init__(self):
super(MyLoss, self).__init__()
def forward(self, output, target):
# Define options
import argparse
parser = argparse.ArgumentParser(description="WGAN")
# Dataset options
parser.add_argument('-d', '--dataset', default="parent_of_n02510455", help="dataset directory (for ImageFolder)")
# Training options
parser.add_argument('--bad', action="store_true", help="use \"bad\" normalization values")
parser.add_argument('-b', '--batch-size', default=16, type=int, help="batch size")
# Backend options
parser.add_argument('--no-cuda', help="disable CUDA", action="store_true")
from PIL import Image, ImageOps
import numbers
import random
class SharedRandomCrop(object):
"""Crops the given PIL.Image at a random location to have a region of
the given size. Applies the same crop for a certain number (num_sharers) of
consecutive crops. size can be a tuple (target_height, target_width)
or an integer, in which case the target will be of a square shape (size, size)
"""
-- Initialize thread pool: will be global to avoid serialization issues (https://github.com/torch/threads/issues/43)
threads = require "threads"
threads.Threads.serialization('threads.sharedserialize')
pool = threads.Threads(5,
function()
threads_t = require "threads"
require "sys"
end
)
@simopal6
simopal6 / test_thread_metatable.lua
Created June 15, 2016 11:52
Torch thread serialization of tables with custom metatables
-- Create table with metatable
tab = {}
idx = {a = 1}
setmetatable(tab, {__index = idx})
-- Setup threads
threads = require 'threads'
threads.Threads.serialization('threads.sharedserialize') -- Commenting this does not affect the outcome
pool = threads.Threads(2)
-- Prepare job
do