TfCheckpoint 1.0.0

.NET 5.0
dotnet add package TfCheckpoint --version 1.0.0
NuGet\Install-Package TfCheckpoint -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TfCheckpoint" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TfCheckpoint --version 1.0.0
#r "nuget: TfCheckpoint, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install TfCheckpoint as a Cake Addin
#addin nuget:?package=TfCheckpoint&version=1.0.0

// Install TfCheckpoint as a Cake Tool
#tool nuget:?package=TfCheckpoint&version=1.0.0

TfCheckpoint

A library to extract tensor data from a Tensorflow checkpoint folder. The main use it to load pre-trained weights into model structures e.g. for PyTorch models.

Usage Example


let idxFile = @"C:\s\hack\uncased_L-2_H-128_A-2\bert_model.ckpt.index"

let tensors = CheckpointReader.readCheckpoint (Path.GetDirectoryName idxFile) |> Seq.toArray

let (tensorName,tensorData) = tensors.[0]

Output:

val tensorName: string = "bert/embeddings/LayerNorm/beta"
val tensorData: CheckpointReader.ShapedTensor =
  { Shape = [|128L|]
    Tensor =
     TdFloat
       [|0.1427177936f; 0.1417384148f; 0.1129989177f; 0.008431605063f;
         -0.3839171827f; -0.04579306394f; -0.009391464293f; 0.2562615871f;
         0.02031775191f; -0.1169935018f; 0.04341379181f; -0.03693608567f;
         -0.1498966217f; -0.04671567678f; -0.05263318121f; -0.1550539136f;
         ...

Build Instructions

The build relies on Tensorflow Protobuf definitions. The Tensorflow repo should be copied into the folder for the TfProto project such that the .proto file references in the .fsproj file are valid.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TfCheckpoint:

Package Downloads
TsBERT

BERT model in TorchSharp with the ability to load pre-trained weights from Google BERT checkpoints. This model produces a single value per input sequence - suitable for tasks such as text classification.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 216 11/16/2021