Git Product home page Git Product logo

Comments (4)

srcansiz avatar srcansiz commented on May 27, 2024

In GitLab by @mvesin on Jun 23, 2021, 15:53

marked the checklist item implement local training as incomplete

from fedbiomed.

srcansiz avatar srcansiz commented on May 27, 2024

In GitLab by @mvesin on Jun 24, 2021, 09:34

marked the checklist item implement local training as completed

from fedbiomed.

srcansiz avatar srcansiz commented on May 27, 2024

In GitLab by @mvesin on Jun 24, 2021, 13:36

  • Why do we need to import torch & F before testing, as they seem to be already imported before when defining the model ?
%%writefile "$model_file"

import torch
import torch.nn as nn
from   fedbiomed.common.torchnn import Torchnn
import torch.nn.functional as F

# you can use any class name eg:
# class NetAlter(Torchnn):
class Net(Torchnn):
    def __init__(self):
...

and then :

# torch & F are not know if we don't import them here
import torch
import torch.nn.functional as F

test_set = datasets.MNIST(root = TMP_DIR + '/local_mnist_testing.tmp', download = True, train = False, transform = transform)
test_loader = torch.utils.data.DataLoader(test_set, batch_size=64, shuffle=True)
...
  • TLDR: this is normal

  • explanation :

    • %%writefile indicates that the content of the cell will be saved to a file not executed. Thus the import was not executed in the notebook (and those modules/functions never available in context of the notebook).
    • nevertheless, these imports are executed in localJob.__init__() when importing the class Net from the module corresponding to %%writefile. So the corresponding symbols are available within the context of the Net() object, which is used for training. You can check it with this, which gives F is defined at execution :
class Net(Torchnn):
    def __init__(self):
        super(Net, self).__init__()
        try:
            F
            print("F IS DEFINED")
        except NameError:
            print("F IS NOT DEFINED")
        print(dir())
        print(globals().keys())
...
  • also note that F does not appear in dir() but appears in globals().keys(), as it is not defined in Net's namespace but in the enclosing module's namespace. Some context about python namespaces here

from fedbiomed.

srcansiz avatar srcansiz commented on May 27, 2024

In GitLab by @mvesin on Jul 5, 2021, 11:44

marked the checklist item compare with fed training (accuracy) as completed

from fedbiomed.

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.