我们有以下tensorflow模型拟合代码。
data, labels, data_test, labels_test = get_data_and_labels()
model = tf.keras.models.Sequential(
[
tf.keras.layers.InputLayer(input_shape=(data.shape[1],)),
tf.keras.layers.Dense(64),
tf.keras.layers.Activation(tf.keras.activations.relu, name=f"relu1"),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(64),
tf.keras.layers.Activation(tf.keras.activations.relu, name=f"relu2"),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(1),
tf.keras.layers.Activation(tf.keras.activations.tanh, name=f"tanh"),
]
)
optimizer = tf.optimizers.Adam(learning_rate=1e-5)
model.compile(
optimizer,
tf.keras.losses.mean_squared_error,
metrics=['cosine_similarity', 'logcosh']
)
cp_callback = tf.keras.callbacks.ModelCheckpoint(
filepath="model_checkpoints/cp-{epoch:04d}.ckpt", save_weights_only=True, verbose=1
)
model.fit(
data,
labels,
# batch_size=64,
epochs=200,
callbacks=[cp_callback],
validation_data=(data_test, labels_test),
)
我试图在没有GPU(我们目前没有)的情况下安装它,但是当我运行代码时,我唯一得到的是:
2021-04-28 10:06:58.123786: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-04-28 10:06:58.126582: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
它像这样卡住了几个小时,没有额外的错误。我们有大约 140 万条记录,并且在 Windows 10 上运行。
只是因为缺乏而卡住了GPU吗?还是我们应该做点别的?任何帮助都会受到重视。