Skip to content

Commit df46b86

Browse files
authored
test task specific tuners (#993)
* update * bug fix
1 parent 0405771 commit df46b86

File tree

3 files changed

+64
-17
lines changed

3 files changed

+64
-17
lines changed

autokeras/tuners/task_specific.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44
'image_block_1/block_type': 'vanilla',
55
'image_block_1/normalize': True,
66
'image_block_1/augment': False,
7-
'image_block_1/vanilla_1/kernel_size': 3,
8-
'image_block_1/vanilla_1/num_blocks': 1,
9-
'image_block_1/vanilla_1/num_layers': 2,
10-
'image_block_1/vanilla_1/max_pooling': True,
11-
'image_block_1/vanilla_1/separable': False,
12-
'image_block_1/vanilla_1/dropout_rate': 0.25,
13-
'image_block_1/vanilla_1/filters_0_0': 32,
14-
'image_block_1/vanilla_1/filters_0_1': 64,
15-
'spatial_reduction_1/reduction_type': 'flatten',
7+
'image_block_1/conv_block_1/kernel_size': 3,
8+
'image_block_1/conv_block_1/num_blocks': 1,
9+
'image_block_1/conv_block_1/num_layers': 2,
10+
'image_block_1/conv_block_1/max_pooling': True,
11+
'image_block_1/conv_block_1/separable': False,
12+
'image_block_1/conv_block_1/dropout_rate': 0.25,
13+
'image_block_1/conv_block_1/filters_0_0': 32,
14+
'image_block_1/conv_block_1/filters_0_1': 64,
1615
'dense_block_1/num_layers': 1,
1716
'dense_block_1/use_batchnorm': False,
1817
'dense_block_1/dropout_rate': 0,
1918
'dense_block_1/units_0': 128,
19+
'classification_head_1/spatial_reduction_1/reduction_type': 'flatten',
2020
'classification_head_1/dropout_rate': 0.5,
2121
'optimizer': 'adam'
2222
}, {
2323
'image_block_1/block_type': 'resnet',
2424
'image_block_1/normalize': True,
2525
'image_block_1/augment': True,
26-
'image_block_1/resnet_1/version': 'v2',
27-
'image_block_1/resnet_1/pooling': 'avg',
28-
'image_block_1/resnet_1/conv3_depth': 4,
29-
'image_block_1/resnet_1/conv4_depth': 6,
26+
'image_block_1/res_net_block_1/version': 'v2',
27+
'image_block_1/res_net_block_1/pooling': 'avg',
28+
'image_block_1/res_net_block_1/conv3_depth': 4,
29+
'image_block_1/res_net_block_1/conv4_depth': 6,
3030
'dense_block_1/num_layers': 2,
3131
'dense_block_1/use_batchnorm': False,
3232
'dense_block_1/dropout_rate': 0,

setup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88

99
setup(
1010
name='autokeras',
11-
version='1.0.1',
11+
version='1.0.2',
1212
description='AutoML for deep learning',
1313
package_data={'': ['README.md']},
1414
long_description=readme.read_text(encoding='utf-8'),
1515
long_description_content_type='text/markdown',
1616
author='Data Analytics at Texas A&M (DATA) Lab, Keras Team',
1717
author_email='[email protected]',
1818
url='http://autokeras.com',
19-
download_url='https://github.com/keras-team/autokeras/archive/1.0.1.tar.gz',
20-
keywords=['AutoML', 'keras'],
21-
# TODO: Do not install tensorflow if tensorflow-gpu is installed.
19+
download_url='https://github.com/keras-team/autokeras/archive/1.0.2.tar.gz',
20+
keywords=['AutoML', 'Keras'],
2221
install_requires=[
2322
'packaging',
2423
'keras-tuner>=1.0.1',
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import copy
2+
3+
import kerastuner
4+
import tensorflow as tf
5+
6+
import autokeras as ak
7+
from autokeras import graph as graph_module
8+
from autokeras.tuners import task_specific
9+
10+
11+
def check_initial_hp(initial_hp, graph):
12+
hp = kerastuner.HyperParameters()
13+
hp.values = copy.copy(initial_hp)
14+
graph.build(hp)
15+
assert hp.values == initial_hp
16+
17+
18+
def test_image_classifier_tuner0():
19+
tf.keras.backend.clear_session()
20+
input_node = ak.ImageInput(shape=(32, 32, 3))
21+
output_node = ak.ImageBlock()(input_node)
22+
output_node = ak.ClassificationHead(
23+
loss='categorical_crossentropy',
24+
output_shape=(10,))(output_node)
25+
graph = graph_module.Graph(input_node, output_node)
26+
check_initial_hp(task_specific.IMAGE_CLASSIFIER[0], graph)
27+
28+
29+
def test_image_classifier_tuner1():
30+
tf.keras.backend.clear_session()
31+
input_node = ak.ImageInput(shape=(32, 32, 3))
32+
output_node = ak.ImageBlock()(input_node)
33+
output_node = ak.ClassificationHead(
34+
loss='categorical_crossentropy',
35+
output_shape=(10,))(output_node)
36+
graph = graph_module.Graph(input_node, output_node)
37+
check_initial_hp(task_specific.IMAGE_CLASSIFIER[1], graph)
38+
39+
40+
def test_text_classifier_tuner0():
41+
tf.keras.backend.clear_session()
42+
input_node = ak.TextInput(shape=(1,))
43+
output_node = ak.TextBlock()(input_node)
44+
output_node = ak.ClassificationHead(
45+
loss='categorical_crossentropy',
46+
output_shape=(10,))(output_node)
47+
graph = graph_module.Graph(input_node, output_node)
48+
check_initial_hp(task_specific.TEXT_CLASSIFIER[0], graph)

0 commit comments

Comments
 (0)