Git Product home page Git Product logo

image-processing-and-pattern-recognition's People

Contributors

khomz avatar

Watchers

 avatar

image-processing-and-pattern-recognition's Issues

NameError: name 'Adam' is not defined

`
if training:
# define trainable lalyer
for layer in baseModel.layers:
layer.trainable = True

    # compile model
    optimizer = Adam(lr=lr, decay = decay)
    model.compile(loss="categorical_crossentropy", optimizer=optimizer,metrics=["accuracy"])    
    
return model

`

WARNING:tensorflow:input_shape is undefined or non-square, or rows is not in [96, 128, 160, 192, 224]. Weights for input shape (224, 224) will be loaded as the default.

NameError Traceback (most recent call last)
in
29 EPOCHS = 30
30
---> 31 model = create_model(lr=INIT_LR, decay=INIT_LR/EPOCHS,training=True)

in create_model(lr, decay, training, output_shape)
20
21 # compile model
---> 22 optimizer = Adam(lr=lr, decay = decay)
23 model.compile(loss="categorical_crossentropy", optimizer=optimizer,metrics=["accuracy"])
24

NameError: name 'Adam' is not defined

NameError: name 'LabelEncoder' is not defined


NameError Traceback (most recent call last)
in
1 # perform one-hot encoding on the labels
----> 2 lb = LabelEncoder()
3 lb.fit(labels)
4 labels = lb.transform(labels)
5 y = to_categorical(labels)

NameError: name 'LabelEncoder' is not defined

NameError: name 'AveragePooling2D' is not defined

`def create_model(lr=1e-4,decay=1e-4/25, training=False,output_shape=y.shape[1]):
baseModel = MobileNetV2(weights="imagenet",
include_top=False,
input_tensor=Input(shape=(80, 80, 3)))

headModel = baseModel.output
headModel = AveragePooling2D(pool_size=(3, 3))(headModel)
headModel = Flatten(name="flatten")(headModel)
headModel = Dense(128, activation="relu")(headModel)
headModel = Dropout(0.5)(headModel)
headModel = Dense(output_shape, activation="softmax")(headModel)

model = Model(inputs=baseModel.input, outputs=headModel)

if training:
    # define trainable lalyer
    for layer in baseModel.layers:
        layer.trainable = True
        
    # compile model
    optimizer = Adam(lr=lr, decay = decay)
    model.compile(loss="categorical_crossentropy", optimizer=optimizer,metrics=["accuracy"])    
    
return model

`

WARNING:tensorflow:input_shape is undefined or non-square, or rows is not in [96, 128, 160, 192, 224]. Weights for input shape (224, 224) will be loaded as the default.
Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/mobilenet_v2/mobilenet_v2_weights_tf_dim_ordering_tf_kernels_1.0_224_no_top.h5
9412608/9406464 [==============================] - 0s 0us/step
9420800/9406464 [==============================] - 0s 0us/step

NameError Traceback (most recent call last)
in
29 EPOCHS = 30
30
---> 31 model = create_model(lr=INIT_LR, decay=INIT_LR/EPOCHS,training=True)

in create_model(lr, decay, training, output_shape)
6
7 headModel = baseModel.output
----> 8 headModel = AveragePooling2D(pool_size=(3, 3))(headModel)
9 headModel = Flatten(name="flatten")(headModel)
10 headModel = Dense(128, activation="relu")(headModel)

NameError: name 'AveragePooling2D' is not defined

NameError: name 'to_categorical' is not defined

`# perform one-hot encoding on the labels
lb = LabelEncoder()
lb.fit(labels)
labels = lb.transform(labels)
y = to_categorical(labels)

save label file so we can use in another script

np.save('license_character_classes.npy', lb.classes_)

split 10% of data as validation set

(trainX, testX, trainY, testY) = train_test_split(X, y, test_size=0.10, stratify=y, random_state=42)

generate data augumentation method

image_gen = ImageDataGenerator(rotation_range=10,

width_shift_range=0.1,

height_shift_range=0.1,

shear_range=0.1,

zoom_range=0.1,

fill_mode="nearest"

)`


NameError Traceback (most recent call last)
in
3 lb.fit(labels)
4 labels = lb.transform(labels)
----> 5 y = to_categorical(labels)
6
7 # save label file so we can use in another script

NameError: name 'to_categorical' is not defined

NameError: name 'MobileNetV2' is not defined

`# Create our model with pre-trained MobileNetV2 architecture from imagenet
def create_model(lr=1e-4,decay=1e-4/25, training=False,output_shape=y.shape[1]):
baseModel = MobileNetV2(weights="imagenet",
include_top=False,
input_tensor=Input(shape=(80, 80, 3)))

headModel = baseModel.output
headModel = AveragePooling2D(pool_size=(3, 3))(headModel)
headModel = Flatten(name="flatten")(headModel)
headModel = Dense(128, activation="relu")(headModel)
headModel = Dropout(0.5)(headModel)
headModel = Dense(output_shape, activation="softmax")(headModel)

model = Model(inputs=baseModel.input, outputs=headModel)

if training:
    # define trainable lalyer
    for layer in baseModel.layers:
        layer.trainable = True
        
    # compile model
    optimizer = Adam(lr=lr, decay = decay)
    model.compile(loss="categorical_crossentropy", optimizer=optimizer,metrics=["accuracy"])    
    
return model

initilaize initial hyperparameter

INIT_LR = 1e-4
EPOCHS = 30

model = create_model(lr=INIT_LR, decay=INIT_LR/EPOCHS,training=True)`


NameError Traceback (most recent call last)
in
29 EPOCHS = 30
30
---> 31 model = create_model(lr=INIT_LR, decay=INIT_LR/EPOCHS,training=True)

in create_model(lr, decay, training, output_shape)
1 # Create our model with pre-trained MobileNetV2 architecture from imagenet
2 def create_model(lr=1e-4,decay=1e-4/25, training=False,output_shape=y.shape[1]):
----> 3 baseModel = MobileNetV2(weights="imagenet",
4 include_top=False,
5 input_tensor=Input(shape=(80, 80, 3)))

NameError: name 'MobileNetV2' is not defined

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.