我希望创建如下图,其中显示一些值和标准差。
我有两组值,包含通过两种不同方法获得的平均值和标准差。我想过用seaborn来做这件事,但我不知道到底该怎么做,因为官方示例使用了我不熟悉的 pandas DataFrame 对象。
作为示例,请考虑以下起始代码:
import seaborn as sns
mean_1 = [10, 20, 30, 25, 32, 43]
std_1 = [2.2, 2.3, 1.2, 2.2, 1.8, 3.5]
mean_2 = [12, 22, 30, 13, 33, 39]
std_2 = [2.4, 1.3, 2.2, 1.2, 1.9, 3.5]
Run Code Online (Sandbox Code Playgroud)
谢谢你,
G。
我想在与维度为[batch_size, H, W, n_channels]的矩阵中每个像素的深度通道相对应的每个向量上映射一个 TensorFlow 函数。
换句话说,对于批次中大小为H x W的每个图像:
下面有一张解释该过程的图片。与图片的唯一区别是输入和输出“感受野”的大小均为 1x1(独立地将函数应用于每个像素)。
这类似于对矩阵应用 1x1 卷积;但是,我需要在深度通道上应用更通用的函数,而不是简单的求和运算。
我认为tf.map_fn()
可能是一个选项,我尝试了以下解决方案,其中我递归地使用tf.map_fn()
来访问与每个像素相关的功能。然而,这种似乎不是最优的,最重要的是,它在尝试反向传播梯度时会引发错误。
您知道发生这种情况的原因以及我应该如何构建代码以避免错误吗?
这是我当前对该功能的实现:
import tensorflow as tf
from tensorflow import layers
def apply_function_on_pixel_features(incoming):
# at first the input is [None, W, H, n_channels]
if len(incoming.get_shape()) > 1: …
Run Code Online (Sandbox Code Playgroud) 我想迭代 bash 中的成对元素。在 Python 中,这很简单:
x_list = [1, 2, 3, 4]
y_list = ["a", "b", "c", "d"]
for x, y in zip(x_list , y_list):
# here we have access to the values (i.e. the pairs are assigned to variables):
result = do_something(x, y)
print(result)
Run Code Online (Sandbox Code Playgroud)
我如何在 bash 中复制这种行为?我需要将这些对的值存储到 for 循环内部的变量中,以便我可以执行一些操作。它应该是这样的:
for x, y in 1a 2b 3c 4d
do
python script.py --x_value=${x} --y_value=${y}
done
Run Code Online (Sandbox Code Playgroud)
请注意,列表的元素也可能是复杂的东西,例如:
x_list = [1e-5, 1e-4, 1e-3]
和y_list = [10, 20, 30]
bash ×1
gradient ×1
loops ×1
map-function ×1
nested ×1
plot ×1
python ×1
seaborn ×1
tensorflow ×1