GithubHelp home page GithubHelp logo

Is it possible to evaluate the BaseModel with other keras metrics aside from binary and categorical accuracy? about tf-encrypted HOT 5 CLOSED

fbarusso avatar fbarusso commented on April 27, 2024
Is it possible to evaluate the BaseModel with other keras metrics aside from binary and categorical accuracy?

from tf-encrypted.

Comments (5)

zicofish avatar zicofish commented on April 27, 2024

@fbarusso use predict?

from tf-encrypted.

fbarusso avatar fbarusso commented on April 27, 2024

@zicofish Thanks for your attention! I tried to use the benchmark/private_training.py by running:
tf-encrypted/examples/benchmark/training$ ./run-remote.sh logistic_regression LogisticArtificial

But on line 133, I used

result = model_2.predict(x=test_data_iter)

instead of

result = model_2.evaluate(x=test_data_iter, metrics=metrics, steps=test_dataset.iterations)

and it resulted in the following error:

Traceback (most recent call last):
  File "./private_training.py", line 133, in <module>
    result = model_2.predict(x=test_data_iter)
  File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/models/base_model.py", line 146, in predict
    y_pred = self.predict_function(input_x)
  File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/protocol/protocol.py", line 188, in wrap_function
    result = graph_function(args, kwargs)
  File "/home/febarusso/miniconda3/envs/tfe/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/tmp/__autograph_generated_filej69ox2qn.py", line 12, in tf__graph_function
    result = ag__.converted_call(ag__.ld(func), tuple(ag__.ld(args)), dict(**ag__.ld(kwargs)), fscope)
  File "/tmp/__autograph_generated_filezpzu8lwk.py", line 12, in tf__predict_step
    y_pred = ag__.converted_call(ag__.ld(self).call, (ag__.ld(input_x),), None, fscope)
  File "/tmp/__autograph_generated_filegmnf96cf.py", line 51, in tf__call
    ag__.for_stmt(ag__.ld(self).layers, None, loop_body, get_state_2, set_state_2, ('outputs', 'inputs'), {'iterate_names': 'layer'})
  File "/tmp/__autograph_generated_filegmnf96cf.py", line 48, in loop_body
    outputs = ag__.converted_call(ag__.ld(layer), (ag__.ld(inputs),), None, fscope)
  File "/tmp/__autograph_generated_file_c7f9xgv.py", line 28, in tf____call__
    outputs = ag__.converted_call(ag__.ld(self).call, ((ag__.ld(inputs),) + tuple(ag__.ld(args))), dict(**ag__.ld(kargs)), fscope)
  File "/tmp/__autograph_generated_file43d06n4z.py", line 11, in tf__call
    input_shape = ag__.converted_call(ag__.ld(inputs).shape.as_list, (), None, fscope)
AttributeError: in user code:

    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/protocol/protocol.py", line 178, in graph_function  *
        result = func(*args, **kwargs)
    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/models/base_model.py", line 129, in predict_step  *
        y_pred = self.call(input_x)
    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/models/sequential.py", line 109, in call  *
        outputs = layer(inputs)
    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/engine/base_layer.py", line 110, in __call__  *
        outputs = self.call(inputs, *args, **kargs)
    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/layers/flatten.py", line 33, in call  *
        input_shape = inputs.shape.as_list()

    AttributeError: 'generator' object has no attribute 'shape'

from tf-encrypted.

zicofish avatar zicofish commented on April 27, 2024

@zicofish Thanks for your attention! I tried to use the benchmark/private_training.py by running: tf-encrypted/examples/benchmark/training$ ./run-remote.sh logistic_regression LogisticArtificial

But on line 133, I used

result = model_2.predict(x=test_data_iter)

instead of

result = model_2.evaluate(x=test_data_iter, metrics=metrics, steps=test_dataset.iterations)

and it resulted in the following error:

Traceback (most recent call last):
  File "./private_training.py", line 133, in <module>
    result = model_2.predict(x=test_data_iter)
  File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/models/base_model.py", line 146, in predict
    y_pred = self.predict_function(input_x)
  File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/protocol/protocol.py", line 188, in wrap_function
    result = graph_function(args, kwargs)
  File "/home/febarusso/miniconda3/envs/tfe/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/tmp/__autograph_generated_filej69ox2qn.py", line 12, in tf__graph_function
    result = ag__.converted_call(ag__.ld(func), tuple(ag__.ld(args)), dict(**ag__.ld(kwargs)), fscope)
  File "/tmp/__autograph_generated_filezpzu8lwk.py", line 12, in tf__predict_step
    y_pred = ag__.converted_call(ag__.ld(self).call, (ag__.ld(input_x),), None, fscope)
  File "/tmp/__autograph_generated_filegmnf96cf.py", line 51, in tf__call
    ag__.for_stmt(ag__.ld(self).layers, None, loop_body, get_state_2, set_state_2, ('outputs', 'inputs'), {'iterate_names': 'layer'})
  File "/tmp/__autograph_generated_filegmnf96cf.py", line 48, in loop_body
    outputs = ag__.converted_call(ag__.ld(layer), (ag__.ld(inputs),), None, fscope)
  File "/tmp/__autograph_generated_file_c7f9xgv.py", line 28, in tf____call__
    outputs = ag__.converted_call(ag__.ld(self).call, ((ag__.ld(inputs),) + tuple(ag__.ld(args))), dict(**ag__.ld(kargs)), fscope)
  File "/tmp/__autograph_generated_file43d06n4z.py", line 11, in tf__call
    input_shape = ag__.converted_call(ag__.ld(inputs).shape.as_list, (), None, fscope)
AttributeError: in user code:

    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/protocol/protocol.py", line 178, in graph_function  *
        result = func(*args, **kwargs)
    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/models/base_model.py", line 129, in predict_step  *
        y_pred = self.call(input_x)
    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/models/sequential.py", line 109, in call  *
        outputs = layer(inputs)
    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/engine/base_layer.py", line 110, in __call__  *
        outputs = self.call(inputs, *args, **kargs)
    File "/home/febarusso/TFE/tf-encrypted/tf_encrypted/keras/layers/flatten.py", line 33, in call  *
        input_shape = inputs.shape.as_list()

    AttributeError: 'generator' object has no attribute 'shape'

@fbarusso you should not use the same test_data_iter for predict, because test_data_iter contains both x an y, which is good for evaluate, but not predict. You might need to figure out some way to extract only x. For example, in the predict function:

changing for input_x in data_iter: to for (input_x, input_y) in data_iter: will make it work. But there should be a better way to achieve what you want.

from tf-encrypted.

zjn-code avatar zjn-code commented on April 27, 2024

There is an example to use model.predict.

from tf-encrypted.

fbarusso avatar fbarusso commented on April 27, 2024

@zicofish @zjn-code it worked, thanks for the support.

from tf-encrypted.

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.