提交 13548e8b 编写于 作者: T Taehoon Lee 提交者: François Chollet

Add tests for inputs set dynamically (#10367)

上级 56b255cc
......@@ -7,7 +7,7 @@ import scipy.sparse as sparse
import keras
from keras import losses
from keras.layers import Dense, Dropout, Conv2D
from keras.layers import Activation, Dense, Dropout, Conv2D
from keras.engine import Input
from keras.engine.training import Model
from keras.engine import training_utils
......@@ -1443,5 +1443,24 @@ def test_model_with_crossentropy_losses_channels_first():
'channels_first and channels_last.'))
@keras_test
def test_dynamic_set_inputs():
model = Sequential()
model.add(Dense(16, input_dim=32))
model.add(Activation('relu'))
model2 = Sequential()
model2.add(model.layers[-1])
model2.add(Dense(8))
preds2 = model2.predict([np.random.random((1, 32))])
assert preds2.shape == (1, 8)
model3 = Model(inputs=model.inputs, outputs=model.outputs)
model3.inputs = None
model3._set_inputs(model.inputs)
preds3 = model3.predict([np.random.random((1, 32))])
assert preds3.shape == (1, 16)
if __name__ == '__main__':
pytest.main([__file__])
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册