我用参数创建了自定义损失函数。
def w_categorical_crossentropy(weights):
def loss(y_true, y_pred):
print(weights)
print("----")
print(weights.shape)
final_mask = K.zeros_like(y_pred[:, 0])
y_pred_max = K.max(y_pred, axis=1)
y_pred_max = K.reshape(y_pred_max, (K.shape(y_pred)[0], 1))
y_pred_max_mat = K.cast(K.equal(y_pred, y_pred_max), K.floatx())
return K.categorical_crossentropy(y_pred, y_true)
return loss
Run Code Online (Sandbox Code Playgroud)
现在,我需要控制权重参数值,但打印功能无法正常工作。有没有办法打印权重值?
我试图了解 bazel 的目的和用法。
对于 这个项目,运行命令是bazel run -c opt :train_ptn -- --init_model={}。这个命令和只有python train_ptn.py 有什么区别?
另外,这个github项目只包含python脚本,为什么我们需要bazel来运行这个项目?
我尝试在 python 中实现以下 C++ 代码:
depth.convertTo(depth, CV_64FC1); // I do not know why it is needed to be
transformed to 64bit image my input is 32bit
Mat nor(depth.size(), CV_64FC3);
for(int x = 1; x < depth.cols - 1; ++x)
{
for(int y = 1; y < depth.rows - 1; ++y)
{
Vec3d t(x,y-1,depth.at<double>(y-1, x)/*depth(y-1,x)*/);
Vec3d l(x-1,y,depth.at<double>(y, x-1)/*depth(y,x-1)*/);
Vec3d c(x,y,depth.at<double>(y, x)/*depth(y,x)*/);
Vec3d d = (l-c).cross(t-c);
Vec3d n = normalize(d);
nor.at<Vec3d>(y,x) = n;
}
}
imshow("normals", nor);
Run Code Online (Sandbox Code Playgroud)
蟒蛇代码:
d_im = cv2.imread("depth.jpg")
d_im …
Run Code Online (Sandbox Code Playgroud)