3. Características
• Biblioteca open source
• Suporte a multi-CPU e multi-GPU
• Suporte a treino distribuído (cluster)
• Suporte a diversos dispositivos (ex: mobile)
• Linguagem preferencial: Python e C++
• Bibliotecas de operadores em diferentes níveis de
abstração
4. Estrutura do código
• Declaração do modelo (construção do grafo)
• Loop de treino
• Salvar/carregar modelo
• Usar modelo para inferir
10. Tensors: tf.placeholder()
#graph definition
a = tf.placeholder(tf.int64, shape=(2,2),name="placeholder_1")
…
#graph evaluation inside session
#a takes the value passed by the feed_dict
a_val = sess.run(a, feed_dict={a:[[1,0],[0,1]]})
#a_val is a numpy array with shape=(2,2)
11. Device allocation: tf.device()
with tf.device("/cpu:0"):
a = tf.Variable(…) #a will be allocated on the cpu memory
with tf.device("/gpu:0"):
b = tf.Variable(…) #b will be allocated on the cuda device 0 (default)
with tf.device("/gpu:1"):
c = tf.Variable(…) #c will be allocated on the cuda device 1
12. Operações
• Operações com matrizes (matmul, etc.)
• Funções de ativação (relu, sigmoid, etc.)
• Algoritmos de otimização (GD, Adam, etc.)
• E muuuuuiiiiito mais…
31. Conclusões
• Biblioteca de operações em diferentes níveis de
abstração
• Mais fácil de customizar que scikit-learn
• Ainda não possui tantos modelos “caixa-preta”
prontos (tf.contrib)
• Ambiente de execução versátil e escalável
• Integração com Google Cloud ML