when learning simple neural network with tensorflow, the following error is reported:
DeprecationWarning: elementwise == comparison failed; this will raise an error
the reason is: when processing the data, I ran the following code, and then re-pasted a copy, running it again, making the data become three-dimensional, causing the mismatch of the data:
code:
image_size = 28
num_labels = 10
def reformat(dataset, labels):
dataset = dataset.reshape((-1, image_size * image_size)).astype(np.float32)
# Map 0 to [1.0, 0.0, 0.0 ...], 1 to [0.0, 1.0, 0.0 ...]
labels = (np.arange(num_labels) == labels[:,None]).astype(np.float32)
return dataset, labels
train_dataset, train_labels = reformat(train_dataset, train_labels)
valid_dataset, valid_labels = reformat(valid_dataset, valid_labels)
test_dataset, test_labels = reformat(test_dataset, test_labels)
print('Training set', train_dataset.shape, train_labels.shape)
print('Validation set', valid_dataset.shape, valid_labels.shape)
print('Test set', test_dataset.shape, test_labels.shape)
correct result:
Training set (200000, 784) (200000, 10)
Validation set (10000, 784) (10000, 10)
Test set (10000, 784) (10000, 10)
run error result:
Training set (200000, 784) (200000, 1, 10)
Validation set (10000, 784) (10000, 1, 10)
Test set (10000, 784) (10000, 1, 10)
obviously, the dimension of the data is wrong
solution: rerun the first time the program can be allowed only once.
Read More:
- Record a problem of no module named ‘tensorflow. Examples’ and’ tensorflow. Examples. Tutorials’ in tensorflow 2.0
- WARNING:tensorflow:`add_update` `inputs` kwarg has been deprecated.
- Ora-02292: integrity constraint (XX) violated – child record found foreign key Association, record cannot be deleted
- Resolve – keyerror encountered while installing tensorflow GPU: ‘tensorflow’ error
- Tensorflow error: attributeerror: module ‘tensorflow’ has no attribute ‘unpack’ (‘pack ‘)
- Using pip to install tensorflow: tensorflow — is not a supported wheel on this platform
- Tensorflow error: module ‘tensorflow’ has no attribute ‘xxx’
- Tensorflow operation report error modulenotfounderror: no module named ‘tensorflow. Python. Types’ solution
- To solve the problem of importerror when installing tensorflow: libcublas.so . 10.0, failed to load the native tensorflow runtime error
- Gcc compiler warning solution: “extra tokens at end of ifndef directive” Tags: GCC, warning
- Tensorflow ValueError: Failed to convert a NumPy array to a Tensor
- In tensorflow tf.reduce_ Mean function
- Tensorflow in function tf.Print Method of outputting intermediate value
- Tensorflow reported an error when using session module: attributeerror: module ‘tensorflow’ has no attribute ‘session’, which has been solved
- Tensorflow image random_ There seems to be something wrong with the shift function
- Visio2007 usage record
- Tensorflow: How to use expand_Dim() to add dimensions
- Commandinvocationfailure: failed to build APK problem record
- OpenGL step pit record
- Visionox shows app development record