view release on metacpan or search on metacpan
List::SomeUtils = 0
Module::Runtime = 0
Mu = 0
Path::Tiny = 0
Sort::Key::Multi = 0
Sub::Uplevel = 0
Syntax::Construct = 0
Types::Path::Tiny = 0
[Encoding / ModelData]
encoding = bytes
match = \.pb$
match = t/upstream/tensorflow/cc/saved_model/testdata/
[MetaNoIndex]
directory = maint
lib/AI/TensorFlow/Libtensorflow.pm view on Meta::CPAN
}
$ffi->attach( 'Version' => [], 'string' );#}}}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow - Bindings for Libtensorflow deep learning library
=for html <a href="https://mybinder.org/v2/gh/EntropyOrg/perl-AI-TensorFlow-Libtensorflow/master"><img src="https://mybinder.org/badge_logo.svg" alt="Binder" /></a>
<a href="https://quay.io/repository/entropyorg/perl-ai-tensorflow-libtensorflow"><img src="https://img.shields.io/badge/quay.io-images-red.svg" alt="quay.io images" /></a>
=head1 SYNOPSIS
lib/AI/TensorFlow/Libtensorflow/ApiDefMap.pm view on Meta::CPAN
arg 'tf_text_buffer' => [qw(name name_len)],
arg 'TF_Status' => 'status',
] => 'TF_Buffer');
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::ApiDefMap - Maps Operation to API description
=head1 SYNOPSIS
use aliased 'AI::TensorFlow::Libtensorflow::ApiDefMap' => 'ApiDefMap';
=head1 CONSTRUCTORS
lib/AI/TensorFlow/Libtensorflow/Buffer.pm view on Meta::CPAN
$ffi->attach( [ 'DeleteBuffer' => 'DESTROY' ] => [ 'TF_Buffer' ], 'void' );
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Buffer - Buffer that holds pointer to data with length
=head1 SYNOPSIS
use aliased 'AI::TensorFlow::Libtensorflow::Buffer' => 'Buffer';
=head1 DESCRIPTION
lib/AI/TensorFlow/Libtensorflow/DataType.pm view on Meta::CPAN
}
sub _op_stringify { $_REV_ENUM_DTYPE{ 0 + ${$_[0]}} }
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::DataType - Datatype enum
=head1 SYNOPSIS
use AI::TensorFlow::Libtensorflow::DataType qw(FLOAT @DTYPES);
use List::Util qw(max);
lib/AI/TensorFlow/Libtensorflow/DeviceList.pm view on Meta::CPAN
TPU => "TPU",
TPU_SYSTEM => "TPU_SYSTEM",
);
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::DeviceList - A list of devices available for the session to run on
=head1 ATTRIBUTES
=head2 Count
B<C API>: L<< C<TF_DeviceListCount>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_DeviceListCount >>
lib/AI/TensorFlow/Libtensorflow/Eager/Context.pm view on Meta::CPAN
arg TF_Status => 'status'
] => 'TFE_Context' => sub {
my ($xs, $class, @rest) = @_;
$xs->(@rest);
} );
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Eager::Context - Eager context
=head1 CONSTRUCTORS
=head2 New
B<C API>: L<< C<TFE_NewContext>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TFE_NewContext >>
lib/AI/TensorFlow/Libtensorflow/Eager/ContextOptions.pm view on Meta::CPAN
arg TFE_ContextOptions => 'options'
] => 'void' );
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Eager::ContextOptions - Eager context options
=head1 CONSTRUCTORS
=head2 New
B<C API>: L<< C<TFE_NewContextOptions>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TFE_NewContextOptions >>
lib/AI/TensorFlow/Libtensorflow/Graph.pm view on Meta::CPAN
arg TF_Buffer => 'output_op_def',
arg TF_Status => 'status',
] => 'void');
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Graph - A TensorFlow computation, represented as a dataflow graph
=head1 SYNOPSIS
use aliased 'AI::TensorFlow::Libtensorflow::Graph' => 'Graph';
=head1 DESCRIPTION
lib/AI/TensorFlow/Libtensorflow/ImportGraphDefOptions.pm view on Meta::CPAN
arg string => 'src_name',
arg TF_Operation => 'dst',
] => 'void' );
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::ImportGraphDefOptions - Holds options that can be passed to ::Graph::ImportGraphDef
=head1 CONSTRUCTORS
=head2 New
B<C API>: L<< C<TF_NewImportGraphDefOptions>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_NewImportGraphDefOptions >>
lib/AI/TensorFlow/Libtensorflow/ImportGraphDefResults.pm view on Meta::CPAN
"int[$num_missing_unused_input_mappings]", $src_indexes);
return [ List::Util::zip($src_names_str, $src_indexes_int) ];
});
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::ImportGraphDefResults - Results from importing a graph definition
=head1 METHODS
=head2 ReturnOutputs
B<C API>: L<< C<TF_ImportGraphDefResultsReturnOutputs>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_ImportGraphDefResultsReturnOutputs >>
lib/AI/TensorFlow/Libtensorflow/Input.pm view on Meta::CPAN
record_module => __PACKAGE__, with_size => 1,
),
=> 'TF_Input_array_sz');
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Input - Input of operation as (operation, index) pair
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 COPYRIGHT AND LICENSE
lib/AI/TensorFlow/Libtensorflow/Lib.pm view on Meta::CPAN
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib - Private class for AI::TensorFlow::Libtensorflow
=head2 C<tensorflow/c/c_api.h>
=head3 TF_SessionOptions
L<AI::TensorFlow::Libtensorflow::SessionOptions>
lib/AI/TensorFlow/Libtensorflow/Lib/FFIType/TFPtrPtrLenSizeArrayRefScalar.pm view on Meta::CPAN
argument_count => 3,
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib::FFIType::TFPtrPtrLenSizeArrayRefScalar - Type to hold string list as void** strings, size_t* lengths, int num_items
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 COPYRIGHT AND LICENSE
lib/AI/TensorFlow/Libtensorflow/Lib/FFIType/TFPtrSizeScalar.pm view on Meta::CPAN
argument_count => 2,
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib::FFIType::TFPtrSizeScalar - Type to hold pointer and size in a scalar (input only)
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 COPYRIGHT AND LICENSE
lib/AI/TensorFlow/Libtensorflow/Lib/FFIType/TFPtrSizeScalarRef.pm view on Meta::CPAN
argument_count => 2,
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib::FFIType::TFPtrSizeScalarRef - Type to hold pointer and size in a scalar reference
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 COPYRIGHT AND LICENSE
lib/AI/TensorFlow/Libtensorflow/Lib/FFIType/Variant/PackableArrayRef.pm view on Meta::CPAN
die "Won't clobber $package" if $INC{module_notional_filename $package};
return $package;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib::FFIType::Variant::PackableArrayRef - ArrayRef to pack()'ed scalar argument with size argument (as int)
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 COPYRIGHT AND LICENSE
lib/AI/TensorFlow/Libtensorflow/Lib/FFIType/Variant/PackableMaybeArrayRef.pm view on Meta::CPAN
die "Won't clobber $package" if $INC{module_notional_filename $package};
return $package;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib::FFIType::Variant::PackableMaybeArrayRef - Maybe[ArrayRef] to pack()'ed scalar argument with size argument (as int) (size is -1 if undef)
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 COPYRIGHT AND LICENSE
lib/AI/TensorFlow/Libtensorflow/Lib/FFIType/Variant/RecordArrayRef.pm view on Meta::CPAN
die "Won't clobber $package" if $INC{module_notional_filename $package};
return $package;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib::FFIType::Variant::RecordArrayRef - Turn FFI::Platypus::Record into packed array (+ size)?
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 COPYRIGHT AND LICENSE
lib/AI/TensorFlow/Libtensorflow/Lib/Types.pm view on Meta::CPAN
index => $_->[1],
});
};
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib::Types - Type library
=head1 TYPES
=head2 TFTensor
Type for class L<AI::TensorFlow::Libtensorflow::Tensor>.
lib/AI/TensorFlow/Libtensorflow/Lib/_Alloc.pm view on Meta::CPAN
my ($class, $ptr) = @_;
_aligned_free($ptr);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Lib::_Alloc - [private] Allocation utilities
=head1 AUTHOR
Zakariyya Mughal <zmughal@cpan.org>
=head1 COPYRIGHT AND LICENSE
lib/AI/TensorFlow/Libtensorflow/Manual.pod view on Meta::CPAN
# ABSTRACT: Index of manual
# PODNAME: AI::TensorFlow::Libtensorflow::Manual
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Manual - Index of manual
=head1 TABLE OF CONTENTS
=over 4
=item L<AI::TensorFlow::Libtensorflow::Manual::Quickstart>
lib/AI/TensorFlow/Libtensorflow/Manual/CAPI.pod view on Meta::CPAN
# PODNAME: AI::TensorFlow::Libtensorflow::Manual::CAPI
# ABSTRACT: List of functions exported by TensorFlow C API
# DO NOT EDIT: Generated by process-capi.pl
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Manual::CAPI - List of functions exported by TensorFlow C API
=head1 DESCRIPTION
The following a list of functions exported by the TensorFlow C API with their
associated documentation from the upstream TensorFlow project. It has been
converted to POD for easy reference.
lib/AI/TensorFlow/Libtensorflow/Manual/GPU.pod view on Meta::CPAN
# ABSTRACT: GPU-specific installation and usage information.
# PODNAME: AI::TensorFlow::Libtensorflow::Manual::GPU
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Manual::GPU - GPU-specific installation and usage information.
=head1 DESCRIPTION
This guide provides information about using the GPU version of
C<libtensorflow>. This is currently specific to NVIDIA GPUs as
they provide the CUDA API that C<libtensorflow> targets for GPU devices.
lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubCenterNetObjDetect.pod view on Meta::CPAN
my $total = du( { 'human-readable' => 1, dereference => 1 },
$model_archive_path, $model_base );
say "Disk space usage: $total"; undef;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubCenterNetObjDetect - Using TensorFlow to do object detection using a pre-trained model
=head1 SYNOPSIS
The following tutorial is based on the L<TensorFlow Hub Object Detection Colab notebook|https://www.tensorflow.org/hub/tutorials/tf2_object_detection>. It uses a pre-trained model based on the I<CenterNet> architecture trained on the I<COCO 2017> dat...
Some of this code is identical to that of C<InferenceUsingTFHubMobileNetV2Model> notebook. Please look there for an explanation for that code. As stated there, this will later be wrapped up into a high-level library to hide the details behind an API.
lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod view on Meta::CPAN
my $encoded = $encoder->index( $p->dummy(0) );
return $encoded;
}
####
{
say "Testing one-hot encoding:\n";
my $onehot_test_seq = "ACGTNtgcan";
my $test_encoded = one_hot_dna( $onehot_test_seq );
$SHOW_ENCODER = 0;
say "One-hot encoding of sequence '$onehot_test_seq' is:";
say $test_encoded->info, $test_encoded;
}
package Interval {
use Bio::Location::Simple ();
use parent qw(Bio::Location::Simple);
sub center {
lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod view on Meta::CPAN
$plot_output_path,
);
say "Disk space usage: $total"; undef;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubEnformerGeneExprPredModel - Using TensorFlow to do gene expression prediction using a pre-trained model
=head1 SYNOPSIS
The following tutorial is based on the L<Enformer usage notebook|https://github.com/deepmind/deepmind-research/blob/master/enformer/enformer-usage.ipynb>. It uses a pre-trained model based on a transformer architecture trained as described in Avsec e...
Running the code requires an Internet connection to download the model (from Google servers) and datasets (from GitHub, UCSC, and NIH).
lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod view on Meta::CPAN
all of which are C<DT_FLOAT>.
Make note of the shapes that those take. Per the L<model description|https://tfhub.dev/deepmind/enformer/1> at TensorFlow Hub:
=over 2
The input sequence length is 393,216 with the prediction corresponding to 128 base pair windows for the center 114,688 base pairs. The input sequence is one hot encoded using the order of indices corresponding to 'ACGT' with N values being all zeros.
=back
The input shape C<(-1, 393216, 4)> thus represents dimensions C<[batch size] x [sequence length] x [one-hot encoding of ACGT]>.
The output shape C<(-1, 896, 5313)> represents dimensions C<[batch size] x [ predictions along 114,688 base pairs / 128 base pair windows ] x [ human target by index ]>. We can confirm this by doing some calculations:
my $model_central_base_pairs_length = 114_688; # bp
my $model_central_base_pair_window_size = 128; # bp / prediction
say "Number of predictions: ", $model_central_base_pairs_length / $model_central_base_pair_window_size;
B<STREAM (STDOUT)>:
lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod view on Meta::CPAN
);
AssertOK($s);
return $outputs_t[0];
};
undef;
=head2 Encoding the data
The model specifies that the way to get a sequence of DNA bases into a C<TFTensor> is to use L<one-hot encoding|https://en.wikipedia.org/wiki/One-hot#Machine_learning_and_statistics> in the order C<ACGT>.
This means that the bases are represented as vectors of length 4:
| base | vector encoding |
|------|-----------------|
| A | C<[1 0 0 0]> |
| C | C<[0 1 0 0]> |
| G | C<[0 0 1 0]> |
| T | C<[0 0 0 1]> |
| N | C<[0 0 0 0]> |
We can achieve this encoding by creating a lookup table with a PDL ndarray. This could be done by creating a byte PDL ndarray of dimensions C<[ 256 4 ]> to directly look up the the numeric value of characters 0-255, but here we'll go with a smaller C...
use PDL;
our $SHOW_ENCODER = 1;
sub one_hot_dna {
my ($seq) = @_;
my $from_alphabet = "NACGT";
my $to_alphabet = pack "C*", 0..length($from_alphabet)-1;
lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubEnformerGeneExprPredModel.pod view on Meta::CPAN
my $encoded = $encoder->index( $p->dummy(0) );
return $encoded;
}
####
{
say "Testing one-hot encoding:\n";
my $onehot_test_seq = "ACGTNtgcan";
my $test_encoded = one_hot_dna( $onehot_test_seq );
$SHOW_ENCODER = 0;
say "One-hot encoding of sequence '$onehot_test_seq' is:";
say $test_encoded->info, $test_encoded;
}
B<STREAM (STDOUT)>:
Testing one-hot encoding:
Encoder is
PDL: Float D [5,4]
[
[0 1 0 0 0]
[0 0 1 0 0]
[0 0 0 1 0]
[0 0 0 0 1]
]
One-hot encoding of sequence 'ACGTNtgcan' is:
PDL: Float D [4,10]
[
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
[0 0 0 0]
[0 0 0 1]
[0 0 1 0]
[0 1 0 0]
lib/AI/TensorFlow/Libtensorflow/Manual/Notebook/InferenceUsingTFHubMobileNetV2Model.pod view on Meta::CPAN
'https://upload.wikimedia.org/wikipedia/commons/thumb/6/62/Solid_red.svg/480px-Solid_red.svg.png',
'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/Green_00FF00_9x9.svg/480px-Green_00FF00_9x9.svg.png',
'https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Solid_blue.svg/480px-Solid_blue.svg.png',
);
undef;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubMobileNetV2Model - Using TensorFlow to do image classification using a pre-trained model
=head1 SYNOPSIS
The following tutorial is based on the L<Image Classification with TensorFlow Hub notebook|https://github.com/tensorflow/docs/blob/master/site/en/hub/tutorials/image_classification.ipynb>. It uses a pre-trained model based on the I<MobileNet V2> arch...
Please look at the L<SECURITY note|https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md> regarding running models as models are programs. You can also used C<saved_model_cli scan> to check for L<security-sensitive "denylisted ops"|https:/...
lib/AI/TensorFlow/Libtensorflow/Manual/Quickstart.pod view on Meta::CPAN
# ABSTRACT: Start here for an overview of the library
# PODNAME: AI::TensorFlow::Libtensorflow::Manual::Quickstart
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Manual::Quickstart - Start here for an overview of the library
=head1 DESCRIPTION
This provides a tour of C<libtensorflow> to help get started with using the
library.
lib/AI/TensorFlow/Libtensorflow/Operation.pm view on Meta::CPAN
$ddp->maybe_colorize(ref $self, 'class' ),
$ddp->parse(\%data) );
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::Operation - An operation
=head1 ATTRIBUTES
=head2 Name
B<C API>: L<< C<TF_OperationName>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_OperationName >>
lib/AI/TensorFlow/Libtensorflow/OperationDescription.pm view on Meta::CPAN
arg 'TF_OperationDescription' => 'desc',
arg 'TF_Status' => 'status',
] => 'TF_Operation');
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
AI::TensorFlow::Libtensorflow::OperationDescription - Operation being built
=head1 CONSTRUCTORS
=head2 New
B<C API>: L<< C<TF_NewOperation>|AI::TensorFlow::Libtensorflow::Manual::CAPI/TF_NewOperation >>