Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

ErrorCorner

ErrorCorner Logo ErrorCorner Logo

ErrorCorner Navigation

  • Home
  • Contact Us
  • About Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Contact Us
  • About Us
Home/ Questions/Q 539
Next
Answered
Kenil Vasani
Kenil Vasani

Kenil Vasani

  • 646 Questions
  • 567 Answers
  • 77 Best Answers
  • 26 Points
View Profile
  • 3
Kenil Vasani
Asked: December 14, 20202020-12-14T21:04:12+00:00 2020-12-14T21:04:12+00:00In: Python

ImportError: No module named ‘tensorflow.python’

  • 3

here i wanna run this code for try neural network with python :

from __future__ import print_function 
from keras.datasets import mnist from 
keras.models import Sequential from 
keras.layers import Activation, Dense 
from keras.utils import np_utils 
import tensorflow as tf


batch_size = 128 nb_classes = 10 nb_epoch = 12

#input image dimensions img_row, img_cols = 28, 28

#the data, Shuffled and split between train and test sets (X_train, y_train), (X_test, y_test) = mnist.load_data()


X_train = X_train.reshape(X_train.shape[0], img_rows * img_cols)

X_test = X_test.reshape(X_test.shape[0], img_row * img_cols)

X_train = X_train.astype('float32') X_test = X_test.astype('float32') X_train /= 255 X_text /= 255

print('X_train shape:', X_train.shape) print(X_train_shape[0], 'train samples') print(X_test_shape[0], 'test samples')

#convert class vectors to binary category

Y_train = np_utils.to_categorical(y_train, nb_classes)

Y_test = np_utils.to_categorical(y_test, nb_classes)

model = Sequential()

model.add(Dense(output_dim = 800, input_dim=X_train.shape[1])) model.add(Activation('sigmoid')) model.add(Dense(nb_classes)) model.add(Actiovation('softmax'))

model.compile(loss = 'categorical_crossentropy', optimizer='sgd', metrics=['accuracy']) #crossentropy fungsi galat atau fungsi error dipakai kalo class biner



#model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch = nb_poch, verbose=1, validation_data=(X_test, Y_test))

score = model.evaluate(X_test, Y_test, verbose = 0) print('Test Score : ', score[0]) print('Test Accuracy : ', score[1])

at the beginning it must install keras, and success. but when try to run the code at the first the error is :

ImportError : No Moduled Name “tensorflow”

then i install using pip :

pip install tensorflow

after installation i try to run code again, got another message like this :

ImportError : No Moduled Name “tensorflow.python”

Message Error
i dont have any idea with the error

kerasneural-networkpythontensorflow
  • 1 1 Answer
  • 11 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    1 Answer

    • Voted
    1. Kenil Vasani

      Kenil Vasani

      • 646 Questions
      • 567 Answers
      • 77 Best Answers
      • 26 Points
      View Profile
      Best Answer
      Kenil Vasani
      2020-12-14T21:02:23+00:00Added an answer on December 14, 2020 at 9:02 pm

      Uninstall tensorflow:

      pip uninstall tensorflow
      

      Then reinstall it:

      pip install tensorflow
      
      • 2
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    You must login to add an answer.

    Forgot Password?

    Sidebar

    Ask A Question
    • Popular
    • Kenil Vasani

      SyntaxError: invalid syntax to repo init in the AOSP code

      • 5 Answers
    • Kenil Vasani

      xlrd.biffh.XLRDError: Excel xlsx file; not supported

      • 3 Answers
    • Kenil Vasani

      Homebrew fails on MacOS Big Sur

      • 3 Answers
    • Kenil Vasani

      runtimeError: package fails to pass a sanity check for numpy ...

      • 3 Answers
    • Kenil Vasani

      Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains ...

      • 2 Answers

    Explore

    • Most Answered
    • Most Visited
    • Most Voted
    • Random

    © 2020-2021 ErrorCorner. All Rights Reserved
    by ErrorCorner.com