colab 信息
代码
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Activation, Dense
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.metrics import categorical_crossentropy
physical_devices = tf.config.experimental.list_physical_devices('GPU')
print("nums of GPU available: ", len(physical_devices))
tf.config.experimental.set_memory_growth(physical_devices[0], True)
model = Sequential(
[
# Dense == fully connected layer
Dense(units=16, input_shape=(1,), activation='relu'),
Dense(units=32, activation='relu'),
Dense(units=2, activation='softmax')
]
)
model.summary()
上述代码 的输出: