0
다음 line있다 :상수 Tensor를 생성하는 동안 "CopyFrom"이 사용되는 이유는 무엇입니까? 상수 텐서의 생성 과정에서
tensor_value.tensor.CopyFrom(
tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape))
CopyFrom
새로 만든 텐서 프로토의 복사본을 생성한다. 그러나 이것은 문서에 따라 make_tensor_proto
이 새로운 개체를 생성하기 때문에 대처를위한 자원 낭비처럼 보입니다.
tensor_value.tensor =
tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape)
이 새로운 개체를 만들 수 없습니다해야, 플러스 그것은 또한 OneOf protobuf 필드의 올바른 사용법이다 : 더 충분하다, 바로 옆에해야 할 일.
이 문서에 설명 된대로 당신은 프로토의 필드에 프로토를 할당 할 수 없습니다
좋은 점 : 당신이 CopyFrom입니다을 제거하면 https://developers.google.com/protocol-buffers/docs/reference/python-generated
하면, 다음과 같은 오류가 발생합니다 , CopyFrom을 제거하고 테스트를 수행합니다. – yuefengz