detection / Tensorflow /models /official /projects /yolo /ops /initializer_ops.py
Kasamuday's picture
Upload 4315 files
07ef7ab verified
Raw
History Blame Contribute Delete
1.02 kB
# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Yolo initializer ops."""
import tensorflow as tf, tf_keras
def pytorch_kernel_initializer(kernel_initializer):
"""Prepare kernel weights initializer to match PyTorch implementation."""
if kernel_initializer == 'VarianceScaling':
return tf_keras.initializers.VarianceScaling(
scale=1 / 3, mode='fan_in', distribution='uniform'
)
return kernel_initializer