Skip to content

Instantly share code, notes, and snippets.

@tony32769
tony32769 / weighted_cross_entropy.py
Created January 24, 2019 14:50 — forked from nasimrahaman/weighted_cross_entropy.py
Pytorch instance-wise weighted cross-entropy loss
import torch
import torch.nn as nn
def log_sum_exp(x):
# See implementation detail in
# http://timvieira.github.io/blog/post/2014/02/11/exp-normalize-trick/
# b is a shift factor. see link.
# x.size() = [N, C]:
b, _ = torch.max(x, 1)
@tony32769
tony32769 / make_parallel.py
Created December 31, 2018 19:01 — forked from ypwhs/make_parallel.py
Keras 多 GPU 同步训练
from keras.layers.merge import Concatenate
from keras.layers.core import Lambda
from keras.models import Model
import tensorflow as tf
def make_parallel(model, gpu_count):
def get_slice(data, idx, parts):
shape = tf.shape(data)
size = tf.concat([ shape[:1] // parts, shape[1:] ],axis=0)
@tony32769
tony32769 / SGDR_Keras.py
Created November 21, 2018 17:41 — forked from koshian2/SGDR_Keras.py
Improve implementation of SGDR: Stochastic Gradient Descent with Warm Restarts in Keras
from keras.layers import Conv2D, Activation, BatchNormalization, Add, Input, GlobalAveragePooling2D, Dense
from keras.models import Model
from keras.optimizers import SGD
from keras.datasets import cifar10
from keras.utils import to_categorical
from keras.initializers import he_normal
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import Callback, LearningRateScheduler
from keras.regularizers import l2
import numpy as np
@tony32769
tony32769 / Keras.ipynb
Created September 20, 2018 16:43 — forked from prhbrt/Keras.ipynb
V-Net in Keras and tensorflow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tony32769
tony32769 / README.md
Created June 30, 2018 00:44 — forked from ahmadsoe/README.md
VPNGate Python script

#VPNGate for OS X This script is a simple script for using to connect vpn server list provided VPNGate through OpenVPN on OS X environment.

It inspired by VPNGate Python script wrtten by Andrea Lazzarotto.

##Requirements If you use the script, Tunnelblick needs to be installed first.

##Installation Open terminal app and copy & paste the command below.

@tony32769
tony32769 / README.md
Created June 30, 2018 00:43 — forked from Lazza/README.md
VPNGate Python script

vpngate.py

This script allows to use the free VPN service provided by VPNGate in an easy way. The user just needs to provide the desidered output country, and the script automatically chooses the best server.

After this step, OpenVPN is launched with the proper configuration. The VPN can be terminated by pressing Ctrl+C.

Usage

Run the script by providing the desired output country:

@tony32769
tony32769 / Keras_FCN.ipynb
Created December 26, 2017 06:02 — forked from ypwhs/Keras_FCN.ipynb
Keras_FCN
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tony32769
tony32769 / CAM.ipynb
Created December 26, 2017 06:02 — forked from ypwhs/CAM.ipynb
CAM
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tony32769
tony32769 / residual_network.py
Created December 26, 2017 06:01 — forked from ypwhs/residual_network.py
Clean and simple Keras implementation of residual networks (ResNeXt and ResNet) accompanying accompanying Deep Residual Learning: https://blog.waya.ai/deep-residual-learning-9610bb62c355.
"""
Clean and simple Keras implementation of network architectures described in:
- (ResNet-50) [Deep Residual Learning for Image Recognition](https://arxiv.org/pdf/1512.03385.pdf).
- (ResNeXt-50 32x4d) [Aggregated Residual Transformations for Deep Neural Networks](https://arxiv.org/pdf/1611.05431.pdf).
Python 3.
"""
from keras import layers
from keras import models
@tony32769
tony32769 / timeseries_cnn.py
Created December 16, 2017 21:24 — forked from jkleint/timeseries_cnn.py
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
#!/usr/bin/env python
"""
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction.
"""
from __future__ import print_function, division
import numpy as np
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten
from keras.models import Sequential