Process: com.example.android.motivatinalapp, PID: 10115
java.lang.RuntimeException: Failed to invoke clarifai2.dto.model.output_info.UnknownOutputInfo() with no args
编辑:添加了用于生成输入数据的功能:
import itertools
import numpy as np
import matplotlib.pyplot as plt
import keras
from keras.datasets import mnist
from keras.models import load_model, Sequential
from keras.layers import Dense, Dropout, Flatten, Lambda
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
from keras.datasets import cifar10
import tensorflow as tf
def idct2d_tf(img_batch):
img_new = tf.transpose(img_batch, perm=(0, 3, 1, 2))
img_new = tf.spectral.idct(img_new)
img_new = tf.transpose(img_new, perm=(0, 1, 3, 2))
img_new = tf.spectral.idct(img_new)
img_new = tf.transpose(img_new, perm=(0, 2, 3, 1))
return img_new
# train model, has IDCT layer first, accepts DCT of MNIST images
model = Sequential()
model.add(Lambda(idct2d_tf, output_shape=(img_rows, img_cols, 1)))
model.add(Conv2D(32, kernel_size=(3, 3),
activation='relu',
input_shape=input_shape))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))
model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.Adadelta(),
metrics=['accuracy'])
model.fit(x_train_dct, y_train,
batch_size=batch_size,
epochs=epochs,
verbose=1,
validation_data=(x_test_dct, y_test))
score = model.evaluate(x_test_dct, y_test, verbose=0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])