Skip to content

Commit

Permalink
test task specific tuners (#993)
Browse files Browse the repository at this point in the history
* update

* bug fix
  • Loading branch information
haifeng-jin authored Feb 21, 2020
1 parent 0405771 commit df46b86
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 17 deletions.
26 changes: 13 additions & 13 deletions autokeras/tuners/task_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
'image_block_1/block_type': 'vanilla',
'image_block_1/normalize': True,
'image_block_1/augment': False,
'image_block_1/vanilla_1/kernel_size': 3,
'image_block_1/vanilla_1/num_blocks': 1,
'image_block_1/vanilla_1/num_layers': 2,
'image_block_1/vanilla_1/max_pooling': True,
'image_block_1/vanilla_1/separable': False,
'image_block_1/vanilla_1/dropout_rate': 0.25,
'image_block_1/vanilla_1/filters_0_0': 32,
'image_block_1/vanilla_1/filters_0_1': 64,
'spatial_reduction_1/reduction_type': 'flatten',
'image_block_1/conv_block_1/kernel_size': 3,
'image_block_1/conv_block_1/num_blocks': 1,
'image_block_1/conv_block_1/num_layers': 2,
'image_block_1/conv_block_1/max_pooling': True,
'image_block_1/conv_block_1/separable': False,
'image_block_1/conv_block_1/dropout_rate': 0.25,
'image_block_1/conv_block_1/filters_0_0': 32,
'image_block_1/conv_block_1/filters_0_1': 64,
'dense_block_1/num_layers': 1,
'dense_block_1/use_batchnorm': False,
'dense_block_1/dropout_rate': 0,
'dense_block_1/units_0': 128,
'classification_head_1/spatial_reduction_1/reduction_type': 'flatten',
'classification_head_1/dropout_rate': 0.5,
'optimizer': 'adam'
}, {
'image_block_1/block_type': 'resnet',
'image_block_1/normalize': True,
'image_block_1/augment': True,
'image_block_1/resnet_1/version': 'v2',
'image_block_1/resnet_1/pooling': 'avg',
'image_block_1/resnet_1/conv3_depth': 4,
'image_block_1/resnet_1/conv4_depth': 6,
'image_block_1/res_net_block_1/version': 'v2',
'image_block_1/res_net_block_1/pooling': 'avg',
'image_block_1/res_net_block_1/conv3_depth': 4,
'image_block_1/res_net_block_1/conv4_depth': 6,
'dense_block_1/num_layers': 2,
'dense_block_1/use_batchnorm': False,
'dense_block_1/dropout_rate': 0,
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@

setup(
name='autokeras',
version='1.0.1',
version='1.0.2',
description='AutoML for deep learning',
package_data={'': ['README.md']},
long_description=readme.read_text(encoding='utf-8'),
long_description_content_type='text/markdown',
author='Data Analytics at Texas A&M (DATA) Lab, Keras Team',
author_email='[email protected]',
url='http://autokeras.com',
download_url='https://github.com/keras-team/autokeras/archive/1.0.1.tar.gz',
keywords=['AutoML', 'keras'],
# TODO: Do not install tensorflow if tensorflow-gpu is installed.
download_url='https://github.com/keras-team/autokeras/archive/1.0.2.tar.gz',
keywords=['AutoML', 'Keras'],
install_requires=[
'packaging',
'keras-tuner>=1.0.1',
Expand Down
48 changes: 48 additions & 0 deletions tests/autokeras/tuners/task_specific_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import copy

import kerastuner
import tensorflow as tf

import autokeras as ak
from autokeras import graph as graph_module
from autokeras.tuners import task_specific


def check_initial_hp(initial_hp, graph):
hp = kerastuner.HyperParameters()
hp.values = copy.copy(initial_hp)
graph.build(hp)
assert hp.values == initial_hp


def test_image_classifier_tuner0():
tf.keras.backend.clear_session()
input_node = ak.ImageInput(shape=(32, 32, 3))
output_node = ak.ImageBlock()(input_node)
output_node = ak.ClassificationHead(
loss='categorical_crossentropy',
output_shape=(10,))(output_node)
graph = graph_module.Graph(input_node, output_node)
check_initial_hp(task_specific.IMAGE_CLASSIFIER[0], graph)


def test_image_classifier_tuner1():
tf.keras.backend.clear_session()
input_node = ak.ImageInput(shape=(32, 32, 3))
output_node = ak.ImageBlock()(input_node)
output_node = ak.ClassificationHead(
loss='categorical_crossentropy',
output_shape=(10,))(output_node)
graph = graph_module.Graph(input_node, output_node)
check_initial_hp(task_specific.IMAGE_CLASSIFIER[1], graph)


def test_text_classifier_tuner0():
tf.keras.backend.clear_session()
input_node = ak.TextInput(shape=(1,))
output_node = ak.TextBlock()(input_node)
output_node = ak.ClassificationHead(
loss='categorical_crossentropy',
output_shape=(10,))(output_node)
graph = graph_module.Graph(input_node, output_node)
check_initial_hp(task_specific.TEXT_CLASSIFIER[0], graph)

0 comments on commit df46b86

Please sign in to comment.