Caffe2 III: Basics of Caffe2-workspaces, Operators, and Nets basic concepts-workspaces, operations, networks

Source: Internet
Author: User
Tags nets

Original address: Https://caffe2.ai/docs/tutorial-basics-of-caffe2.html translation for personal use


This tutorial introduces a few basic CAFFE2 components: Here are some of the basic elements of Caffe2 Workspaces working space Operators Operation Nets Network

You are also may want to review the Intro Tutorial before starting this notebook. Before starting this tutorial you can look at the introduction https://caffe2.ai/docs/intro-tutorial

Browse the Tutorial

Tutorial Original: HTTPS://GITHUB.COM/CAFFE2/CAFFE2/BLOB/MASTER/CAFFE2/PYTHON/TUTORIALS/BASICS.IPYNB


In here tutorial we go through a set of Caffe2 basics:the basic concepts including how operators and nets are being WR Itten.

In this tutorial, we introduce some basic concepts of Caffe2, including how to use operations and networks.


A, let ' s import caffe2. The core and workspace are usually the two that you need most. If you are want to manipulate protocol buffers generated by CAFFE2, for you probably also want to import CAFFE2_PB2 from CAFFE2.PR Oto.

First, we introduce Caffe2 's core and workspace, two frequently used class libraries. If you need to use protocol buffer, you need to introduce CAFFE2_PB2 from Caffe2.proto.

1
2
3
4
5
6 7 8 9 10
# We ' ll also import a few standard Python libraries from
matplotlib import pyplot
import numpy as NP
import Time

# These are the droids your are looking for.
From Caffe2.python import core, workspace to
caffe2.proto import CAFFE2_PB2 # Let's show all
plots INLINE.
     %matplotlib Inline

You might a warning saying this caffe2 does not have GPU support. That means your are running a cpu-only build. Don ' t be alarmed-anything the CPU is still runnable without problem.

There may be a warning that CAFFE2 does not have GPU support. This indicates that the code is running in pure CPU mode. Don't worry, all CPUs can run this code. workspaces#

Let ' s cover Workspaces-A, where all the data reside. Let's take a look at the work space, where all the data is accommodated.

If you are are familiar with Matlab, workspace consists of blobs your create and store in memory. For now, the consider a blob to being a n-dimensional Tensor similar to NumPy ' s ndarray, and but is contiguous. Down the road, we'll show you this a blob is actually a typed pointer this can store any type of C + + objects, but Tensor Is the most common type stored in a blob. Let's show what the "interface looks like."

Similar to Matlab, in memory workspace contains the blob you create, you can think of a blob as an N-dimensional Tensor, a blob similar to the Ndarray of NumPy. Next, you'll see that a blob is actually a pointer to any type of C + + object (Tensor is the most common one) showing the interface below:


Blobs () prints out all existing Blobs in the workspace. Hasblob () queries if a BLOB exists in the workspace. For now, we don ' t have anything yet.

Blobs () prints out all the Blobs in the work space. Hasblob () queries whether a blob exists in the workspace.

1
2
Print ("BLOBs in the workspace: {}". Format (Workspace). Blobs ())
print ("Workspace has blob ' X ')"? {} '. Format (workspace. Hasblob ("X"))

We can feed blobs into the workspace using Feedblob ().

We use Feedblob () to put BLOBs into workspace.

1 2 3 
 X = NP 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.