Environment: Python 3.6, TensorFlow 1.15
Hope for augmentation, using tf keras. Preprocessing. Image. Random_shift function
Unsupported operand type(s) for *: ‘Dimension’ and ‘float’
Line 446 in tensor_shape.py is return self * other
Return self * other –> return self * other –> return self * int(other)
The random_shift function does not work, and the image does not have any shift effects
As a last resort, change the design function to achieve random_shift function function
According to my requirements, first of all, two random numbers are generated by TF.Random. Uniform, which are used as the translation pixels of the width and height dimensions of the image. Then use tf.roll to translate the image in two dimensions of height and width. The code is as follows:
Hope for augmentation, using tf keras. Preprocessing. Image. Random_shift function
Unsupported operand type(s) for *: ‘Dimension’ and ‘float’
Line 446 in tensor_shape.py is return self * other
Return self * other –> return self * other –> return self * int(other)
The random_shift function does not work, and the image does not have any shift effects
As a last resort, change the design function to achieve random_shift function function
According to my requirements, first of all, two random numbers are generated by TF.Random. Uniform, which are used as the translation pixels of the width and height dimensions of the image. Then use tf.roll to translate the image in two dimensions of height and width. The code is as follows:
shift_num = tf.random.uniform(shape=[2], minval=-img_height/2, maxval=img_height/2, dtype=tf.dtype.int32)
img_out = tf.roll(img_in, shift=shift_num, axis=[1,2])
This code does what I need the random_shift function to do, but it’s slow
over
Read More:
- Random number random reports an error. Illegalargumentexception: bound must be positive
- Two deformation methods of tensorflow image
- In tensorflow tf.reduce_ Mean function
- “Typeerror: invalid dimensions for image data” in Matplotlib drawing imshow() function
- Tensorflow in function tf.Print Method of outputting intermediate value
- Matlab: Three forms of random number generated (Rand, Randi and Randn)
- To solve the problem of importerror when installing tensorflow: libcublas.so . 10.0, failed to load the native tensorflow runtime error
- Using pip to install tensorflow: tensorflow — is not a supported wheel on this platform
- Record a problem of no module named ‘tensorflow. Examples’ and’ tensorflow. Examples. Tutorials’ in tensorflow 2.0
- Wrong path to add PCH file. Apple llvm 9.0 – language cannot be found in the new project
- Solutions to Excel 2007 “cannot shift object off sheet”
- numpy.random.rand()
- Tensorflow: How to use expand_Dim() to add dimensions
- Importerror using tensorflow: DLL load failed: the specified program cannot be found
- Tensorflow import error: DLL load failed: the specified module could not be found
- Tensorflow error: module ‘tensorflow’ has no attribute ‘xxx’
- After tensorflow installation, an error occurred while importing: importerror: DLL load failed: the specified module could not be found
- Converting PDF file to JPG image in Ubuntu
- Tensorflow error: attributeerror: module ‘tensorflow’ has no attribute ‘unpack’ (‘pack ‘)
- 26 English letters in upper and lower case and 0-9 to generate 8-bit random password