模型预测:不兼容的形状
Posted
技术标签:
【中文标题】模型预测:不兼容的形状【英文标题】:Model Prediction: Incompatible Shape 【发布时间】:2021-06-02 10:18:55 【问题描述】:我有一个经过 1024 批次训练的预训练模型。现在,当我尝试对新样本进行简单预测时,我收到以下警告:
警告:tensorflow:模型是用形状 (1024, 87, 16) 构造的输入 KerasTensor(type_spec=TensorSpec(shape=(1024, 87, 16), dtype=tf.float32, name='Input'), name='Input', description="created by layer 'Input'"),但它是在形状不兼容的输入上调用的 (1, 87, 16)。
如何删除批次维度?如果忽略警告,预测结果是否会有所不同?
#load model
json_file = open(data_dir+'wt_sm_model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json)
# load weights
loaded_model.load_weights(data_dir+"wt_sm_model.h5")
print("Loaded model from disk")
#Define Model
losses=[mse,mse,mse,mse,mse,mse,mse,mse,scc,scc,scc,scc,scc,scc,scc,scc,scc,scc,scc,scc,scc,scc,scc,
scc,scc,scc,scc,scc,scc,scc,scc,scc,scc]
optimizer = keras.optimizers.Adam(lr=0.003)
reduce_lr = callbacks.ReduceLROnPlateau(monitor='val_loss', factor=0.5,patience=3, min_lr=0.0005)
early_stopping = callbacks.EarlyStopping(monitor='val_loss', patience=10)
#Compile and Predict
loaded_model.compile(loss = losses, optimizer=optimizer, metrics='accuracy')
prediction=model.predict(mfcc,callbacks=[reduce_lr,early_stopping],steps = 1,verbose=1)
wt_sm_model.json:
"class_name": "Functional", "config": "name": "model", "layers": ["class_name": "InputLayer", "config": "batch_input_shape": [1024, 87, 16], "dtype": "float32", "sparse": false, "ragged": false, "name": "Input", "name": "Input", "inbound_nodes": [], "class_name": "Bidirectional", "config": "name": "BidirLSTM", "trainable": true, "dtype": "float32", "layer": "class_name": "LSTM", "config": "name": "lstm", "trainable": true, "batch_input_shape": [null, 87, 16], "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 64, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "recurrent_initializer": "class_name": "Orthogonal", "config": "gain": 1.0, "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "unit_forget_bias": true, "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.01, "recurrent_dropout": 0.01, "implementation": 1, "merge_mode": "concat", "name": "BidirLSTM", "inbound_nodes": [[["Input", 0, 0, ]]], "class_name": "Dense", "config": "name": "Dense", "trainable": true, "dtype": "float32", "units": 256, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Dense", "inbound_nodes": [[["BidirLSTM", 0, 0, ]]], "class_name": "BatchNormalization", "config": "name": "BatchNorm", "trainable": true, "dtype": "float32", "axis": [1], "momentum": 0.99, "epsilon": 0.001, "center": true, "scale": true, "beta_initializer": "class_name": "Zeros", "config": , "gamma_initializer": "class_name": "Ones", "config": , "moving_mean_initializer": "class_name": "Zeros", "config": , "moving_variance_initializer": "class_name": "Ones", "config": , "beta_regularizer": null, "gamma_regularizer": null, "beta_constraint": null, "gamma_constraint": null, "name": "BatchNorm", "inbound_nodes": [[["Dense", 0, 0, ]]], "class_name": "Dense", "config": "name": "MidCon", "trainable": true, "dtype": "float32", "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "MidCon", "inbound_nodes": [[["BatchNorm", 0, 0, ]]], "class_name": "Dense", "config": "name": "MidCat", "trainable": true, "dtype": "float32", "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "MidCat", "inbound_nodes": [[["BatchNorm", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConFltPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConFltPre", "inbound_nodes": [[["MidCon", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConModPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConModPre", "inbound_nodes": [[["MidCon", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConOscPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConOscPre", "inbound_nodes": [[["MidCon", 0, 0, ]]], "class_name": "Dense", "config": "name": "MidMtx", "trainable": true, "dtype": "float32", "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "MidMtx", "inbound_nodes": [[["BatchNorm", 0, 0, ]]], "class_name": "Dense", "config": "name": "CatWTPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "CatWTPre", "inbound_nodes": [[["MidCat", 0, 0, ]]], "class_name": "Dense", "config": "name": "CatFltPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "CatFltPre", "inbound_nodes": [[["MidCat", 0, 0, ]]], "class_name": "Dense", "config": "name": "CatModPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "CatModPre", "inbound_nodes": [[["MidCat", 0, 0, ]]], "class_name": "Dense", "config": "name": "CatOscPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "CatOscPre", "inbound_nodes": [[["MidCat", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConFlt", "trainable": true, "dtype": "float32", "units": 8, "activation": "sigmoid", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConFlt", "inbound_nodes": [[["ConFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConMod", "trainable": true, "dtype": "float32", "units": 38, "activation": "sigmoid", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConMod", "inbound_nodes": [[["ConModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConOsc", "trainable": true, "dtype": "float32", "units": 12, "activation": "sigmoid", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConOsc", "inbound_nodes": [[["ConOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorAmp", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorAmp", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorEnv2", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorEnv2", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorEnv3", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorEnv3", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorLFO1", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorLFO1", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorLFO2", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorLFO2", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC1WT", "trainable": true, "dtype": "float32", "units": 194, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC1WT", "inbound_nodes": [[["CatWTPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC2WT", "trainable": true, "dtype": "float32", "units": 194, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC2WT", "inbound_nodes": [[["CatWTPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1BpNMo", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1BpNMo", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1Lphp", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1LpHp", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1ON", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1ON", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1Slope", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1Slope", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1Type", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1Type", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2BpNMo", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2BpNMo", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2LpHp", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2LpHp", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2ON", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2ON", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2Slope", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2Slope", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2Type", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2Type", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "GlobalFltRouting", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "GlobalFltRouting", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "AmpLoop", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "AmpLoop", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Env2Loop", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Env2Loop", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Env3Loop", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Env3Loop", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "LFO1Shape", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "LFO1Shape", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "LFO2Shape", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "LFO2Shape", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC1FxMode", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC1FxMode", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC1Transpose", "trainable": true, "dtype": "float32", "units": 49, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC1Transpose", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC2FxMode", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC2FxMode", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC2Transpose", "trainable": true, "dtype": "float32", "units": 49, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC2Transpose", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "SubTranspose", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "SubTranspose", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "UniMode", "trainable": true, "dtype": "float32", "units": 7, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "UniMode", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "UniVoiceCount", "trainable": true, "dtype": "float32", "units": 7, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "UniVoiceCount", "inbound_nodes": [[["CatOscPre", 0, 0, ]]]], "input_layers": [["Input", 0, 0]], "output_layers": [["ConFlt", 0, 0], ["ConMod", 0, 0], ["ConOsc", 0, 0], ["ModVectorAmp", 0, 0], ["ModVectorEnv2", 0, 0], ["ModVectorEnv3", 0, 0], ["ModVectorLFO1", 0, 0], ["ModVectorLFO2", 0, 0], ["OSC1WT", 0, 0], ["OSC2WT", 0, 0], ["Flt1BpNMo", 0, 0], ["Flt1LpHp", 0, 0], ["Flt1ON", 0, 0], ["Flt1Slope", 0, 0], ["Flt1Type", 0, 0], ["Flt2BpNMo", 0, 0], ["Flt2LpHp", 0, 0], ["Flt2ON", 0, 0], ["Flt2Slope", 0, 0], ["Flt2Type", 0, 0], ["GlobalFltRouting", 0, 0], ["AmpLoop", 0, 0], ["Env2Loop", 0, 0], ["Env3Loop", 0, 0], ["LFO1Shape", 0, 0], ["LFO2Shape", 0, 0], ["OSC1FxMode", 0, 0], ["OSC1Transpose", 0, 0], ["OSC2FxMode", 0, 0], ["OSC2Transpose", 0, 0], ["SubTranspose", 0, 0], ["UniMode", 0, 0], ["UniVoiceCount", 0, 0]], "keras_version": "2.4.0", "backend": "tensorflow"
【问题讨论】:
你有构建模型的代码吗?如果您的输入形状为(1024, 87, 16)
,您可以安全地将其更改为 (None, 86, 16)
以使用可变大小的批量维度。
@jakub 是的,这正是我想要的。我该怎么做?
可以分享wt_sm_model.json
的内容吗?应该在那里定义。
@jakub 是的,我做到了。我希望它是这样可读的。
【参考方案1】:
批量大小在 JSON 文件的模型定义中硬编码。
要使用可变批量大小,请在输入层中替换以下内容
"batch_input_shape": [1024, 87, 16]
与
"batch_input_shape": [null, 87, 16]
这是进行了更改的 JSON:
"class_name": "Functional", "config": "name": "model", "layers": ["class_name": "InputLayer", "config": "batch_input_shape": [null, 87, 16], "dtype": "float32", "sparse": false, "ragged": false, "name": "Input", "name": "Input", "inbound_nodes": [], "class_name": "Bidirectional", "config": "name": "BidirLSTM", "trainable": true, "dtype": "float32", "layer": "class_name": "LSTM", "config": "name": "lstm", "trainable": true, "batch_input_shape": [null, 87, 16], "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 64, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "recurrent_initializer": "class_name": "Orthogonal", "config": "gain": 1.0, "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "unit_forget_bias": true, "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.01, "recurrent_dropout": 0.01, "implementation": 1, "merge_mode": "concat", "name": "BidirLSTM", "inbound_nodes": [[["Input", 0, 0, ]]], "class_name": "Dense", "config": "name": "Dense", "trainable": true, "dtype": "float32", "units": 256, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Dense", "inbound_nodes": [[["BidirLSTM", 0, 0, ]]], "class_name": "BatchNormalization", "config": "name": "BatchNorm", "trainable": true, "dtype": "float32", "axis": [1], "momentum": 0.99, "epsilon": 0.001, "center": true, "scale": true, "beta_initializer": "class_name": "Zeros", "config": , "gamma_initializer": "class_name": "Ones", "config": , "moving_mean_initializer": "class_name": "Zeros", "config": , "moving_variance_initializer": "class_name": "Ones", "config": , "beta_regularizer": null, "gamma_regularizer": null, "beta_constraint": null, "gamma_constraint": null, "name": "BatchNorm", "inbound_nodes": [[["Dense", 0, 0, ]]], "class_name": "Dense", "config": "name": "MidCon", "trainable": true, "dtype": "float32", "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "MidCon", "inbound_nodes": [[["BatchNorm", 0, 0, ]]], "class_name": "Dense", "config": "name": "MidCat", "trainable": true, "dtype": "float32", "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "MidCat", "inbound_nodes": [[["BatchNorm", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConFltPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConFltPre", "inbound_nodes": [[["MidCon", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConModPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConModPre", "inbound_nodes": [[["MidCon", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConOscPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConOscPre", "inbound_nodes": [[["MidCon", 0, 0, ]]], "class_name": "Dense", "config": "name": "MidMtx", "trainable": true, "dtype": "float32", "units": 128, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "MidMtx", "inbound_nodes": [[["BatchNorm", 0, 0, ]]], "class_name": "Dense", "config": "name": "CatWTPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "CatWTPre", "inbound_nodes": [[["MidCat", 0, 0, ]]], "class_name": "Dense", "config": "name": "CatFltPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "CatFltPre", "inbound_nodes": [[["MidCat", 0, 0, ]]], "class_name": "Dense", "config": "name": "CatModPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "CatModPre", "inbound_nodes": [[["MidCat", 0, 0, ]]], "class_name": "Dense", "config": "name": "CatOscPre", "trainable": true, "dtype": "float32", "units": 32, "activation": "relu", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "CatOscPre", "inbound_nodes": [[["MidCat", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConFlt", "trainable": true, "dtype": "float32", "units": 8, "activation": "sigmoid", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConFlt", "inbound_nodes": [[["ConFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConMod", "trainable": true, "dtype": "float32", "units": 38, "activation": "sigmoid", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConMod", "inbound_nodes": [[["ConModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "ConOsc", "trainable": true, "dtype": "float32", "units": 12, "activation": "sigmoid", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ConOsc", "inbound_nodes": [[["ConOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorAmp", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorAmp", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorEnv2", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorEnv2", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorEnv3", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorEnv3", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorLFO1", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorLFO1", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "ModVectorLFO2", "trainable": true, "dtype": "float32", "units": 52, "activation": "tanh", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L1", "config": "l1": 0.05000000074505806, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "ModVectorLFO2", "inbound_nodes": [[["MidMtx", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC1WT", "trainable": true, "dtype": "float32", "units": 194, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC1WT", "inbound_nodes": [[["CatWTPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC2WT", "trainable": true, "dtype": "float32", "units": 194, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC2WT", "inbound_nodes": [[["CatWTPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1BpNMo", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1BpNMo", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1LpHp", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1LpHp", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1ON", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1ON", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1Slope", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1Slope", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt1Type", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt1Type", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2BpNMo", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2BpNMo", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2LpHp", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2LpHp", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2ON", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2ON", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2Slope", "trainable": true, "dtype": "float32", "units": 2, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2Slope", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Flt2Type", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Flt2Type", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "GlobalFltRouting", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "GlobalFltRouting", "inbound_nodes": [[["CatFltPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "AmpLoop", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "AmpLoop", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Env2Loop", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Env2Loop", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "Env3Loop", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "Env3Loop", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "LFO1Shape", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "LFO1Shape", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "LFO2Shape", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "LFO2Shape", "inbound_nodes": [[["CatModPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC1FxMode", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC1FxMode", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC1Transpose", "trainable": true, "dtype": "float32", "units": 49, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC1Transpose", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC2FxMode", "trainable": true, "dtype": "float32", "units": 5, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC2FxMode", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "OSC2Transpose", "trainable": true, "dtype": "float32", "units": 49, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "OSC2Transpose", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "SubTranspose", "trainable": true, "dtype": "float32", "units": 3, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "SubTranspose", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "UniMode", "trainable": true, "dtype": "float32", "units": 7, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "UniMode", "inbound_nodes": [[["CatOscPre", 0, 0, ]]], "class_name": "Dense", "config": "name": "UniVoiceCount", "trainable": true, "dtype": "float32", "units": 7, "activation": "softmax", "use_bias": true, "kernel_initializer": "class_name": "GlorotUniform", "config": "seed": null, "bias_initializer": "class_name": "Zeros", "config": , "kernel_regularizer": "class_name": "L2", "config": "l2": 0.009999999776482582, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "name": "UniVoiceCount", "inbound_nodes": [[["CatOscPre", 0, 0, ]]]], "input_layers": [["Input", 0, 0]], "output_layers": [["ConFlt", 0, 0], ["ConMod", 0, 0], ["ConOsc", 0, 0], ["ModVectorAmp", 0, 0], ["ModVectorEnv2", 0, 0], ["ModVectorEnv3", 0, 0], ["ModVectorLFO1", 0, 0], ["ModVectorLFO2", 0, 0], ["OSC1WT", 0, 0], ["OSC2WT", 0, 0], ["Flt1BpNMo", 0, 0], ["Flt1LpHp", 0, 0], ["Flt1ON", 0, 0], ["Flt1Slope", 0, 0], ["Flt1Type", 0, 0], ["Flt2BpNMo", 0, 0], ["Flt2LpHp", 0, 0], ["Flt2ON", 0, 0], ["Flt2Slope", 0, 0], ["Flt2Type", 0, 0], ["GlobalFltRouting", 0, 0], ["AmpLoop", 0, 0], ["Env2Loop", 0, 0], ["Env3Loop", 0, 0], ["LFO1Shape", 0, 0], ["LFO2Shape", 0, 0], ["OSC1FxMode", 0, 0], ["OSC1Transpose", 0, 0], ["OSC2FxMode", 0, 0], ["OSC2Transpose", 0, 0], ["SubTranspose", 0, 0], ["UniMode", 0, 0], ["UniVoiceCount", 0, 0]], "keras_version": "2.4.0", "backend": "tensorflow"
【讨论】:
以上是关于模型预测:不兼容的形状的主要内容,如果未能解决你的问题,请参考以下文章
在 Keras 中训练对象检测模型时出现不兼容张量形状的问题