Giter Site home page Giter Site logo

Comments (3)

sushreebarsa avatar sushreebarsa commented on July 19, 2024

@GreatKampfstern I was able to import 'mean_squared_error' from 'tensorflow.keras.losses , please follow the correct commands as below;

!pip install pyod
import tensorflow as tf
from pyod.models.auto_encoder import AutoEncoder
from tensorflow.keras.losses import mean_squared_error

Please find the gist here for your reference. Thank you!

from tensorflow.

GreatKampfstern avatar GreatKampfstern commented on July 19, 2024

If I first execute

!pip install --upgrade pyod
!pip install --upgrade tf-keras
!pip install --upgrade tensorflow

and then do
from pyod.models.auto_encoder import AutoEncoder
I get the same error:

ImportError Traceback (most recent call last)

in <cell line: 1>()
----> 1 from pyod.models.auto_encoder import AutoEncoder

/usr/local/lib/python3.10/dist-packages/pyod/models/auto_encoder.py in
28 from tensorflow.keras.layers import Dense, Dropout
29 from tensorflow.keras.regularizers import l2
---> 30 from tensorflow.keras.losses import mean_squared_error
31
32

ImportError: cannot import name 'mean_squared_error' from 'tensorflow.keras.losses' (/usr/local/lib/python3.10/dist-packages/keras/_tf_keras/keras/losses/init.py)

Sorry if the first three lines are stupid, I just thought (when I did it on my computer) that I first have to install and upgrade all packages. And as far as I know it should still work if I upgrade everything.
Gist for reference

from tensorflow.

sushreebarsa avatar sushreebarsa commented on July 19, 2024

@GreatKampfstern keras.src.losses.losses refers to an internal path within the Keras source code which is not recommended for use. The following command is recommended for use;

from tensorflow.keras.losses import mean_squared_error

Firstly install pyod and then run the command for AutoEncoder as below;

!pip install pyod

from pyod.models.auto_encoder import AutoEncoder

Please have a look at this gist. Thank you!

from tensorflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.