title: Unknown regularizer: L2 in tensorflowjs
body: <p>I have trained a model in python using model</p>
  <pre><code>reg = 0.000001
  model = Sequential()
  model.add(Dense(24, activation='tanh', name='input_dense', input_shape=input_shape))
  model.add(GRU(24, activation='tanh', recurrent_activation='sigmoid', return_sequences=True, kernel_regularizer=regularizers.l2(reg), recurrent_regularizer=regularizers.l2(reg), reset_after=False))
  model.add(Flatten())
  model.add(Dense(2, activation='softmax'))
  </code></pre>
  <p>But when I converted this model using &quot;tensorflowjs_converter --input_format keras&quot; and loaded in browser getting error</p>
  <blockquote>
  <p>Unhandled Rejection (Error): Unknown regularizer: L2. This may be due
  to one of the following reasons:</p>
  <ol>
  <li>The regularizer is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.</li>
  <li>The custom regularizer is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().</li>
  </ol>
  </blockquote>
  <p>The model.json file content is</p>
  <pre class="lang-json prettyprint-override"><code>{
   &quot;format&quot;: &quot;layers-model&quot;,
   &quot;generatedBy&quot;: &quot;keras v2.4.0&quot;,
   &quot;convertedBy&quot;: &quot;TensorFlow.js Converter v2.3.0&quot;,
   &quot;modelTopology&quot;: {
    &quot;keras_version&quot;: &quot;2.4.0&quot;,
    &quot;backend&quot;: &quot;tensorflow&quot;,
    &quot;model_config&quot;: {
     &quot;class_name&quot;: &quot;Sequential&quot;,
     &quot;config&quot;: {
      &quot;name&quot;: &quot;sequential&quot;,
      &quot;layers&quot;: [
       {
        &quot;class_name&quot;: &quot;InputLayer&quot;,
        &quot;config&quot;: {
         &quot;batch_input_shape&quot;: [null, 22, 13],
         &quot;dtype&quot;: &quot;float32&quot;,
         &quot;sparse&quot;: false,
         &quot;ragged&quot;: false,
         &quot;name&quot;: &quot;input_dense_input&quot;
        }
       },
       {
        &quot;class_name&quot;: &quot;Dense&quot;,
        &quot;config&quot;: {
         &quot;name&quot;: &quot;input_dense&quot;,
         &quot;trainable&quot;: true,
         &quot;batch_input_shape&quot;: [null, 22, 13],
         &quot;dtype&quot;: &quot;float32&quot;,
         &quot;units&quot;: 24,
         &quot;activation&quot;: &quot;tanh&quot;,
         &quot;use_bias&quot;: true,
         &quot;kernel_initializer&quot;: {
          &quot;class_name&quot;: &quot;GlorotUniform&quot;,
          &quot;config&quot;: { &quot;seed&quot;: null }
         },
         &quot;bias_initializer&quot;: { &quot;class_name&quot;: &quot;Zeros&quot;, &quot;config&quot;: {} },
         &quot;kernel_regularizer&quot;: null,
         &quot;bias_regularizer&quot;: null,
         &quot;activity_regularizer&quot;: null,
         &quot;kernel_constraint&quot;: null,
         &quot;bias_constraint&quot;: null
        }
       },
       {
        &quot;class_name&quot;: &quot;GRU&quot;,
        &quot;config&quot;: {
         &quot;name&quot;: &quot;gru&quot;,
         &quot;trainable&quot;: true,
         &quot;dtype&quot;: &quot;float32&quot;,
         &quot;return_sequences&quot;: true,
         &quot;return_state&quot;: false,
         &quot;go_backwards&quot;: false,
         &quot;stateful&quot;: false,
         &quot;unroll&quot;: false,
         &quot;time_major&quot;: false,
         &quot;units&quot;: 24,
         &quot;activation&quot;: &quot;tanh&quot;,
         &quot;recurrent_activation&quot;: &quot;sigmoid&quot;,
         &quot;use_bias&quot;: true,
         &quot;kernel_initializer&quot;: {
          &quot;class_name&quot;: &quot;GlorotUniform&quot;,
          &quot;config&quot;: { &quot;seed&quot;: null }
         },
         &quot;recurrent_initializer&quot;: {
          &quot;class_name&quot;: &quot;Orthogonal&quot;,
          &quot;config&quot;: { &quot;gain&quot;: 1.0, &quot;seed&quot;: null }
         },
         &quot;bias_initializer&quot;: { &quot;class_name&quot;: &quot;Zeros&quot;, &quot;config&quot;: {} },
         &quot;kernel_regularizer&quot;: {
          &quot;class_name&quot;: &quot;L2&quot;,
          &quot;config&quot;: { &quot;l2&quot;: 9.999999974752427e-7 }
         },
         &quot;recurrent_regularizer&quot;: {
          &quot;class_name&quot;: &quot;L2&quot;,
          &quot;config&quot;: { &quot;l2&quot;: 9.999999974752427e-7 }
         },
         &quot;bias_regularizer&quot;: null,
         &quot;activity_regularizer&quot;: null,
         &quot;kernel_constraint&quot;: null,
         &quot;recurrent_constraint&quot;: null,
         &quot;bias_constraint&quot;: null,
         &quot;dropout&quot;: 0.0,
         &quot;recurrent_dropout&quot;: 0.0,
         &quot;implementation&quot;: 2,
         &quot;reset_after&quot;: false
        }
       },
       {
        &quot;class_name&quot;: &quot;Flatten&quot;,
        &quot;config&quot;: {
         &quot;name&quot;: &quot;flatten&quot;,
         &quot;trainable&quot;: true,
         &quot;dtype&quot;: &quot;float32&quot;,
         &quot;data_format&quot;: &quot;channels_last&quot;
        }
       },
       {
        &quot;class_name&quot;: &quot;Dense&quot;,
        &quot;config&quot;: {
         &quot;name&quot;: &quot;dense&quot;,
         &quot;trainable&quot;: true,
         &quot;dtype&quot;: &quot;float32&quot;,
         &quot;units&quot;: 2,
         &quot;activation&quot;: &quot;softmax&quot;,
         &quot;use_bias&quot;: true,
         &quot;kernel_initializer&quot;: {
          &quot;class_name&quot;: &quot;GlorotUniform&quot;,
          &quot;config&quot;: { &quot;seed&quot;: null }
         },
         &quot;bias_initializer&quot;: { &quot;class_name&quot;: &quot;Zeros&quot;, &quot;config&quot;: {} },
         &quot;kernel_regularizer&quot;: null,
         &quot;bias_regularizer&quot;: null,
         &quot;activity_regularizer&quot;: null,
         &quot;kernel_constraint&quot;: null,
         &quot;bias_constraint&quot;: null
        }
       }
      ]
     }
    },
    &quot;training_config&quot;: {
     &quot;loss&quot;: &quot;categorical_crossentropy&quot;,
     &quot;metrics&quot;: [&quot;accuracy&quot;],
     &quot;weighted_metrics&quot;: null,
     &quot;loss_weights&quot;: null,
     &quot;optimizer_config&quot;: {
      &quot;class_name&quot;: &quot;Nadam&quot;,
      &quot;config&quot;: {
       &quot;name&quot;: &quot;Nadam&quot;,
       &quot;learning_rate&quot;: 0.0020000000949949026,
       &quot;decay&quot;: 0.004000000189989805,
       &quot;beta_1&quot;: 0.8999999761581421,
       &quot;beta_2&quot;: 0.9990000128746033,
       &quot;epsilon&quot;: 1e-7
      }
     }
    }
   },
   &quot;weightsManifest&quot;: [
    {
     &quot;paths&quot;: [&quot;group1-shard1of1.bin&quot;],
     &quot;weights&quot;: [
      { &quot;name&quot;: &quot;dense/kernel&quot;, &quot;shape&quot;: [528, 2], &quot;dtype&quot;: &quot;float32&quot; },
      { &quot;name&quot;: &quot;dense/bias&quot;, &quot;shape&quot;: [2], &quot;dtype&quot;: &quot;float32&quot; },
      { &quot;name&quot;: &quot;gru/gru_cell/kernel&quot;, &quot;shape&quot;: [24, 72], &quot;dtype&quot;: &quot;float32&quot; },
      {
       &quot;name&quot;: &quot;gru/gru_cell/recurrent_kernel&quot;,
       &quot;shape&quot;: [24, 72],
       &quot;dtype&quot;: &quot;float32&quot;
      },
      { &quot;name&quot;: &quot;gru/gru_cell/bias&quot;, &quot;shape&quot;: [72], &quot;dtype&quot;: &quot;float32&quot; },
      { &quot;name&quot;: &quot;input_dense/kernel&quot;, &quot;shape&quot;: [13, 24], &quot;dtype&quot;: &quot;float32&quot; },
      { &quot;name&quot;: &quot;input_dense/bias&quot;, &quot;shape&quot;: [24], &quot;dtype&quot;: &quot;float32&quot; }
     ]
    }
   ]
  }
  </code></pre>