How can I set RNNBlock's number of units? #1498
-
Sorry for the second question. I would like to specify (or tune automatically) the number of units in the RNNBlock. I have tried the following code, but the number of units is 1.
↓output
How can I set the number of units to be specific value (or automatically tuned value), as shown below? (This is a keras description)
↓output
Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You are right. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply. import autokeras as ak
import tensorflow as tf
from tensorflow.keras.layers import Dense, TimeDistributed
class TimeDistributedDenseBlock(ak.Block):
def build(self, hp, inputs=None):
input_node = tf.nest.flatten(inputs)[0]
layer = TimeDistributed(Dense(hp.Int('units', min_value=2, max_value=10)))
output_node = layer(input_node)
return output_node
input_node = ak.Input()
dense_node = TimeDistributedDenseBlock()(input_node)
gru_node = ak.RNNBlock(bidirectional=False, layer_type="gru")(dense_node)
output_node = ak.RegressionHead(output_dim=1, dropout=0.0)(gru_node)
auto_model = ak.AutoModel(
inputs=input_node,
outputs=output_node,
overwrite=True
)
auto_model.fit(x, y)
model = auto_model.export_model()
model.summary() ↓output
|
Beta Was this translation helpful? Give feedback.
You are right.
Feel free to submit an issue about this feature.
If more people want it, we will add it.