Fast programming

junissen9

Junissen

Posted on November 29, 2024

Fast programming

By fast programming I mean templates that are automatically inserted into the code and solve simple problems.
Unloading a sample from a file and filling the data array with labels are elementary operations that can be copied and pasted into different projects.

from google.colab import drive
drive.mount('/content/gdrive', force_remount=True)

!cp /content/gdrive/'My Drive'/data.zip .
!unzip data.zip
Enter fullscreen mode Exit fullscreen mode

Google Colab loads the required sample and fills the memory area during the project run. This can be done once, and errors in the model can be corrected without touching this piece of code.
The dataset is downloaded and parsed into labels from the .zip file (below). What is important to us is not the accuracy of the image in the data array, but the average size of the downloaded files.

Image description

We also duplicate libraries that are relevant for different projects:

import keras
from keras.layers import Dense, GlobalAveragePooling2D, Dropout, UpSampling2D, Conv2D, MaxPooling2D, Activation
from keras.models import Model
from keras.layers import Input, Dense, Concatenate

inp = Input(shape=(256, 256, 3)) 
Enter fullscreen mode Exit fullscreen mode

But it is better to write the code execution on similar data at a given time, since the array size changes from task to task.
for x, y in keras_generator(train_df, 16):
break

We make sure that the sample labels and the volume of image data match. Otherwise, the model training will be disrupted and errors will occur.

Image description

We also monitor declared variables. If in one project there are different designations of single entities, there is a risk of data conflict.
model = Model(inputs=inp, outputs=result)

It is better to store such developments in GitHub for frequent reference. The computer file system has a tendency to confuse when accessing familiar resources.

💖 💪 🙅 🚩
junissen9
Junissen

Posted on November 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Fast programming
python Fast programming

November 29, 2024