---

title: Experiments with loading 01


keywords: fastai
sidebar: home_sidebar

summary: "Contains some experiments with implemented functions"
description: "Contains some experiments with implemented functions"
nb_path: "nbs/03_load_tests.ipynb"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/03_load_tests.ipynb
# command to build the docs after a change: nbdev_build_docs

-->

<div class="container" id="notebook-container">
        
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># from fastai.tabular.all import *</span>
<span class="c1"># import json</span>
<span class="c1"># import torch</span>
<span class="c1"># from torch.autograd import Variable</span>

<span class="c1"># from transfertab.utils import *</span>
<span class="c1"># from transfertab.core import *</span>
<span class="c1"># from srsly import ujson</span>

<span class="c1"># import wandb</span>
<span class="c1"># from fastai.callback.wandb import WandbCallback</span>


<span class="c1"># wandb.init(settings=wandb.Settings(start_method=&quot;thread&quot;))</span>
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">

<div class="output_subarea output_stream output_stderr output_text">
<pre>wandb: wandb version 0.10.32 is available!  To upgrade, please run:
wandb:  $ pip install wandb --upgrade
</pre>
</div>
</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea ">

                Tracking run with wandb version 0.10.24<br/>
                Syncing run <strong style="color:#cdcd00">kind-snow-1</strong> to <a href="https://wandb.ai" target="_blank">Weights & Biases</a> <a href="https://docs.wandb.com/integrations/jupyter.html" target="_blank">(Documentation)</a>.<br/>
                Project page: <a href="https://wandb.ai/ishitadatta/transfertab-nbs" target="_blank">https://wandb.ai/ishitadatta/transfertab-nbs</a><br/>
                Run page: <a href="https://wandb.ai/ishitadatta/transfertab-nbs/runs/29wlpmae" target="_blank">https://wandb.ai/ishitadatta/transfertab-nbs/runs/29wlpmae</a><br/>
                Run data is saved locally in <code>C:\Users\HP\transfertab\nbs\wandb\run-20210617_153338-29wlpmae</code><br/><br/>
            
</div>

</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea output_execute_result">
<h1>Run(29wlpmae)</h1><iframe src="https://wandb.ai/ishitadatta/transfertab-nbs/runs/29wlpmae" style="border:none;width:100%;height:400px"></iframe>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># df2 = pd.read_csv(&#39;../data/toy_dataset.csv&#39;)</span>
<span class="c1"># splits2 = RandomSplitter(valid_pct=0.2)(range_of(df2))</span>
<span class="c1"># to2 = TabularPandas(df2, procs=[Categorify, FillMissing,Normalize],</span>
<span class="c1">#                    cat_names = [&#39;City&#39;,&#39;sex&#39;],</span>
<span class="c1">#                    cont_names = [&#39;Number&#39;, &#39;Income&#39;, &#39;Age&#39;],</span>
<span class="c1">#                    y_names=&#39;Illness&#39;,</span>
<span class="c1">#                    splits=splits2)</span>
<span class="c1"># dls2 = to2.dataloaders(bs=64)</span>
<span class="c1"># learn2 = tabular_learner(dls2, metrics=accuracy, cbs=WandbCallback(log_dataset=True, log_model=True))</span>
</pre></div>

    </div>
</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># learn2.fit(1)</span>
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">

<div class="output_subarea output_stream output_stdout output_text">
<pre>WandbCallback could not retrieve the dataset path, please provide it explicitly to &#34;log_dataset&#34;
WandbCallback requires use of &#34;SaveModelCallback&#34; to log best model
</pre>
</div>
</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: left;">
      <th>epoch</th>
      <th>train_loss</th>
      <th>valid_loss</th>
      <th>accuracy</th>
      <th>time</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>0</td>
      <td>0.265406</td>
      <td>0.287556</td>
      <td>0.918533</td>
      <td>00:33</td>
    </tr>
  </tbody>
</table>
</div>

</div>

<div class="output_area">

<div class="output_subarea output_stream output_stderr output_text">
<pre>D:\Anaconda\lib\site-packages\torch\nn\modules\module.py:795: UserWarning: Using a non-full backward hook when the forward contains multiple autograd Nodes is deprecated and will be removed in future versions. This hook will be missing some grad_input. Please use register_full_backward_hook to get the documented behavior.
  warnings.warn(&#34;Using a non-full backward hook when the forward contains multiple autograd Nodes &#34;
</pre>
</div>
</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># row, clas, probs = learn2.predict(df2.iloc[-1])</span>
<span class="c1"># row, clas, probs</span>
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_html rendered_html output_subarea ">

</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>(   City  sex    Number    Income       Age  Illness
 0   1.0  1.0  1.730422 -0.160174 -0.687693      0.0,
 tensor(0),
 tensor([0.9303, 0.0697]))</pre>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># tab_obj = TabTransfer(learn2)</span>
</pre></div>

    </div>
</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">

<div class="output_subarea output_stream output_stdout output_text">
<pre>tensor([[ 0.0078, -0.0057,  0.0079],
        [ 0.0084, -0.0047,  0.0006],
        [-0.0068, -0.0055,  0.0075]])
mean is tensor([ 0.0031, -0.0053,  0.0053]) for tensor([[ 0.0078, -0.0057,  0.0079],
        [ 0.0084, -0.0047,  0.0006],
        [-0.0068, -0.0055,  0.0075]])
0, &lt;class &#39;int&#39;&gt;
Transferring weights for class #na#, cat sex using mean
old weight for class is tensor([ 0.0031, -0.0053,  0.0053], grad_fn=&lt;SliceBackward&gt;)
new weight for class is tensor([ 0.0031, -0.0053,  0.0053], grad_fn=&lt;SliceBackward&gt;)
1, &lt;class &#39;int&#39;&gt;
Transferring weights for class Female, cat sex from previous weights
old weight for class is tensor([ 0.0078, -0.0057,  0.0079], grad_fn=&lt;SliceBackward&gt;)
new weight for class is tensor([ 0.0078, -0.0057,  0.0079], grad_fn=&lt;SliceBackward&gt;)
2, &lt;class &#39;int&#39;&gt;
Transferring weights for class Male, cat sex from previous weights
old weight for class is tensor([ 0.0084, -0.0047,  0.0006], grad_fn=&lt;SliceBackward&gt;)
new weight for class is tensor([ 0.0084, -0.0047,  0.0006], grad_fn=&lt;SliceBackward&gt;)
</pre>
</div>
</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_html rendered_html output_subarea ">

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>City</th>
      <th>sex</th>
      <th>Number</th>
      <th>Income</th>
      <th>Age</th>
      <th>Illness</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>Austin</td>
      <td>Female</td>
      <td>150000.001614</td>
      <td>87251.00002</td>
      <td>37.0</td>
      <td>No</td>
    </tr>
  </tbody>
</table>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>(tensor(0), tensor([0.9316, 0.0684]))</pre>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h5 id="===============================">===============================<a class="anchor-link" href="#==============================="> </a></h5>
</div>
</div>
</div>
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_html rendered_html output_subarea ">

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>City</th>
      <th>sex</th>
      <th>Number</th>
      <th>Income</th>
      <th>Age</th>
      <th>Illness</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>Austin</td>
      <td>Female</td>
      <td>150000.001614</td>
      <td>87251.00002</td>
      <td>37.0</td>
      <td>No</td>
    </tr>
  </tbody>
</table>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>(tensor(0), tensor([0.9018, 0.0982]))</pre>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_html rendered_html output_subarea ">

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>City</th>
      <th>sex</th>
      <th>Number</th>
      <th>Income</th>
      <th>Age</th>
      <th>Illness</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>Austin</td>
      <td>Female</td>
      <td>150000.001614</td>
      <td>87251.00002</td>
      <td>37.0</td>
      <td>No</td>
    </tr>
  </tbody>
</table>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span> 
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>tensor([0.9316, 0.0684])</pre>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># wandb.finish()</span>
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
<br/>Waiting for W&B process to finish, PID 0<br/>Program ended successfully.
</div>

</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
Find user logs for this run at: <code>C:\Users\HP\transfertab\nbs\wandb\run-20210617_153338-29wlpmae\logs\debug.log</code>
</div>

</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
Find internal logs for this run at: <code>C:\Users\HP\transfertab\nbs\wandb\run-20210617_153338-29wlpmae\logs\debug-internal.log</code>
</div>

</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
<h3>Run summary:</h3><br/><style>
    table.wandb td:nth-child(1) { padding: 0 10px; text-align: right }
    </style><table class="wandb">
<tr><td>epoch</td><td>1</td></tr><tr><td>train_loss</td><td>0.26541</td></tr><tr><td>raw_loss</td><td>0.28508</td></tr><tr><td>wd_0</td><td>0.01</td></tr><tr><td>sqr_mom_0</td><td>0.99</td></tr><tr><td>lr_0</td><td>0.001</td></tr><tr><td>mom_0</td><td>0.9</td></tr><tr><td>eps_0</td><td>1e-05</td></tr><tr><td>_runtime</td><td>415</td></tr><tr><td>_timestamp</td><td>1623924633</td></tr><tr><td>_step</td><td>1874</td></tr><tr><td>valid_loss</td><td>0.28756</td></tr><tr><td>accuracy</td><td>0.91853</td></tr></table>
</div>

</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
<h3>Run history:</h3><br/><style>
    table.wandb td:nth-child(1) { padding: 0 10px; text-align: right }
    </style><table class="wandb">
<tr><td>epoch</td><td>▁▁▁▁▂▂▂▂▂▃▃▃▃▃▃▄▄▄▄▄▅▅▅▅▅▅▆▆▆▆▆▇▇▇▇▇▇███</td></tr><tr><td>train_loss</td><td>█▇▅▃▂▂▁▂▁▁▁▂▁▂▁▁▁▂▁▁▁▂▂▁▁▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁</td></tr><tr><td>raw_loss</td><td>█▇▆▅▃▃▄▄▆▂▃▅▂▄▃▂▅▂▅▃▅▂▃▃▁▅▄▅▄▆▅▂▂▄▅▃▅▂▄▂</td></tr><tr><td>wd_0</td><td>▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</td></tr><tr><td>sqr_mom_0</td><td>▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</td></tr><tr><td>lr_0</td><td>▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</td></tr><tr><td>mom_0</td><td>▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</td></tr><tr><td>eps_0</td><td>▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁</td></tr><tr><td>_runtime</td><td>▁▁▁▁▂▂▂▂▂▂▃▃▃▃▃▄▄▄▄▄▄▅▅▅▅▅▅▆▆▆▆▆▇▇▇▇████</td></tr><tr><td>_timestamp</td><td>▁▁▁▁▂▂▂▂▂▂▃▃▃▃▃▄▄▄▄▄▄▅▅▅▅▅▅▆▆▆▆▆▇▇▇▇████</td></tr><tr><td>_step</td><td>▁▁▁▁▂▂▂▂▂▃▃▃▃▃▃▄▄▄▄▄▅▅▅▅▅▅▆▆▆▆▆▇▇▇▇▇▇███</td></tr><tr><td>valid_loss</td><td>▁</td></tr><tr><td>accuracy</td><td>▁</td></tr></table><br/>
</div>

</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea ">
Synced 5 W&B file(s), 2 media file(s), 1 artifact file(s) and 0 other file(s)
</div>

</div>

<div class="output_area">


<div class="output_html rendered_html output_subarea ">

                    <br/>Synced <strong style="color:#cdcd00">kind-snow-1</strong>: <a href="https://wandb.ai/ishitadatta/transfertab-nbs/runs/29wlpmae" target="_blank">https://wandb.ai/ishitadatta/transfertab-nbs/runs/29wlpmae</a><br/>
                
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

</div>
 

