简体   繁体   中英

ValueError: Shapes (10000, 11) and (10000, 1) are incompatible Tensorflow

I've seen this error, however, I'm unsure how to fix it in my case. My repo for all the code and dataset: https://github.com/itisyeetimetoday/reggression

regressor = skflow.DNNRegressor(feature_columns=feature_columns,
            label_dimension=11,
            hidden_units=hidden_layers,
            model_dir=MODEL_PATH,
            dropout=dropout,
            config=test_config,
            activation_fn = tf.nn.relu,
            optimizer  = tf.compat.v1.train.AdamOptimizer(learning_rate = learning_rate)

However, the above line generates this error: ValueError: Shapes (10000, 11) and (10000, 1) are incompatible

Technically, the fit line is getting the error, but the model parameters that can solve the error. I've tried changing the dimensions to 10 in case TensorFlow starts at 0, but this didn't work. How do I fix the error? Thank you.

ValueError: Shapes (batch, 11) and (batch, 1) are incompatible

Error indicates that the model expects output shape to be (10000, 11) whereas the true label shape is (10000, 1). So, You have to change the label_dimension=1 .

regressor = skflow.DNNRegressor(feature_columns=feature_columns,
            label_dimension=1,
            hidden_units=hidden_layers,
            model_dir=MODEL_PATH,
            dropout=dropout,
            config=test_config,
            activation_fn = tf.nn.relu,
            optimizer  = tf.compat.v1.train.AdamOptimizer(learning_rate = learning_rate)

In case of 11 output nodes , you should change the dimension of your training dataset label from 1 to 11.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM