-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
467 additions
and
353 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 | ||
} |
This file was deleted.
Oops, something went wrong.
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
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' |
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
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
Oops, something went wrong.