1297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# 2297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Copyright (C) 2017 The Android Open Source Project 3297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# 4297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Licensed under the Apache License, Version 2.0 (the "License"); 5297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# you may not use this file except in compliance with the License. 6297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# You may obtain a copy of the License at 7297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# 8297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# http://www.apache.org/licenses/LICENSE-2.0 9297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# 10297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Unless required by applicable law or agreed to in writing, software 11297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# distributed under the License is distributed on an "AS IS" BASIS, 12297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# See the License for the specific language governing permissions and 14297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# limitations under the License. 15297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# 16297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung 17297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungmodel = Model() 18297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungin0 = Input("op1", "TENSOR_FLOAT32", "{1, 5}") # batch = 1, input_size = 5 19297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungweights = Input("op2", "TENSOR_FLOAT32", "{1, 5}") # num_units = 1, input_size = 5 20297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungbias = Input("b0", "TENSOR_FLOAT32", "{1}") 21297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungout0 = Output("op3", "TENSOR_FLOAT32", "{1, 1}") # batch = 1, number_units = 1 22297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungact = Int32Scalar("act", 0) 23297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungmodel = model.Operation("FULLY_CONNECTED", in0, weights, bias, act).To(out0) 24297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung 25297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Example 1. Input in operand 0, 26297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sunginput0 = {in0: # input 0 27297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung [1, 10, 100, 1000, 10000], 28297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung weights: 29297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung [2, 3, 4, 5, 6], 30297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung bias: 31297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung [900000]} 32297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungoutput0 = {out0: # output 0 33297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung [965432]} 34297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung 35297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Instantiate an example 36297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) SungExample((input0, output0)) 37