TfCheckpoint 1.0.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 and Polyglot Notebooks. 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 Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 577 11/16/2021