问题遇到的现象和发生背景
将tensor转换为numpy
用代码块功能插入代码,请勿粘贴截图
from keras import backend as K
in_shp = train_data.shape[1:] # in_shap= (4096,2)
Xm_input = Input(in_shp)
x1 = Lambda(slice,output_shape=(4096,1),arguments={'index':0})(Xm_input)
x2 = Lambda(slice,output_shape=(4096,1),arguments={'index':1})(Xm_input)
n1 = K.eval(x1)
model.compile(optimizer = Nadam(learning_rate=0.002),
loss= 'categorical_crossentropy',
metrics=[iou_coef],
run_eagerly=True)
运行结果及报错内容
('Some keys in session_kwargs are not supported at this time: %s', dict_keys(['run_eagerly']))
我的解答思路和尝试过的方法
想要将lambda层输出的Tensor转为numpy,刚开始会报placehold的错误,之后再compile中加了run_eagerly参数,又报了新的错误:('Some keys in session_kwargs are not supported at this time: %s', dict_keys(['run_eagerly']))
我想要达到的结果
将模型中的Tensor转为numpy