tensor操作
reshape
keras.backend.reshape(x,shape)
Arguments
- x:Tensor or variable
- shape:Target shape tuple
permute_dimensions
keras.backend.permute_dimensions(x,pattern)
Arguments
- pattern: A tuple of dimension indices eg.(0,2,1)
resize_images
keras.backend.resize_images(x, height_factor, width_factor, data_format, interpolation='nearest')
Resizes the images contained in a 4D tensor.
Arguments
- x: Tensor or variable to resize.
- height_factor: Positive integer.
- width_factor: Positive integer.
- data_format: string, "channels_last" or "channels_first".
- interpolation: A string, one of nearest or bilinear.
resize_volumes
keras.backend.resize_volumes(x, depth_factor, height_factor, width_factor, data_format)
Resizes the volume contained in a 5D tensor.
Arguments
- x: Tensor or variable to resize.
- depth_factor: Positive integer.
- height_factor: Positive integer.
- width_factor: Positive integer.
- data_format: string, "channels_last" or "channels_first".
arange
keras.backend.arange(start, stop=None, step=1, dtype='int32')
Creates a 1D tensor containing a sequence of integers.
Arguments
- start: Start value.
- stop: Stop value.
- step: Difference between two successive values.
- dtype: Integer dtype to use.
tile
keras.backend.tile(x, n)
Creates a tensor by tiling x by n.return a tiled tensor .网格化tensor,像瓷砖一样铺展开来,类似于repeat复制
Arguments
- x: A tensor or variable
- n: A list of integer. The length must be the
- same as the number of dimensions in x.
batch_flatten
keras.backend.batch_flatten(x)
Turn a nD tensor into a 2D tensor with same 0th dimension.
In other words, it flattens each data samples of a batch.按batch展开tensor。
expand_dims
keras.backend.expand_dims(x, axis=-1)
在指定的轴上进行维度拓展
Arguments
- x: A tensor or variable.
- axis: Position where to add a new axis.
squeeze
keras.backend.squeeze(x,axis)
Removes a 1-dimension from the tensor at index "axis".
降低指定轴上的维度
cast
keras.backend.cast(x, dtype)
Casts a tensor to a different dtype and returns it.
You can cast a Keras variable but it still returns a Keras tensor.
数据类型转化






网友评论