To use tensorflow in Python, you first need to install it. You can do this using pip install command:
main.py23 chars2 lines
Once installation is complete, you can import tensorflow in your Python script and start using it. Here is a simple example of using tensorflow to create a neural network:
main.py518 chars20 lines
This code defines a simple neural network with two dense layers and trains it on MNIST dataset. The model is compiled with 'adam' optimizer, 'categorical_crossentropy' loss function and 'accuracy' metric. It is then trained for 5 epochs on training data and evaluated on test data. Finally, the test accuracy is printed.
gistlibby LogSnag