Я тестирую код, который раскрашивает изображения в Google Colab.
from keras.models import Model, Sequential, load_model
from keras.layers.merge import concatenate
from keras.layers.pooling import MaxPooling2D
from keras.preprocessing.image import ImageDataGenerator
from keras.layers.convolutional import Conv2D, Conv2DTranspose
from keras.layers import Input, UpSampling2D, RepeatVector, Reshape
from keras.callbacks import EarlyStopping, ModelCheckpoint, ReduceLROnPlateau
from keras.applications.inception_resnet_v2 import InceptionResNetV2, preprocess_input
from keras import backend as K
import tensorflow as tf
print(tf.__version__)
Using TensorFlow backend.
1.14.0
Я использую tenorflow 1.14.0, потому что оригинальный код от Kaggle, оригинальный: https://www.kaggle.com/valkling/image-colorization-using-autoencoders-and-resnet/notebook
Нет проблем ни в одной камере, до тренировки. Когда исполняется этот код, происходит сбой.
%%time
BATCH_SIZE = 20
model.fit_generator(
image_a_b_gen(X_train, BATCH_SIZE),
epochs=30,
verbose=1,
steps_per_epoch=X_train.shape[0]/BATCH_SIZE,
callbacks=model_callbacks)
Ошибка:
Epoch 1/30
---------------------------------------------------------------------------
FailedPreconditionError Traceback (most recent call last)
<ipython-input-14-61e8a51cf536> in <module>()
----> 1 get_ipython().run_cell_magic('time', '', 'BATCH_SIZE = 20\nmodel.fit_generator(\n image_a_b_gen(X_train, BATCH_SIZE),\n epochs=30,\n verbose=1,\n steps_per_epoch=X_train.shape[0]/BATCH_SIZE,\n callbacks=model_callbacks)')
<decorator-gen-60> in time(self, line, cell, local_ns)
<timed exec> in <module>()
<timed exec> in image_a_b_gen(dataset, batch_size)
<timed exec> in create_inception_embedding(grayscaled_rgb)
1456 ret = tf_session.TF_SessionRunCallable(self._session._session,
1457 self._handle, args,
-> 1458 run_metadata_ptr)
1459 if run_metadata:
1460 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
FailedPreconditionError: Error while reading resource variable conv2d_45/kernel from Container: localhost. This could mean that the variable was uninitialized. Not found: Container localhost does not exist. (Could not find resource: localhost/conv2d_45/kernel)
[[{{node conv2d_45/convolution/ReadVariableOp}}]]
Я думаю, что это может быть связано с версией тензорного потока или сессий, но я не могу найти решение.
Спасибо