I see that people use regulizers in Dense layer but there is a kernel_regulizer argument in Conv2d in keras documentation:
https://keras.io/layers/convolutional/
When I add the regulizers as follows:
conv1 = Conv2D(32, (3, 15), strides=(1, 2), padding='same', data_format='channels_first', kernel_regularizer=regularizers.l2(), input_shape=x_train_n.shape[1:])(g0)
I get this error:
NameError: name 'regularizers' is not defined
I already imported:
import tensorflow as tf
from tensorflow.python.keras.models import Model
from tensorflow.python.keras.layers import Input, Activation, Conv2D, MaxPooling2D, BatchNormalization, UpSampling2D, Lambda, \
Conv2DTranspose, Permute, GaussianNoise, advanced_activations, Add, LeakyReLU, Dropout, ActivityRegularization
from tensorflow.python.keras import regularizers
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.figure as fgr
from tensorflow.python.keras import backend
from tensorflow.python.keras.utils import plot_model, normalize
from tensorflow.python.keras.callbacks import EarlyStopping
How can I call regulizers in Conv2D? are there any conflicts in imports?
from tensorflow.python.keras import regularizerswas not run before you attempted to make the conv layer. - The Guy with The Hatfrom tensorflow.python.keras import regularizerspython did not recognizeregularizers.l2()nor'l2', etc. this was the only way I could pass the argument to conv2D without in line errors from Pycharm IDE. - Farnaz