In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What is Keras's Python-based deep learning database? for this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Keras is an advanced neural network API written in Python, which can run with CNTK, Theano or TensorFlow as the back end. The development focus of Keras is to support rapid experimentation. The key to good research is to be able to convert your ideas into experimental results with minimal delay.
Guiding principles:
User-friendly. Keras is an API designed for humans, not machines. It puts user experience at the top and center. Keras follows best practices to reduce cognitive difficulties: it provides a consistent and simple API, minimizes the number of user actions required for common use cases, and provides clear and actionable feedback when users make mistakes.
Modularization. The model is understood as a sequence or diagram composed of independent and fully configurable modules. These modules can be assembled with as few restrictions as possible. In particular, the neural network layer, loss function, optimizer, initialization method, activation function and regularization method are all modules that can be combined to build a new model.
Easy to scale. New modules are easy to add (as new classes and functions), and existing modules provide plenty of examples. Because it is easy to create new modules that can improve performance, Keras is more suitable for advanced research.
Based on Python implementation. Keras does not have a separate configuration file in a specific format. The model is defined in Python code, which is compact, easy to debug, and easy to extend.
Keras compatible Python version: Python 2.7-3.6.
Installation log:
The environment I use is python 3.5.2 and AnaConda 4.5.11. It is recommended to use conda installation, which will save a lot of trouble. If you like the challenge, try it with pip.
Command: conda install keras. The specific execution effect is as follows:
I installed Tensorflow at the back end and used a combination of kite.
Based on this environment, an example is given:
Multilayer Perceptron (MLP) for multi-class softmax classification:
Import keras
From keras.models import Sequential
From keras.layers import Dense, Dropout, Activation
From keras.optimizers import SGD
# Generate dummy data
Import numpy as np
X_train = np.random.random (1000, 20)
Y_train = keras.utils.to_categorical (np.random.randint (10, size= (1000, 1)), num_classes=10)
X_test = np.random.random (100,20)
Y_test = keras.utils.to_categorical (np.random.randint (10, size= (100,1)), num_classes=10)
Model = Sequential ()
# Dense (64) is a fully-connected layer with 64 hidden units.
# in the first layer, you must specify the expected input data shape:
# here, 20-dimensional vectors.
Model.add (Dense (64, activation='relu', input_dim=20))
Model.add (Dropout, 0.5)
Model.add (Dense (64, activation='relu'))
Model.add (Dropout, 0.5)
Model.add (Dense (10, activation='softmax'))
Sgd = SGD (lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
Model.compile (loss='categorical_crossentropy'
Optimizer=sgd
Metrics= ['accuracy'])
Model.fit (x_train, y_train
Epochs=20
Batch_size=128)
Score = model.evaluate (x_test, y_test, batch_size=128)
The system prompts an error:
Message=softmax () got an unexpected keyword argument 'axis'
To solve this problem, it is because of the version matching problem between keras and tensorflow. The basic matching table is:
The Tensorflow version I installed is 1.2.1, and keras is the latest version
Reinstall 2.0.6 MagneConda not found, then install 2.0.8
New problems encountered after the upgrade is complete:
Module 'pandas' has no attribute' computation'
Update dask as follows:
Rerun the above example
Multilayer Perceptron (MLP) for multi-class softmax classification:
The results are as follows:
The answer to the question about Keras's Python-based in-depth learning library is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.