<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="295152" data-post-id="295152">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="NickGnd" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/NickGnd/120/4035_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  NickGnd
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hey <a class="mention" href="/u/aetherus" rel="nofollow">@Aetherus</a> thanks <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>I’m far from being an expert, but I’ll give it a try and reply to some of your questions:</p>
<blockquote>
<ol>
<li>How to save a trained model? Is there any language-agnostic standard format?</li>
</ol>
</blockquote>
<p>There are probably multiple ways to do that.</p>
<p>A simple approach is to dump the weights obtained from the training in a file (see <a href="https://hexdocs.pm/nx/Nx.html#serialize/2" rel="noopener nofollow ugc"><code>Nx.serialize/2</code></a>), they should be pretty much portable and language/framework-agnositc, but of course the model implementation must be the same. Basically, you need to keep your model definitions as code around and then you can just load the weights and call the predict function.</p>
<p>Another possible way is to convert the trained model to <a href="https://onnxruntime.ai/" rel="noopener nofollow ugc">ONNX</a> format (including the weights). In elixir-nx ecosystem you can use the <a href="https://hexdocs.pm/axon_onnx/AxonOnnx.html" rel="noopener nofollow ugc">AxonOnnx</a> library.</p>
<blockquote>
<ol start="2">
<li>How to load a pre-trained model written in another language?</li>
</ol>
</blockquote>
<p>Also in this case, there are more possibilities depending on the model.</p>
<p>First thing, maybe you can check if this model is already available via <a href="https://hexdocs.pm/bumblebee/Bumblebee.html" rel="noopener nofollow ugc">Bumblebee</a>, that would be the easiest way.</p>
<p>If not, you can check if it is possible to <a href="https://huggingface.co/docs/transformers/serialization" rel="noopener nofollow ugc">export the model to onnx format</a> and then you can try to import it in Axon via the aforementioned AxonOnnx.</p>
<p>Worst case scenario, you have only the weights at hand and therefore you need to re-implement the model with Axon, in that case you can check Bumblebee models for inspirations.</p>
<p>I’m sure there are probably other ways.</p>
<blockquote>
<p>3 How to do transfer learning?</p>
</blockquote>
<p>I don’t have any experience about it.</p>
<p>I think this livebook can be a good entry point for fine-tuning <a href="https://hexdocs.pm/bumblebee/fine_tuning.html" class="inline-onebox" rel="noopener nofollow ugc">Fine-tuning — Bumblebee v0.7.0</a></p>
<p>Otherwise, I have seen that Axon exposes APIs to <a href="https://hexdocs.pm/axon/Axon.html#freeze/2" rel="noopener nofollow ugc">freeze layers</a> which can be useful for transfer learning.</p>
<p>Cheers <img src="https://forum.elixirforum.com/images/emoji/apple/v.png?v=15" title=":v:" class="emoji" alt=":v:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="295152" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/programming-machine-learning-book-livebooks-with-nx-and-axon/54535/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-295152" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="295152"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="297296" data-post-id="297296">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kenichi" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kenichi/120/25898_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kenichi
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/nickgnd" rel="nofollow">@NickGnd</a> thanks for checking! i carried on into further chapters, and haven’t gone back to check but i have a suspicion that :f64 vs. :f32 might be the thing. i will check our your gist and reply back - might be a bit though <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<p>thanks again!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="297296" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/programming-machine-learning-book-livebooks-with-nx-and-axon/54535/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-297296" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="297296"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="297335" data-post-id="297335">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="bmitc" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bmitc/120/28446_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  bmitc
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You beat me to it. Haha. I am slowly going through the book in both F# and Elixir, using notebooks for each language. I’ll take a look at your implementation. Thanks for posting it!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="297335" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/programming-machine-learning-book-livebooks-with-nx-and-axon/54535/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-297335" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="297335"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>