Git Product home page Git Product logo

Comments (4)

jl749 avatar jl749 commented on May 20, 2024

What does model.eval() do in pytorch?
https://stackoverflow.com/questions/60018578/what-does-model-eval-do-in-pytorch

evaluate model:

model.eval()

with torch.no_grad():
    ...
    out_data = model(data)
    ...

training step:

...
model.train()
...

from yolov1.

jl749 avatar jl749 commented on May 20, 2024

(7, 7, 30) -- torch.Tensor::unsqueeze(0) --> (1, 7, 7, 30)
(1, 7, 7) -- torch.Tensor::unsqueeze(-1) --> (1, 7, 7, 1)

from yolov1.

jl749 avatar jl749 commented on May 20, 2024

torch.permute()

>>> x = torch.randn(2, 3, 5)
>>> x.size()
torch.Size([2, 3, 5])
>>> torch.permute(x, (2, 0, 1)).size()
torch.Size([5, 2, 3])\

from yolov1.

jl749 avatar jl749 commented on May 20, 2024

propagate tensor with repeat()

batch size = 1
cell_indices = torch.arange(S).repeat(batch_size, S, 1).unsqueeze(-1)  # (1, 7, 7, 1)
result tensor
tensor([[[[0],
          [1],
          [2],
          [3],
          [4],
          [5],
          [6]],

         [[0],
          [1],
          [2],
          [3],
          [4],
          [5],
          [6]],

         [[0],
          [1],
          [2],
          [3],
          [4],
          [5],
          [6]],

         [[0],
          [1],
          [2],
          [3],
          [4],
          [5],
          [6]],

         [[0],
          [1],
          [2],
          [3],
          [4],
          [5],
          [6]],

         [[0],
          [1],
          [2],
          [3],
          [4],
          [5],
          [6]],

         [[0],
          [1],
          [2],
          [3],
          [4],
          [5],
          [6]]]])

swap 1st 2nd indexes

cell_indices.permute(0, 2, 1, 3))
result tensor
tensor([[[[0],
          [0],
          [0],
          [0],
          [0],
          [0],
          [0]],

         [[1],
          [1],
          [1],
          [1],
          [1],
          [1],
          [1]],

         [[2],
          [2],
          [2],
          [2],
          [2],
          [2],
          [2]],

         [[3],
          [3],
          [3],
          [3],
          [3],
          [3],
          [3]],

         [[4],
          [4],
          [4],
          [4],
          [4],
          [4],
          [4]],

         [[5],
          [5],
          [5],
          [5],
          [5],
          [5],
          [5]],

         [[6],
          [6],
          [6],
          [6],
          [6],
          [6],
          [6]]]])

from yolov1.

Related Issues (4)

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.