Skip to content

Commit

Permalink
some CI changed
Browse files Browse the repository at this point in the history
  • Loading branch information
TsumiNa committed Jan 29, 2018
1 parent 35d86a7 commit e87ca61
Show file tree
Hide file tree
Showing 11 changed files with 467 additions and 353 deletions.
96 changes: 0 additions & 96 deletions random_test.ipynb

This file was deleted.

150 changes: 150 additions & 0 deletions samples/random_test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Sequential(\n",
" (0): Layer1d(\n",
" (neuron): Linear(in_features=290, out_features=100)\n",
" (batch_nor): BatchNorm1d(100, eps=0.1, momentum=0.1, affine=True)\n",
" (act_func): ReLU()\n",
" (dropout): Dropout(p=0.3)\n",
" )\n",
" (1): Layer1d(\n",
" (neuron): Linear(in_features=100, out_features=1)\n",
" )\n",
")"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from xenonpy.model.nn import Generator1d\n",
"import numpy as np\n",
"\n",
"g = Generator1d(290, 1, n_neuron=[100, 70, 50], p_drop=(0.2, 0.3, 0.4),\n",
" batch_normalize=[True], momentum=(0.1, 0.2))\n",
"m = g(1)\n",
"next(m)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Sequential(\n",
" (0): Layer1d(\n",
" (neuron): Linear(in_features=290, out_features=70)\n",
" (batch_nor): BatchNorm1d(70, eps=0.1, momentum=0.1, affine=True)\n",
" (act_func): ReLU()\n",
" (dropout): Dropout(p=0.3)\n",
" )\n",
" (1): Layer1d(\n",
" (neuron): Linear(in_features=70, out_features=35)\n",
" (batch_nor): BatchNorm1d(35, eps=0.1, momentum=0.1, affine=True)\n",
" (act_func): ReLU()\n",
" (dropout): Dropout(p=0.3)\n",
" )\n",
" (2): Layer1d(\n",
" (neuron): Linear(in_features=35, out_features=1)\n",
" )\n",
")"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from math import ceil\n",
"\n",
"g = Generator1d(290, 1, n_neuron=[100, 70, 50], p_drop=(0.2, 0.3, 0.4),\n",
" batch_normalize=[True], momentum=(0.1, 0.2))\n",
"\n",
"m = g(2, scheduler=lambda i, paras: dict(paras, n_out=ceil(paras['n_out'] * 0.5)))\n",
"next(m)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5830"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(list(m))"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.arange(10).tolist()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
8 changes: 0 additions & 8 deletions tests/models/test_layer.py

This file was deleted.

33 changes: 33 additions & 0 deletions tests/test_layer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2017 TsumiNa. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

from torch.nn import Module
from xenonpy.model.nn import Generator1d
from xenonpy.model.nn import Layer1d


def test_layer():
layer = Layer1d(10, 1)
assert isinstance(layer, Module)


def test_generator1d1():
g = Generator1d(290, 1, n_neuron=[100, 70, 50], p_drop=(0.2, 0.3, 0.4),
batch_normalize=[True], momentum=(0.1, 0.2))
m = g(1)
assert len(list(m)) == 18, '3x3x2'


def test_generator1d2():
g = Generator1d(290, 1, n_neuron=[100, 70, 50], p_drop=(0.2, 0.3, 0.4),
batch_normalize=[True], momentum=(0.1, 0.2))
m = g(1, n_models=10)
assert len(list(m)) == 10, '0 < n_models <= 3x3x2'


def test_generator1d3():
g = Generator1d(290, 1, n_neuron=[100, 70, 50], p_drop=(0.2, 0.3, 0.4),
batch_normalize=[True], momentum=(0.1, 0.2))
m = g(1, n_models=120)
assert len(list(m)) == 18, 'n_models > 3x3x2, should got 3x3x2'
4 changes: 2 additions & 2 deletions travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ conda update -q conda
conda info -a

if [[ "$PYTHON_VERSION" == "3.5" ]]; then
conda env create -f environment_py35.yml
conda env create -f devtools/environment_py35.yml
source activate xepy35
else
conda env create -f environment_py36.yml
conda env create -f devtools/environment_py36.yml
source activate xepy36
fi

Expand Down
4 changes: 2 additions & 2 deletions xenonpy/model/nn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
except ImportError:
warnings.warn("Can't fing pytorch, will not load neural network modules.", RuntimeWarning)
else:
from .base_model import *
from .layer import *
from .base import *
from .random_model import *

0 comments on commit e87ca61

Please sign in to comment.