【发布时间】:2020-06-24 16:32:24
【问题描述】:
我是深度学习的新手,只是想问一下我使用的方法是否正确。
此外,如果有人对模型创建的更改有什么建议,我们也将不胜感激。
我正在使用 CNN 模型来训练基于“买入”、“卖出”和“交易”图片的烛台,这些图片看起来与所附图片相似。 (尝试了不同数量的柱,但结果相似)
我基于这篇文章的代码:
https://towardsdatascience.com/making-a-i-that-looks-into-trade-charts-62e7d51edcba
我做了一些更改,但保持模型训练代码相似(小的更改不会产生显着的准确性)
# Input the size of your sample images
img_width, img_height = 150, 150
nb_filters1 = 32
nb_filters2 = 32
nb_filters3 = 64
conv1_size = 3
conv2_size = 2
conv3_size = 5
pool_size = 2
# We have 2 classes, buy and sell
classes_num = 3
batch_size = 128
lr = 0.001
chanDim =3
model = Sequential()
model.add(Convolution2D(nb_filters1, conv1_size, conv1_size, border_mode ='same', input_shape=(img_height, img_width , 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(pool_size, pool_size)))
model.add(Convolution2D(nb_filters2, conv2_size, conv2_size, border_mode ="same"))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(pool_size, pool_size), dim_ordering='th'))
model.add(Convolution2D(nb_filters3, conv3_size, conv3_size, border_mode ='same'))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(pool_size, pool_size), dim_ordering='th'))
model.add(Flatten())
model.add(Dense(1024))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(classes_num, activation='softmax'))
model.summary()
model.compile(loss='categorical_crossentropy',
optimizer=optimizers.rmsprop(),
metrics=['accuracy'])
train_datagen = ImageDataGenerator(
#rescale=1. / 255,
horizontal_flip=False)
test_datagen = ImageDataGenerator(
#rescale=1. / 255,
horizontal_flip=False)
train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size=(img_height, img_width),
#shuffle=True,
batch_size=batch_size,
class_mode='categorical'
)
validation_generator = test_datagen.flow_from_directory(
validation_data_dir,
target_size=(img_height, img_width),
batch_size=batch_size,
#shuffle=True,
class_mode='categorical')
有了这个,我得到了 38% 的准确率,如果我去掉“禁止交易”选项,我得到了 52% 的准确率。
训练前和训练后并没有显着提高准确率,这就是为什么我假设设置不是 100%
.
在进行预测时,结果总是偏向一边(52% 买入,48% 卖出),并且在数百张图片之后变化不大。
有什么建议吗?
【问题讨论】:
标签: python tensorflow keras deep-learning candlestick-chart