Keras安装 {Keras 由浅入深}

Keras 安装

|
![tensorflow ](https://img-blog.csdnimg.cn/20190825125400589.png#==#pic_center =40x)TensorFlow|

![keras](https://img-blog.csdnimg.cn/20190804140154168.png#==#pic_center =40x)Keras

python & mathematics


installation

sudo pip install keras

backend : tensorflow

dependencies:
cuDNN (recommended if you plan on running Keras on GPU).
HDF5 and h5py (required if you plan on saving Keras models to disk).
graphviz and pydot (used by visualization utilities to plot model graphs).

其实用tensorflow是可以的
我也比较推荐直接使用tensorflow
因为keras其实是tensorflow高阶API
用tensorflow能够使得传统的keras程序有较好的扩展性。
不仅能够使用keras中的特性也能受益于tensorflow

import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layouts

def build_model():
  model = keras.Sequential([
    layers.Dense(64, activation=tf.nn.relu, input_shape=[len(train_dataset.keys())]),
    layers.Dense(64, activation=tf.nn.relu),
    layers.Dense(1)
  ])

  optimizer = tf.keras.optimizers.RMSprop(0.001)

  model.compile(loss='mean_squared_error',
                optimizer=optimizer,
                metrics=['mean_absolute_error', 'mean_squared_error'])
  return model

猜你喜欢

转载自www.cnblogs.com/wykxldz/p/13192454.html