pytorch与tensorflow API速查表
方法名称 | pytroch | tensorflow | numpy |
---|---|---|---|
裁剪 | torch.clamp(x, min, max) | tf.clip_by_value(x, min, max) | np.clip(x, min, max) |
取最大值 | torch.max(x, dim)[0] | tf.max(x, axis) | np.max(x, axis) |
取最小值 | torch.min(x, dim)[0] | tf.min(x, axis) | np.min(x , axis) |
取两个tensor的最大值 | torch.max(x, y) | tf.maximum(x, y) | np.maximum(x, y) |
取两个tensor的最小值 | torch.min(x, y) | torch.minimum(x, y) | np.minmum(x, y) |
取最大值索引 | torch.max(x, dim)[1] | tf.argmax(x, axis) | np.argma |