Skip to content

Getting Error When importing "import apply_regularization, l2_regularizer" #15

Open

Description

@anandece4u

Hi I am getting error while running the notebook in line where we are importing

from tensorflow.contrib.layers import apply_regularization, l2_regularizer

`---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
in
15
16 import tensorflow as tf
---> 17 from tensorflow.contrib.layers import apply_regularization, l2_regularizer
18
19 import bottleneck as bn

ModuleNotFoundError: No module named 'tensorflow.contrib'`

Please help

Activity

  1. TruongThuyLiem commented on Jun 1, 2021

    @TruongThuyLiem

    You can try with tensorflow-gpu==1.15

  2. amithadiraju1694 commented on Feb 19, 2022

    @amithadiraju1694

    You could also try to to just apply L2 regularization directly than a two-step process as in tf 1.15, I did this to make it work on tf 2.7.3:

    `from tensorFlow.keras.regularizers import L2

    ........

    l2_reg = L2(self.lam) # inside build_graph function
    reg_var = l2_reg(self.weights)
    `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions