Code Monkey home page Code Monkey logo

d2l-pytorch's People

Contributors

ahlaw avatar ajitpant avatar akshitmittal1 avatar aksub99 avatar anirudhdagar avatar ankitaharwal avatar fanqie03 avatar gupta1912 avatar harshalmittal4 avatar ishan-kumar2 avatar kanishk27dh avatar msank00 avatar purvachiniya avatar rcshubhadeep avatar rsinghal757 avatar ruijianw avatar sagupta8399 avatar saswatpp avatar shubhamgit1 avatar subham103 avatar suvaansh avatar vipul2001 avatar vn09 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

d2l-pytorch's Issues

Why use np.asscalar nor item() to get scalar value?

in CH_4_Data_manipulation, we use

We can transform the result into a scalar in Python using the asscalar function of numpy. In the following example, the $\ell_2$ norm of x yields a single element tensor. The final result is transformed into a scalar.
In[20]: np.asscalar(x.norm())
Out[20]: 22.494443893432617

Why don't just use x.norm().item() to get the scalar, which seems much easier? Are their any differences?

Wrong label at y axis

Hi Team,

In Ch06_Multilayer_Perceptrons/Multilayer_Perceptron.ipynb, I found that the y axis label for the gradient of relu() is mistakenly written as grad of sigmoid.

code clarification in Ch09_Modern_Convolutional_Networks Residual_Networks_(ResNet)

This is the original code

def resnet_block(input_channels, num_channels, num_residuals, first_block=False):
  blk = []
  for i in range(num_residuals):
    if i == 0 and not first_block:
      blk.append(Residual(input_channels, num_channels, use_1x1conv=True, strides=2))
    else:
      blk.append(Residual(num_channels, num_channels))
  return blk

I tried running the code in colab but there was a channel error. so I added the last line of code

in_channels = out_channels

And the new code looks like this .and it runs ok.

def resnet_block(in_channels,out_channels,num_residuals,first_block = False):
    blk = []
    for i in range(num_residuals):
        if i == 0 or not first_block:
            blk.append(Residual(in_channels,out_channels,use_1x1conv= True,strides = 2))
        else:
            blk.append(Residual(out_channels,out_channels))
        in_channels = out_channels
    return blk

A new idea for implementation during summers.

We can implement functions like tensor rotation, scaling, translation, general and channel-wise etc,
which are currently not possible with direct use of pytorch library as there are no such direct functions implemented, one idea was to convert tensor to PIL image and apply transformations and then revert back to tensor, the idea seems legit but there seems to be a bug in the library that doesn't return the correct result after conversion back to tensor, so such custom functions can be very helpful.

[possible typo] AdaptiveAvgPool2d or AdaptiveMaxPool2d in NiN?

in Ch09_Modern_Convolutional_Networks/Network_in_Network(NiN).ipynb defines the NiN net model with:

    #Global Average Pooling can be achieved by AdaptiveMaxPool2d with output size = (1,1)
    self.avg1 = nn.AdaptiveMaxPool2d((1,1))

Is it a typo of nn.AdaptiveAvgPool2d or some deeper reasons behind this? Cause using Avg will train a lot slower and get bad train/val accuracy like 0.460 (epoch 5)

Questions on the Focal Loss computation in the SSD Chapter

Two questions

  1. alpha_t is unused below.
  2. should we use the following to derive the BCECrossEntropyLoss:

pt = torch.log(p) * target.float() + torch.log(1.0 - p) * (1 - target).float()

class FocalLoss(nn.Module):
    def __init__(self, alpha=0.25, gamma=2, device="cuda:0", eps=1e-10):
        super().__init__()
        self.alpha = alpha
        self.gamma = gamma
        self.device = device
        self.eps = eps

    def forward(self, input, target):
        p = torch.sigmoid(input)
        pt = p * target.float() + (1.0 - p) * (1 - target).float()
        alpha_t = (1.0 - self.alpha) * target.float() + self.alpha * (1 - target).float()
        loss = - 1.0 * torch.pow((1 - pt), self.gamma) * torch.log(pt + self.eps)
        return loss.sum()

ready for social attention?

Hey, really great work on porting the book's code over to PyTorch.

It's one of the nicest books I read (atleast the few chapters I did) and Zack & team are great writers.

We want to get this port some attention via PyTorch Twitter, and want to make sure this book is ready in a state that you like -- and that we aren't surprising you by pre-announcing.

Let us know

14.1 Image Augmentation

I would like to contribute to this topic with notebook using Pytorch. Kindly assign this to me.

There's a bug in Ch10's “Implementation_of_Recurrent_Neural_Networks_from_Scratch”。

there is a runtime error when running the 7th code block. But I checked, the device type doesn't conflict each other. What's Wrong?

RuntimeError Traceback (most recent call last)
in
1 state = init_rnn_state(X.shape[0], num_hiddens, ctx)
2 inputs = to_onehot(X.to(ctx), len(vocab))
----> 3 params = get_params()
4 outputs, state_new = rnn(inputs, state, params)
5 len(outputs), outputs[0].shape, state_new[0].shape

in get_params()
9
10 # Hidden layer parameters
---> 11 W_xh = _one((num_inputs, num_hiddens))
12 W_hh = _one((num_hiddens, num_hiddens))
13 b_h = torch.zeros(num_hiddens, device=ctx)

in _one(shape)
6 def get_params():
7 def one(shape):
----> 8 return torch.Tensor(size=shape, device=ctx).normal
(std=0.01)
9
10 # Hidden layer parameters

RuntimeError: legacy constructor for device type: cpu was passed device type: cuda, but device type must be: cpu

TypeError in Chp14_Computer_Vision Single_Shot_Multibox_Detection.ipynb

In Chp14_Computer_Vision Single_Shot_Multibox_Detection.ipynb in the implementation of Define Loss and Evaluation Functions there is a missing .long() on line 61. A TypeError was raised: "Expected Long but got Float"

I solved it by changing class_true_i[0, j] to class_true_i[0, j].long() because class_target is a tensor with dtype long as shown on line 54 class_target = torch.zeros(class_hat_i.shape[0]).long().to(self.device)

Automatic Differentiation

In Section "Head gradients and the chain rule"
z.backward(head_gradient)
should be modified to
y.backward(head_gradient)

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.