我有一个TF Estimator模型,其代码如下: '''
estimator_model = keras.estimator.model_to_estimator(keras_model=model, model_dir=outputdir)
def batchGen(features, labels):
num = 0
for i in itertools.count(0):
if(num < len(features)):
yield features[i], labels[i]
num+=1
else:
break
def newFeatureFunc(x):
x = x.decode("utf-8")
outT = tokenizer.texts_to_sequences(x, maxlen)
outT = outT.astype(np.float32)
return outT
def newLabelFunc(y):
outT = utils.to_categorical(y, nb_classes)
return outT
def train_fn_custom(features, labels, batch_size):
genSet = lambda : batchGen(features,labels)
dataset=tf.data.Dataset.from_generator(genSet,(tf.string, tf.float32),(tf.TensorShape([]), tf.TensorShape([])))
def _preprocess_function(features, labels):
output1 = tf.py_func(newFeatureFunc, [features], tf.float32)
output1.set_shape([,maxlen])
output2 = tf.py_func(newLabelFunc, [labels], tf.float32)
output2.set_shape([,nb_classes])
return output1, output2
dataset = dataset.map(_preprocess_function)
dataset = dataset.repeat(9)
dataset = dataset.batch(batch_size)
return dataset
batch_size = 1
customTrain = lambda:train_fn_custom(X1, y_train, batch_size)
estimator_model.train(input_fn=customTrain, steps=100)
'''
这会产生错误
OP_REQUIRES在transpose_op.cc:157处失败:参数无效:transpose期望一个大小为5的向量。但是input(1)是一个大小为4的向量
我无法指向导致此错误的代码的位置以及在我的估算器的上下文中的含义。有人可以提供一些见解吗?