In this chapter, we'll cover the following recipes:
- Implementing Operational Gates
- Working with Gates and Activation Functions
- Implementing an One-Hidden-Layer Neural Network
- Implementing Different Layers
- Using Multilayer Networks
- Improving Predictions of Linear Models
- Learning to Play Tic Tac Toe
一层隐藏层的全连接神经网络
-- 与MLP像,但solver, loss的策略不同
加载Iris数据。
# Implementing a one-layer Neural Network #--------------------------------------- # # We will illustrate how to create a one hidden layer NN # # We will use the iris data for this exercise # # We will build a one-hidden layer neural network # to predict the fourth attribute, Petal Width from # the other three (Sepal length, Sepal width, Petal length). import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from sklearn import datasets from tensorflow.python.framework import ops ops.reset_default_graph() iris = datasets.load_iris() x_vals = np.array([x[0:3] for x in iris.data]) y_vals = np.array([x[3] for x in iris.data])