[−][src]Function opencv::dnn::read_net_from_torch
pub fn read_net_from_torch(
model: &str,
is_binary: bool,
evaluate: bool
) -> Result<Net>
Reads a network model stored in Torch7 framework's format.
Parameters
- model: path to the file, dumped from Torch by using torch.save() function.
- isBinary: specifies whether the network was serialized in ascii mode or binary.
- evaluate: specifies testing phase of network. If true, it's similar to evaluate() method in Torch.
Returns
Net object.
Note: Ascii mode of Torch serializer is more preferable, because binary mode extensively use long
type of C language,
which has various bit-length on different systems.
The loading file must contain serialized nn.Module object with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
List of supported layers (i.e. object instances derived from Torch nn.Module class):
- nn.Sequential
- nn.Parallel
- nn.Concat
- nn.Linear
- nn.SpatialConvolution
- nn.SpatialMaxPooling, nn.SpatialAveragePooling
- nn.ReLU, nn.TanH, nn.Sigmoid
- nn.Reshape
- nn.SoftMax, nn.LogSoftMax
Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.
C++ default parameters
- is_binary: true
- evaluate: true