GithubHelp home page GithubHelp logo

packtpublishing / neural-network-projects-with-python Goto Github PK

View Code? Open in Web Editor NEW
301.0 21.0 186.0 73.52 MB

Neural Network Projects with Python, Published by Packt

License: MIT License

Python 100.00%

neural-network-projects-with-python's Introduction

Neural Network Projects with Python

Book Name

This is the code repository for Neural Network Projects with Python, published by Packt.

The ultimate guide to using Python to explore the true power of neural networks through six projects

What is this book about?

Neural networks are at the core of recent AI advances, providing some of the best resolutions to many real-world problems, including image recognition, medical diagnosis, text analysis, and more. This book goes through some basic neural network and deep learning concepts, as well as some popular libraries in Python for implementing them.

This book covers the following exciting features:

  • Learn various neural network architectures and its advancements in AI
  • Master deep learning in Python by building and training neural network
  • Master neural networks for regression and classification
  • Discover convolutional neural networks for image recognition
  • Learn sentiment analysis on textual data using Long Short-Term Memory

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

def detect_faces(img, draw_box=True):
  # convert image to grayscale
  grayscale_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Following is what you need for this book: This book is a perfect match for data scientists, machine learning engineers, and deep learning enthusiasts who wish to create practical neural network projects in Python. Readers should already have some basic knowledge of machine learning and neural networks.

With the following software and hardware list you can run all code files present in the book (Chapter 1-7).

Software and Hardware List

Chapter Software required OS required
1-7 Python, Jupyter Notebook Windows, Mac OS X, and Linux (Any)

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Get to Know the Author

James Loy has more than five years, expert experience in data science in the finance and healthcare industries. He has worked with the largest bank in Singapore to drive innovation and improve customer loyalty through predictive analytics. He has also experience in the healthcare sector, where he applied data analytics to improve decision-making in hospitals. He has a master's degree in computer science from Georgia Tech, with a specialization in machine learning.

His research interest includes deep learning and applied machine learning, as well as developing computer-vision-based AI agents for automation in industry. He writes on Towards Data Science, a popular machine learning website with more than 3 million views per month.

Suggestions and Feedback

Click here if you have any feedback or suggestions.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781789138900

neural-network-projects-with-python's People

Contributors

eishad avatar jamesloyys avatar jovita1195 avatar packt-itservice avatar packtutkarshr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neural-network-projects-with-python's Issues

Chapter 7 Error

I am studying machine learning hard with your book. I managed to follow up to Chapter 7, but I have not been able to solve the problems encountered in Chapter 7.
I need your help.
the problem is

Epoch 1/10

TypeError Traceback (most recent call last)
in ()
----> 1 model.fit( [training_pairs[:, 0], training_pairs[:, 1]], training_labels, batch_size=64, epochs=10)

10 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
971 except Exception as e: # pylint:disable=broad-except
972 if hasattr(e, "ag_error_metadata"):
--> 973 raise e.ag_error_metadata.to_exception(e)
974 else:
975 raise

TypeError: in user code:

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:806 train_function  *
    return step_function(self, iterator)
<ipython-input-7-0c8fbaf0850a>:53 contrasive_loss  *
    return K.mean(Y_true*K.square(D) + (1- Y_true)* K.maximum((margin-D), 0))
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:1141 binary_op_wrapper
    raise e
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:1125 binary_op_wrapper
    return func(x, y, name=name)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:1457 _mul_dispatch
    return multiply(x, y, name=name)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py:201 wrapper
    return target(*args, **kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:509 multiply
    return gen_math_ops.mul(x, y, name)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_math_ops.py:6176 mul
    "Mul", x=x, y=y, name=name)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:506 _apply_op_helper
    inferred_from[input_arg.type_attr]))

TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type int64 of argument 'x'.

tensorflow-gpu error in Chapter 5

I'm having a problem in chapter 5 where I get the following error:

Epoch 1/10 2020-11-02 13:40:42.502689: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 2020-11-02 13:40:42.507971: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll 2020-11-02 13:40:42.629293: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected 2020-11-02 13:40:42.631779: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-LU2D9D5 2020-11-02 13:40:42.631939: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: MY_DESKTOP

For reference, when I run the chapter04 auto encoder, it works fine with the gpu.
I also tried adding batch_size=32 to the fit, the code runs, but on the cpu.

Epoch 1/10 2020-11-02 13:42:15.445419: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 2020-11-02 13:42:15.449756: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll 2020-11-02 13:42:15.563797: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected 2020-11-02 13:42:15.566350: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-LU2D9D5 2020-11-02 13:42:15.566498: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-LU2D9D5 195/195 [==============================] - 11s 58ms/step - loss: 0.4456

Using the code with different images gives errors

I am trying to use the code with my own images but am receiving errors. Specifically I'm editing basic_autoencoder_denoise_documents.py and changing image sizes to my required size where needed yet I get the following error when I try and run the code:

AttributeError: 'ProgbarLogger' object has no attribute 'log_values'

The code I am trying to run is below

https://gist.github.com/gormleymark/3185f8c48d2f01634812965c92954b87

Is there something I am missing?

How to run TensorFlow for SSE4.1 SSE4.2 AVX AVX2 FMA on Python with Spyder on MacOs

Hi, I am trying to run the code "lstm.py" in chapter 6. I am getting the following message once I run it with Spyder in Anaconda, Python 3.7.

I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations: SSE4.1 SSE4.2 AVX AVX2 FMA

To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags.

I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 4. Tune using inter_op_parallelism_threads for best performance.

Can you please provide some guidance on what should be done to solve this issue? Thanks.

Chapter 1 error with Keras

Dear James,
I am following the book and I installed the environment as indicated. I am running on Mac OS X 11.2.3.
I get an error on Chapter 1 with Keras (see attached file for the full description of the terminal output).
NNPP_chapter1_error.txt
Thanks for your help,
Best,
Stephane

Issues with the IMDB Dataset: Chapter 6

Hi I am trying to do the LSTM project and I can't seem to even get the dataset. I have tried the code in the book and in your code, and I keep getting an error. It says that "allow_pickle = False". To get around this I tried using np.load() but then I got an error "too many values to unpack (expected 2)". Below are the 2 codes I used.

training_set, testing_set = imdb.load_data(index_from = 3)
X_train, y_train = training_set
X_test, y_test = testing_set

training_set, testing_set = np.load("imdb.npz", allow_pickle=True)
X_train, y_train = training_set
X_test, y_test = testing_set

Chapter 4 Issue

Hello. When I try to run the train_test_split function, rather than create subfolders like Dataset/PetImages/Train/Cat it creates two subfolders, Dataset/PetImagesTrain and Dataset/PetImages/Test that are both empty. I am completely copying the code from the Chapter04 folder as it was downloaded when I started reading through the book.

Issue with Ch.7 Code, plus a fix for a problem someone else had

siamese_nn.py line 28 gave an error of mismatched types, I changed the line to this to fix it:
model.fit([np.float32(training_pairs[:, 0]), np.float32(training_pairs[:, 1])], np.float32(training_labels), batch_size=128, epochs=10)

Now, when I try to run face_recognition_system.py, I get a "SystemError: unknown opcode" message on line 25.

The Keras documentation says we need to supply a custom_objects paramter, and it is supplied, but obviously not correctly.
model = load_model('siamese_nn.h5', custom_objects={'contrastive_loss': utils.contrastive_loss, 'euclidean_distance': utils.euclidean_distance})

Please help.

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.