ierhon commited on
Commit
6de5c93
1 Parent(s): 31dee74

Fix dropout

Browse files
Files changed (1) hide show
  1. chatbot_constructor.py +5 -5
chatbot_constructor.py CHANGED
@@ -54,7 +54,7 @@ def train(message: str = "", dropout: float = 0.5, learning_rate: float = 0.001,
54
  else:
55
  input_layer = Input(shape=(inp_len,))
56
  emb_layer = Embedding(input_dim=vocab_size, output_dim=emb_size, input_length=inp_len)(input_layer)
57
- dropout1_layer = Dropout(0.25)(emb_layer)
58
  attn_layer = MultiHeadAttention(num_heads=4, key_dim=128)(dropout1_layer, dropout1_layer, dropout1_layer)
59
  noise_layer = GaussianNoise(0.1)(attn_layer)
60
  conv1_layer = Conv1D(kernels_count, kernel_size, padding='same', activation='relu', strides=1, input_shape=(64, 128))(noise_layer)
@@ -66,14 +66,14 @@ def train(message: str = "", dropout: float = 0.5, learning_rate: float = 0.001,
66
  conv2_flatten_layer = Flatten()(conv2_layer)
67
  conv3_flatten_layer = Flatten()(conv3_layer)
68
  concat1_layer = Concatenate()([flatten_layer, attn_flatten_layer, conv1_flatten_layer, conv2_flatten_layer, conv3_flatten_layer])
69
- dropout2_layer = Dropout(0.5)(concat1_layer)
70
  dense1_layer = Dense(512, activation="linear")(dropout2_layer)
71
  prelu1_layer = PReLU()(dense1_layer)
72
- dropout3_layer = Dropout(0.5)(prelu1_layer)
73
  dense2_layer = Dense(256, activation="tanh")(dropout3_layer)
74
- dropout4_layer = Dropout(0.5)(dense2_layer)
75
  dense3_layer = Dense(256, activation="relu")(dropout4_layer)
76
- dropout5_layer = Dropout(0.5)(dense3_layer)
77
  dense4_layer = Dense(100, activation="tanh")(dropout5_layer)
78
  concat2_layer = Concatenate()([dense4_layer, prelu1_layer, attn_flatten_layer, conv1_flatten_layer])
79
  dense4_layer = Dense(resps_len, activation="softmax")(concat2_layer)
 
54
  else:
55
  input_layer = Input(shape=(inp_len,))
56
  emb_layer = Embedding(input_dim=vocab_size, output_dim=emb_size, input_length=inp_len)(input_layer)
57
+ dropout1_layer = Dropout(dropout)(emb_layer)
58
  attn_layer = MultiHeadAttention(num_heads=4, key_dim=128)(dropout1_layer, dropout1_layer, dropout1_layer)
59
  noise_layer = GaussianNoise(0.1)(attn_layer)
60
  conv1_layer = Conv1D(kernels_count, kernel_size, padding='same', activation='relu', strides=1, input_shape=(64, 128))(noise_layer)
 
66
  conv2_flatten_layer = Flatten()(conv2_layer)
67
  conv3_flatten_layer = Flatten()(conv3_layer)
68
  concat1_layer = Concatenate()([flatten_layer, attn_flatten_layer, conv1_flatten_layer, conv2_flatten_layer, conv3_flatten_layer])
69
+ dropout2_layer = Dropout(dropout)(concat1_layer)
70
  dense1_layer = Dense(512, activation="linear")(dropout2_layer)
71
  prelu1_layer = PReLU()(dense1_layer)
72
+ dropout3_layer = Dropout(dropout)(prelu1_layer)
73
  dense2_layer = Dense(256, activation="tanh")(dropout3_layer)
74
+ dropout4_layer = Dropout(dropout)(dense2_layer)
75
  dense3_layer = Dense(256, activation="relu")(dropout4_layer)
76
+ dropout5_layer = Dropout(dropout)(dense3_layer)
77
  dense4_layer = Dense(100, activation="tanh")(dropout5_layer)
78
  concat2_layer = Concatenate()([dense4_layer, prelu1_layer, attn_flatten_layer, conv1_flatten_layer])
79
  dense4_layer = Dense(resps_len, activation="softmax")(concat2_layer)