我尝试使用Google Colab TPU运行我的keras UNet模型,而我却遇到了这个问题UpSampling2D。任何解决方案或解决方法?
要运行的代码:
import os
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import UpSampling2D
model = Sequential()
model.add(UpSampling2D((2, 2), input_shape=(16, 16, 1)))
model.compile(optimizer=tf.train.RMSPropOptimizer(learning_rate=0.01),
loss='binary_crossentropy', metrics=['acc'])
TPU_WORKER = 'grpc://' + os.environ['COLAB_TPU_ADDR']
tf.logging.set_verbosity(tf.logging.INFO)
model = tf.contrib.tpu.keras_to_tpu_model(
model,strategy=tf.contrib.tpu.TPUDistributionStrategy(
tf.contrib.cluster_resolver.TPUClusterResolver(TPU_WORKER)))
X = np.zeros((1024, 16, 16, 1))
Y = np.zeros((1024, 32, 32, 1))
model.fit(X, Y, batch_size=1024)
Run Code Online (Sandbox Code Playgroud)
错误:
[DT_INT16]设备中的T =“ CPU”;[DT_UINT16]设备中的T =“ CPU”;[DT_INT32]设备中的T =“ CPU”;[DT_INT64]中的T)){{node tpu_140211339657168 / up_sampling2d_1 / ResizeNearestNeighbor}}