это мой код, я избавляюсь от последних плотных слоев и предсказываю особенности.
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Convolution2D, MaxPooling2D, Flatten, Dense, Dropout, GlobalAveragePooling2D
from tensorflow.keras.applications import VGG16
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D
from tensorflow.keras.layers import Dense, Dropout
from tensorflow.keras.layers import Flatten, BatchNormalization
import os, shutil
from keras.preprocessing.image import ImageDataGenerator
import keras
conv_base = VGG16(weights='imagenet',
include_top=False,
input_shape=(img_width, img_height, 3))
train_dir = "/content/drive/My Drive/small_data/data/train"
valid_dir = "/content/drive/My Drive/small_data/data/validation"
datagen = ImageDataGenerator(rescale=1./155)
batch_size = 1
img_width, img_height = 224, 224
def extract_features(directory, sample_count):
features = np.zeros(shape=(sample_count, 7, 7, 512)) # Must be equal to the output of the convolutional base
labels = np.zeros(shape=(sample_count,6))
# Preprocess data
generator = datagen.flow_from_directory(directory,
target_size=(img_width,img_height),
batch_size = batch_size,
class_mode='binary')
# Pass data through convolutional base
i = 0
for inputs_batch, labels_batch in generator:
features_batch = conv_base.predict(inputs_batch)
features[i * batch_size: (i + 1) * batch_size] = features_batch
labels[i * batch_size: (i + 1) * batch_size] = labels_batch
i += 1
if i * batch_size >= sample_count:
break
return features, labels
train_features, train_labels = extract_features(train_dir, 43)
validation_features, validation_labels = extract_features(valid_dir, 28)
значение, которое я получаю, когда печатаю жесты поезда, - это просто большой список с такими числами (0 ., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.08844849, 0.40013123, 0., 0., 0., 0., 0., 0. , 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.59819716, 0., 0., 0., 0.03238258, 0., 0., 0., 0.32838312, 0.42723358, 0.10626598, 0., 0.1936072, 0.71200961, 0.38265556, 0.06889667, 0.3056691, 0.35969719, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. , 0., 0., 0.9093371, 0.17480908, 0., 0., 0.07098073, 0.41668156, 0., 0., 0., 0., 0.93668669, 0., 0., 0., 1.08008015, 0., 0.24190509 , 1.52572215), как вы можете видеть, в функциях много нуля, поэтому я хочу знать, почему?