0
以下是math_grad.cc line543到line554:FunctionDefHelper :: Create和FunctionDefHelper :: Define有什麼區別?
543 *g = FDH::Create("_",
544 // Input defs
545 {"x:T", "i:int32", "dy:T"},
546 // Ret val defs
547 {"dx:T", "di:int32"},
548 // Attr defs
549 {{"T: {half, float, double}"}},
550 // Nodes
551 nodes,
552 // Return values
553 {{"dx", "dx:output:0"}, {"di", "di:y:0"}});
554 return Status::OK();
及以下爲math_grad.cc line593到line615,
593 Status MinMaxGradHelper(const string& op, const AttrSlice& attrs,
594 FunctionDef* g) {
595 // clang-format off
596 *g = FDH::Define(
597 // Arg defs
598 {"x:T", "i:int32", "dy:T"},
599 // Ret val defs
600 {"dx:T", "di:int32"},
601 // Attr defs
602 {{"T: {half, float, double}"}},
603 {
604 // keep_dims because we need to do x == y, which requires x
605 // and y are broadcastable.
606 {{"y"}, op, {"x", "i"}, {{"T", "$T"}, {"keep_dims", true}}},
607 {{"mask"}, "Equal", {"x", "y"}, {{"T", "$T"}}},
608 {{"mask_cast"}, "Cast", {"mask"}, {{"SrcT", DT_BOOL}, {"DstT", "$T"}}},
609 {{"mask_sum"}, "Sum", {"mask_cast", "i"}, {{"T", "$T"}}},
610 {{"norm_dy"}, "Div", {"dy", "mask_sum"}, {{"T", "$T"}}},
611 {{"sy"}, "Shape", {"y"}, {{"T", "$T"}}},
612 {{"norm_dy_reshaped"}, "Reshape", {"norm_dy", "sy"}, {{"T", "$T"}}},
613 {{"dx"}, "Mul", {"mask_cast", "norm_dy_reshaped"}, {{"T", "$T"}}},
614 {{"di"}, "ZerosLike", {"i"}, {{"T", DT_INT32}}}
615 });
我有點困惑如何做TensorFlow確定是否使用 FDH :: Define或FDH :: Create。
據我所知,FDH :: Define是定義FunctionDef的老手。我認爲與FDH :: Create相比,FDH :: Define提供的信息更少。
那麼,任何人都可以幫助我區分?任何意見將不勝感激,非常感謝。從同事