<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>programming Archives - Nerd Corner</title>
	<atom:link href="https://nerd-corner.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerd-corner.com/tag/programming/</link>
	<description>Craft your dreams!</description>
	<lastBuildDate>Thu, 18 May 2023 14:11:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://nerd-corner.com/wp-content/uploads/2019/10/cropped-LogoNerdCorner-2-32x32.png</url>
	<title>programming Archives - Nerd Corner</title>
	<link>https://nerd-corner.com/tag/programming/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Tensorflow.js vs Tensorflow (Python)</title>
		<link>https://nerd-corner.com/tensorflow-js-vs-tensorflow-python/</link>
					<comments>https://nerd-corner.com/tensorflow-js-vs-tensorflow-python/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Thu, 18 May 2023 14:11:37 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[CUDA]]></category>
		<category><![CDATA[Deep Learning]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[Natural Language Processing]]></category>
		<category><![CDATA[NLP]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[software comparison]]></category>
		<category><![CDATA[Tensorflow]]></category>
		<category><![CDATA[Tensorflow Anleitung]]></category>
		<category><![CDATA[tensorflow comparison]]></category>
		<category><![CDATA[TensorFlow GPU]]></category>
		<category><![CDATA[Tensorflow guide]]></category>
		<category><![CDATA[Tensorflow python]]></category>
		<category><![CDATA[Tensorflow.js]]></category>
		<category><![CDATA[Tensorflow.js vs Tensorflow]]></category>
		<category><![CDATA[TPU]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1384</guid>

					<description><![CDATA[<p>In the world of machine learning and deep learning, there are a variety of tools and libraries that help developers create and train advanced models. &#8230; </p>
<p>The post <a href="https://nerd-corner.com/tensorflow-js-vs-tensorflow-python/">Tensorflow.js vs Tensorflow (Python)</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the world of machine learning and deep learning, there are a variety of tools and libraries that help developers create and train advanced models. Two popular options are Tensorflow.js and the original Tensorflow, developed for JavaScript and Python respectively. Due to a project where I want to use NLP (Natural Language Processing) to automatically convert standard language texts into dialect, I took a closer look at the two options. In this blog article I will discuss the differences and advantages of Tensorflow.js vs Tensorflow (Python). Afterwards, everyone should be able to decide between Tensorflow.js vs Tensorflow (Python).</p>
<p><em><strong>This might also be interesting for you:</strong> <a href="https://nerd-corner.com/enable-tensorflow-gpu-under-windows/">How to enable GPU for TensorFlow in Windows</a></em></p>
<h2>Language and environment</h2>
<p>Tensorflow.js was developed specifically for JavaScript, which means that models can be implemented directly in JavaScript code. This allows seamless integration into web applications and execution of models in the browser without additional server infrastructure.</p>
<p>Tensorflow Python provides a comprehensive Python library for machine learning. Python is a widely used programming language in the field of machine learning and offers a variety of libraries and frameworks to facilitate model development and deployment.</p>
<h2>Target platform</h2>
<p>One of the greatest strengths of Tensorflow.js is the ability to run models directly in the browser. This allows developers to create interactive web applications with machine learning without the user having to install additional software or send external server requests.</p>
<p>Tensorflow Python, on the other hand, allows models to be developed and run on multiple platforms, including desktop computers, servers and mobile devices. It offers a wide range of features and supports advanced techniques such as training models on GPUs or TPUs. TPU stands for &#8220;Tensor Processing Unit&#8221;. These are application-specific chips to accelerate machine learning applications.</p>
<h2>Community</h2>
<p>To be honest, the Tensorflow.js community is simply too small. With many questions, one has the feeling that one is doing &#8220;pioneering work&#8221; here, which is not recommended, especially for beginners. To be more specific: There are 80 times more StackOverflow questions about TensorFlow than about TensorFlow.js. However, depending on the use case, a number of resources, tutorials and examples now also exist for TensorFlow.js that can help with development with Tensorflow.js. Since JavaScript is a widely used language, one can also access a large amount of general web development resources that can help when working with Tensorflow.js.</p>
<p>Tensorflow Python, on the other hand, benefits from a large and active community that regularly develops and publishes new models, techniques and resources. There are a variety of tutorials, forums and open source projects that can help you advance your machine learning projects. The Python community is known for its support and collaboration, which can make it easier to get started with Tensorflow Python.</p>
<h2>Libraries</h2>
<p>In many cases, and specifically for my NLP project, a knockout criterion for Tensorflow.js was the libraries. Tensorflow.js has far less libraries compared to Tensorflow Python. In my view, this is due to the following 3 points:</p>
<ol>
<li>Development status: Tensorflow Python exists for several years and has had a long development period. During this time, numerous extensions, modules and additional libraries have been developed specifically for Tensorflow Python. Tensorflow.js, on the other hand, is a comparatively newer technology and may still be in an earlier stage of development. Therefore, Tensorflow.js may have fewer libraries and extensions developed specifically for this platform.</li>
<li>Target platform: Tensorflow Python targets a wide range of platforms, including desktop computers, servers and mobile devices. As a result, there are a variety of specialised libraries and extensions for different use cases and hardware configurations. Tensorflow.js, on the other hand, aims to run models directly in the browser. Therefore, the functions and libraries of Tensorflow.js are optimised for the requirements of web applications and the limited resource availability in the browser.</li>
<li>Compatibility: Tensorflow.js is based on JavaScript, a language primarily used for web development. Although JavaScript has a large developer community and many existing libraries and frameworks, not all of them are directly compatible with Tensorflow.js. Therefore, not all available libraries and extensions for Tensorflow Python may also be available for Tensorflow.js.</li>
</ol>
<p>However, it is important to note that Tensorflow.js is constantly evolving and the library and available extensions may grow over time. The community around Tensorflow.js is working to expand the ecosystem and provide new libraries as well as tools to improve the functionality and expand the possibilities of Tensorflow.js.</p>
<h2>Platform support</h2>
<p>Written in C++, TensorFlow is a cross-platform library supported on various operating systems including Windows, macOS and Linux. It can be used to develop and run models on servers as well as desktop computers.</p>
<p>TensorFlow therefore supports a wider range of platforms than TensorFlow.js, as TensorFlow.js is mainly focused on JavaScript environments such as the browser and Node.js.</p>
<h2>Training large models</h2>
<p>TensorFlow can train and process very large models, whereas TensorFlow.js is limited to smaller models due to the performance limitations of JavaScript engines.</p>
<p>JavaScript engines are less powerful compared to specialised machine learning frameworks and hardware accelerators such as GPUs or TPUs. This means that TensorFlow.js is usually suitable for smaller models due to the limited processing power and memory of JavaScript engines.</p>
<p>Therefore, TensorFlow is recommended for projects where large models need to be trained or complex calculations need to be performed, while TensorFlow.js is better suited for applications that use smaller models and are intended to run in web browsers or JavaScript environments.</p>
<h2>Why TensorFlow.js in the browser?</h2>
<p>There is the issue of speed. Since you don&#8217;t have to send data to a remote server, classification is faster. In addition, you have direct access to sensors such as camera, microphone, GPS, etc.</p>
<p>In addition, data protection is an important issue in many countries. You can train and classify data on your own computer without having to send it to an external web server. This may be necessary to comply with data protection laws such as the DSGVO or if one does not want to share the data with third parties.</p>
<p>With one click, anyone in the world can access and use the application via a link without the need for a complex setup with servers and special hardware such as graphics cards.</p>
<p>Finally, with ML you should also keep an eye on the costs. You only have to pay for hosting the client. This is much cheaper than maintaining your own server permanently.</p>
<h2>Conclusion: Tensorflow.js vs. Tensorflow?</h2>
<p>Overall, the question Tensorflow.js vs. Tensorflow can be answered in a simplified way by saying that Tensorflow with Python is almost ALWAYS the better choice due to its broad acceptance and large <a href="https://www.tensorflow.org/community" target="_blank" rel="noopener">community</a>. Nevertheless, Tensorflow.js is becoming increasingly important and is predominantly used by developers who want to develop web applications with machine learning on the client side.</p>
<p>This means if you want to build apps that run in the web browser, TensorFlow.js is actually the better choice. However, if you want to build apps to run on a server or desktop computer, TensorFlow is the better option. Also, the Python version is much better suited if you want to work with powerful devices like GPUs.</p>
<p>The post <a href="https://nerd-corner.com/tensorflow-js-vs-tensorflow-python/">Tensorflow.js vs Tensorflow (Python)</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/tensorflow-js-vs-tensorflow-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Import Swagger in Node TypeScript Project</title>
		<link>https://nerd-corner.com/import-swagger-in-node-typescript-project/</link>
					<comments>https://nerd-corner.com/import-swagger-in-node-typescript-project/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Wed, 26 Oct 2022 17:10:41 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[Api]]></category>
		<category><![CDATA[Backend]]></category>
		<category><![CDATA[Backend Server]]></category>
		<category><![CDATA[Backend with Swagger]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[Endpoints]]></category>
		<category><![CDATA[express.js]]></category>
		<category><![CDATA[Github]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[Node with Swagger and Typescript]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[Swagger]]></category>
		<category><![CDATA[swagger documentation]]></category>
		<category><![CDATA[Swagger express]]></category>
		<category><![CDATA[Swagger.json]]></category>
		<category><![CDATA[typescript]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1287</guid>

					<description><![CDATA[<p>I recently coded a Node server with express.js in Typescript. This is a typical combination for backend development. It is especially beneficial if you already &#8230; </p>
<p>The post <a href="https://nerd-corner.com/import-swagger-in-node-typescript-project/">Import Swagger in Node TypeScript Project</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I recently coded a Node server with express.js in Typescript. This is a typical combination for backend development. It is especially beneficial if you already have experience with frontend development in Typescript. In general I strongly recommend to use Typescript instead of Javascript for frontend as well as backend development. Typescript uses Javascript but is type based and therefore not as error prone!</p>
<p>Also, the focus should always be on clean code and it should be properly documented. Especially when a project gets bigger, proper documented work pays off. For example, to document REST endpoints it is recommended to use Swagger. The Swagger API documentation provides an overview of all endpoints and even the possibility to interact with them.</p>
<p><strong><em>This might also be interesting for you: </em></strong><a href="https://nerd-corner.com/how-to-build-a-custom-angular-reactive-svg-form-with-clickable-elements/" target="_blank" rel="noopener"><em>Angular Form with clickable SVG</em></a></p>
<h2>List of components</h2>
<ul>
<li>IDE (for example VS Code)</li>
<li>Node.js</li>
</ul>
<h2>Documentation with swagger</h2>
<p>Although Swagger is quite well known, I could not find a detailed implementation guide. Therefore I would like to explain 2 ways to implement Swagger in an existing node server. The first way is to add Swagger parameters directly to each endpoint. This is probably the faster variant, but can get messy depending on the number of endpoints. The second option is to create a &#8220;swagger.json&#8221; file that summarizes the parameters of the endpoints.</p>
<p>To use Swagger the following library and its type extension will be needed:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">npm install --save  swagger-ui-express
npm install --save-dev @types/swagger-ui-express</pre>
<p>Swagger creates documentation of the endpoints:</p>
<p><img fetchpriority="high" decoding="async" class="zoooom aligncenter wp-image-1271" src="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu.jpg" alt="Example Swagger Docu" width="1647" height="853" srcset="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu.jpg 1847w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu-300x155.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu-1024x531.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu-768x398.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu-1536x796.jpg 1536w" sizes="(max-width: 1647px) 100vw, 1647px" /></p>
<p>These can be opened and you can see an example request and an example response:</p>
<p><img decoding="async" class="aligncenter wp-image-1273 zoooom" style="font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint.jpg" alt="Example Swagger Endpoint 1" width="1657" height="840" srcset="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint.jpg 1757w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint-300x152.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint-1024x519.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint-768x389.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint-1536x779.jpg 1536w" sizes="(max-width: 1657px) 100vw, 1657px" /><img decoding="async" class="aligncenter wp-image-1272 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2.png" alt="Example Swagger Endpoint 2" width="1657" height="803" srcset="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2.png 1757w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2-300x145.png 300w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2-1024x496.png 1024w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2-768x372.png 768w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2-1536x744.png 1536w" sizes="(max-width: 1657px) 100vw, 1657px" /></p>
<p>The &#8220;Try it out&#8221; button can be used to interact directly with the endpoint.</p>
<h2>Swagger API documentation with params</h2>
<p>This variant is more recommended for smaller projects. First, these two Swagger libraries must be integrated into the project:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">npm install --save-dev @types/swagger-jsdoc 
npm install --save swagger-jsdoc</pre>
<p>The libraries are configured in app.ts or for non Typescript users app.js. Due to the configuration set here, the documentation is located in &#8220;/api-docs&#8221;:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-title="app.ts">import express from "express";
import bodyParser from "body-parser";
import exampleRoutes from "./routes/example-route";
import swaggerJSDoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";

const app = express();

const options = {
  definition: {
    openapi: "3.0.1",
    info: {
      title: "REST API for Swagger Documentation",
      version: "1.0.0",
    },
    schemes: ["http", "https"],
    servers: [{ url: "http://localhost:3000/" }],
  },
  apis: [
    `${__dirname}/routes/example-route.ts`,
    "./dist/routes/example-route.js",
  ],
};

const swaggerSpec = swaggerJSDoc(options);

app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.use(bodyParser.json());
app.use(exampleRoutes);

app.listen(3000);</pre>
<p>The endpoint is described with the parameters as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-title="example-route.ts">import { Router } from "express";
import { exampleFunction } from "../controller/example";

const router = Router();

/**
 * @swagger
 * /example:
 *      post:
 *          summary: Send the text to the server
 *          tags:
 *              - ExampleEndpoints
 *          description: Send a message to the server and get a response added to the original text.
 *          requestBody:
 *              required: true
 *              content:
 *                  application/json:
 *                      schema:
 *                          type: object
 *                          properties:
 *                              responseText:
 *                                  type: string
 *                                  example: This is some example string! This is an endpoint
 *          responses:
 *              201:
 *                  description: Success
 *                  content:
 *                      application/json:
 *                          schema:
 *                              type: object
 *                              properties:
 *                                  text:
 *                                      type: string
 *                                      example: This is some example string!
 *              404:
 *                  description: Not found
 *              500:
 *                  description: Internal server error
 */
router.post("/example", exampleFunction);

export default router;
</pre>
<h2>Swagger API documentation with swagger.json</h2>
<p>To have a better overview and not to mix the documentation with the actual code, it is recommended to use one, or even more json files. When using TypeScript, the Swagger.json file must be placed in the rootDirectory:</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1276 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/10/foulderStructureOfSwaggerJson.jpg" alt="Foulder Structure with Swagger.json" width="170" height="344" srcset="https://nerd-corner.com/wp-content/uploads/2022/10/foulderStructureOfSwaggerJson.jpg 199w, https://nerd-corner.com/wp-content/uploads/2022/10/foulderStructureOfSwaggerJson-148x300.jpg 148w" sizes="auto, (max-width: 170px) 100vw, 170px" /></p>
<p>Again, the configuration is first defined in app.ts or, for non-Typescript users, in app.js. The domain path &#8220;/api-docs&#8221; is also selected here for the documentation:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-title="app.ts">import express from "express";
import bodyParser from "body-parser";
import exampleRoutes from "./routes/example-route";
import swaggerUi from "swagger-ui-express";

import * as swaggerDocument from "./swagger.json";

const app = express();

app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.use(bodyParser.json());

app.use(exampleRoutes);

app.listen(3000);</pre>
<p>Important note: To import JSON files into a Typescript project this must be allowed in tsconfig.json. Also, the JSON file must be located in the root directory.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-title="tsconfig.json">{
  "compilerOptions": {
    "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
    "module": "commonjs" /* Specify what module code is generated. */,
    "rootDir": "./src" /* Specify the root folder within your source files. */,
    "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
    "resolveJsonModule": true /* Enable importing .json files. */,
    "outDir": "./dist" /* Specify an output folder for all emitted files. */,
    "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
    "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
    "strict": true /* Enable all strict type-checking options. */,
    "skipLibCheck": true /* Skip type checking all .d.ts files. */
  }
}</pre>
<p>The previous Swagger documentation with parameters would thus look like this in swagger.json:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json">{
  "openapi": "3.0.1",
  "info": {
    "title": "REST API for Swagger Documentation",
    "version": "1.0.0"
  },
  "schemes": ["http"],
  "servers": [{ "url": "http://localhost:3000/" }],
  "paths": {
    "/example": {
      "post": {
        "tags": ["ExampleEndpoints"],
        "summary": "Send a text to the server",
        "description": "Send a message to the server and get a response added to the original text.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExampleSchemaHeader"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExampleSchemaBody"
                }
              }
            }
          },
          "404": { "description": "Not found" },
          "500": { "description": "Internal server error" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ExampleSchemaBody": {
        "properties": {
          "responseText": {
            "type": "string",
            "example": "This is some example string! This is an endpoint"
          }
        }
      },
      "ExampleSchemaHeader": {
        "required": ["text"],
        "properties": {
          "text": {
            "type": "string",
            "example": "This is some example string!"
          }
        }
      }
    }
  }
}
</pre>
<h2>Download files</h2>
<ul>
<li><a href="https://github.com/hanneslim/Node-with-swagger-params" target="_blank" rel="noopener">Github example projcet for swagger params</a></li>
<li><a href="https://github.com/hanneslim/node-with-swagger-json" target="_blank" rel="noopener">Github example project for swagger.json</a></li>
</ul>
<p>The post <a href="https://nerd-corner.com/import-swagger-in-node-typescript-project/">Import Swagger in Node TypeScript Project</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/import-swagger-in-node-typescript-project/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
