GithubHelp home page GithubHelp logo

Propagation Performance about c3 HOT 3 CLOSED

q-optimize avatar q-optimize commented on July 1, 2024
Propagation Performance

from c3.

Comments (3)

shaimach avatar shaimach commented on July 1, 2024

from c3.

nwittler avatar nwittler commented on July 1, 2024

One thing to keep in mind is that the python structure is not necessarily the tensorflow structure. The examples above use decorated @tf.functions which means they will be parsed as a for loop but not executed that way. It all comes back to the fact that we need a proper software engineer to find the best tensorflow network representation for the propagation.

Below is an example notebook but that's about as far as I got investigating this.

import numpy as np
import tensorflow as tf
import time

slices = 3000
var = tf.Variable(np.random.rand(100,100))

def expm(var):
    return tf.linalg.expm(var)

@tf.function
def tf_expm(var):
    return tf.linalg.expm(var)
start_time = time.time()
res = []
for ii in range(slices):
    res.append(expm(var))
print(time.time() - start_time, "seconds")
19.600555658340454 seconds
start_time = time.time()
res2 = []
for ii in range(slices):
    res2.append(tf_expm(var))
print(time.time() - start_time, "seconds")
4.85532021522522 seconds
var_vec = tf.Variable(np.random.rand(slices, 100,100))
def expm_vec():
    return tf.vectorized_map(expm, var_vec)
start_time = time.time()
res_vec = expm_vec()
print(time.time() - start_time, "seconds")
WARNING:tensorflow:Using a while_loop for converting ResourceGather
6.617619276046753 seconds
@tf.function
def expm_tf_vec():
    return tf.vectorized_map(expm, var_vec)
start_time = time.time()
res_vec_2 = expm_tf_vec()
print(time.time() - start_time, "seconds")
WARNING:tensorflow:Using a while_loop for converting ResourceGather
6.34708309173584 seconds

from c3.

lazyoracle avatar lazyoracle commented on July 1, 2024

@GlaserN Is this issue fixed in #34?

from c3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.