25
25
from autokeras import keras_layers
26
26
from autokeras .blocks import reduction
27
27
from autokeras .engine import block as block_module
28
+ from autokeras .utils import io_utils
28
29
from autokeras .utils import layer_utils
29
30
from autokeras .utils import utils
30
31
@@ -103,19 +104,19 @@ def get_config(self):
103
104
config = super ().get_config ()
104
105
config .update (
105
106
{
106
- "num_layers" : hyperparameters . serialize (self .num_layers ),
107
- "num_units" : hyperparameters . serialize (self .num_units ),
107
+ "num_layers" : io_utils . serialize_block_arg (self .num_layers ),
108
+ "num_units" : io_utils . serialize_block_arg (self .num_units ),
108
109
"use_batchnorm" : self .use_batchnorm ,
109
- "dropout" : hyperparameters . serialize (self .dropout ),
110
+ "dropout" : io_utils . serialize_block_arg (self .dropout ),
110
111
}
111
112
)
112
113
return config
113
114
114
115
@classmethod
115
116
def from_config (cls , config ):
116
- config ["num_layers" ] = hyperparameters . deserialize (config ["num_layers" ])
117
- config ["num_units" ] = hyperparameters . deserialize (config ["num_units" ])
118
- config ["dropout" ] = hyperparameters . deserialize (config ["dropout" ])
117
+ config ["num_layers" ] = io_utils . deserialize_block_arg (config ["num_layers" ])
118
+ config ["num_units" ] = io_utils . deserialize_block_arg (config ["num_units" ])
119
+ config ["dropout" ] = io_utils . deserialize_block_arg (config ["dropout" ])
119
120
return cls (** config )
120
121
121
122
def build (self , hp , inputs = None ):
@@ -190,20 +191,20 @@ def get_config(self):
190
191
config .update (
191
192
{
192
193
"return_sequences" : self .return_sequences ,
193
- "bidirectional" : hyperparameters . serialize (self .bidirectional ),
194
- "num_layers" : hyperparameters . serialize (self .num_layers ),
195
- "layer_type" : hyperparameters . serialize (self .layer_type ),
194
+ "bidirectional" : io_utils . serialize_block_arg (self .bidirectional ),
195
+ "num_layers" : io_utils . serialize_block_arg (self .num_layers ),
196
+ "layer_type" : io_utils . serialize_block_arg (self .layer_type ),
196
197
}
197
198
)
198
199
return config
199
200
200
201
@classmethod
201
202
def from_config (cls , config ):
202
- config ["bidirectional" ] = hyperparameters . deserialize (
203
+ config ["bidirectional" ] = io_utils . deserialize_block_arg (
203
204
config ["bidirectional" ]
204
205
)
205
- config ["num_layers" ] = hyperparameters . deserialize (config ["num_layers" ])
206
- config ["layer_type" ] = hyperparameters . deserialize (config ["layer_type" ])
206
+ config ["num_layers" ] = io_utils . deserialize_block_arg (config ["num_layers" ])
207
+ config ["layer_type" ] = io_utils . deserialize_block_arg (config ["layer_type" ])
207
208
return cls (** config )
208
209
209
210
def build (self , hp , inputs = None ):
@@ -314,24 +315,24 @@ def get_config(self):
314
315
config = super ().get_config ()
315
316
config .update (
316
317
{
317
- "kernel_size" : hyperparameters . serialize (self .kernel_size ),
318
- "num_blocks" : hyperparameters . serialize (self .num_blocks ),
319
- "num_layers" : hyperparameters . serialize (self .num_layers ),
320
- "filters" : hyperparameters . serialize (self .filters ),
318
+ "kernel_size" : io_utils . serialize_block_arg (self .kernel_size ),
319
+ "num_blocks" : io_utils . serialize_block_arg (self .num_blocks ),
320
+ "num_layers" : io_utils . serialize_block_arg (self .num_layers ),
321
+ "filters" : io_utils . serialize_block_arg (self .filters ),
321
322
"max_pooling" : self .max_pooling ,
322
323
"separable" : self .separable ,
323
- "dropout" : hyperparameters . serialize (self .dropout ),
324
+ "dropout" : io_utils . serialize_block_arg (self .dropout ),
324
325
}
325
326
)
326
327
return config
327
328
328
329
@classmethod
329
330
def from_config (cls , config ):
330
- config ["kernel_size" ] = hyperparameters . deserialize (config ["kernel_size" ])
331
- config ["num_blocks" ] = hyperparameters . deserialize (config ["num_blocks" ])
332
- config ["num_layers" ] = hyperparameters . deserialize (config ["num_layers" ])
333
- config ["filters" ] = hyperparameters . deserialize (config ["filters" ])
334
- config ["dropout" ] = hyperparameters . deserialize (config ["dropout" ])
331
+ config ["kernel_size" ] = io_utils . deserialize_block_arg (config ["kernel_size" ])
332
+ config ["num_blocks" ] = io_utils . deserialize_block_arg (config ["num_blocks" ])
333
+ config ["num_layers" ] = io_utils . deserialize_block_arg (config ["num_layers" ])
334
+ config ["filters" ] = io_utils . deserialize_block_arg (config ["filters" ])
335
+ config ["dropout" ] = io_utils . deserialize_block_arg (config ["dropout" ])
335
336
return cls (** config )
336
337
337
338
def build (self , hp , inputs = None ):
@@ -560,24 +561,24 @@ def get_config(self):
560
561
config .update (
561
562
{
562
563
"max_features" : self .max_features ,
563
- "pretraining" : hyperparameters . serialize (self .pretraining ),
564
- "embedding_dim" : hyperparameters . serialize (self .embedding_dim ),
565
- "num_heads" : hyperparameters . serialize (self .num_heads ),
566
- "dense_dim" : hyperparameters . serialize (self .dense_dim ),
567
- "dropout" : hyperparameters . serialize (self .dropout ),
564
+ "pretraining" : io_utils . serialize_block_arg (self .pretraining ),
565
+ "embedding_dim" : io_utils . serialize_block_arg (self .embedding_dim ),
566
+ "num_heads" : io_utils . serialize_block_arg (self .num_heads ),
567
+ "dense_dim" : io_utils . serialize_block_arg (self .dense_dim ),
568
+ "dropout" : io_utils . serialize_block_arg (self .dropout ),
568
569
}
569
570
)
570
571
return config
571
572
572
573
@classmethod
573
574
def from_config (cls , config ):
574
- config ["pretraining" ] = hyperparameters . deserialize (config ["pretraining" ])
575
- config ["embedding_dim" ] = hyperparameters . deserialize (
575
+ config ["pretraining" ] = io_utils . deserialize_block_arg (config ["pretraining" ])
576
+ config ["embedding_dim" ] = io_utils . deserialize_block_arg (
576
577
config ["embedding_dim" ]
577
578
)
578
- config ["num_heads" ] = hyperparameters . deserialize (config ["num_heads" ])
579
- config ["dense_dim" ] = hyperparameters . deserialize (config ["dense_dim" ])
580
- config ["dropout" ] = hyperparameters . deserialize (config ["dropout" ])
579
+ config ["num_heads" ] = io_utils . deserialize_block_arg (config ["num_heads" ])
580
+ config ["dense_dim" ] = io_utils . deserialize_block_arg (config ["dense_dim" ])
581
+ config ["dropout" ] = io_utils . deserialize_block_arg (config ["dropout" ])
581
582
return cls (** config )
582
583
583
584
def build (self , hp , inputs = None ):
@@ -872,18 +873,18 @@ def get_config(self):
872
873
config .update (
873
874
{
874
875
"max_features" : self .max_features ,
875
- "pretraining" : hyperparameters . serialize (self .pretraining ),
876
- "embedding_dim" : hyperparameters . serialize (self .embedding_dim ),
877
- "dropout" : hyperparameters . serialize (self .dropout ),
876
+ "pretraining" : io_utils . serialize_block_arg (self .pretraining ),
877
+ "embedding_dim" : io_utils . serialize_block_arg (self .embedding_dim ),
878
+ "dropout" : io_utils . serialize_block_arg (self .dropout ),
878
879
}
879
880
)
880
881
return config
881
882
882
883
@classmethod
883
884
def from_config (cls , config ):
884
- config ["pretraining" ] = hyperparameters . deserialize (config ["pretraining" ])
885
- config ["dropout" ] = hyperparameters . deserialize (config ["dropout" ])
886
- config ["embedding_dim" ] = hyperparameters . deserialize (
885
+ config ["pretraining" ] = io_utils . deserialize_block_arg (config ["pretraining" ])
886
+ config ["dropout" ] = io_utils . deserialize_block_arg (config ["dropout" ])
887
+ config ["embedding_dim" ] = io_utils . deserialize_block_arg (
887
888
config ["embedding_dim" ]
888
889
)
889
890
return cls (** config )
@@ -956,7 +957,7 @@ def get_config(self):
956
957
config = super ().get_config ()
957
958
config .update (
958
959
{
959
- "max_sequence_length" : hyperparameters . serialize (
960
+ "max_sequence_length" : io_utils . serialize_block_arg (
960
961
self .max_sequence_length
961
962
)
962
963
}
@@ -965,7 +966,7 @@ def get_config(self):
965
966
966
967
@classmethod
967
968
def from_config (cls , config ):
968
- config ["max_sequence_length" ] = hyperparameters . deserialize (
969
+ config ["max_sequence_length" ] = io_utils . deserialize_block_arg (
969
970
config ["max_sequence_length" ]
970
971
)
971
972
return cls (** config )
0 commit comments