您好,我正在尝试使用Resnet神经网络通过使用微调方法来训练癌症数据集
这是我以前用来微调的方法.
image_input = Input(shape=(224, 224, 3))
model = ResNet50(input_tensor=image_input, include_top=True,weights='imagenet')
model.summary()
last_layer = model.get_layer('avg_pool').output
x= Flatten(name='flatten')(last_layer)
out = Dense(num_classes, activation='softmax', name='output_layer')(x)
custom_resnet_model = Model(inputs=image_input,outputs= out)
custom_resnet_model.summary()
for layer in custom_resnet_model.layers[:-1]:
layer.trainable = False
custom_resnet_model.layers[-1].trainable
custom_resnet_model.compile(Adam(lr=0.001),loss='categorical_crossentropy',metrics=['accuracy'])
custom_resnet_model.summary()
tensorboard = TensorBoard(log_dir='./logs', histogram_freq=0,
write_graph=True, write_images=False)
hist = custom_resnet_model.fit(X_train, X_valid, batch_size=32, epochs=nb_epoch, verbose=1, validation_data=(Y_train, Y_valid),callbacks=[tensorboard])
(loss, accuracy) = custom_resnet_model.evaluate(Y_train,Y_valid,batch_size=batch_size,verbose=1)
print("[INFO] loss={:.4f}, accuracy: {:.4f}%".format(loss,accuracy * 100))
df = pd.read_csv('C:/CT_SCAN_IMAGE_SET/resnet_50/dbs2017/data/stage1_sample_submission.csv')
df2 = pd.read_csv('C:/CT_SCAN_IMAGE_SET/resnet_50/dbs2017/data/stage1_solution.csv')
x = np.array([np.mean(np.load('E:/224x224/%s.npy' % str(id)), axis=0) for id in df['id'].tolist()])
x = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试安装支持GPU的tensorflow.
我尝试了以下链接中的信息
https://www.tensorflow.org/install/install_windows
然后用来pip3 install --upgrade tensorflow-gpu
安装tensorflow.
但是在尝试导入tensorflow时我收到以下错误.
Traceback (most recent call last):
File "C:\Research\Python_installation\lib\site-packages\tensorflow\python\platform\self_check.py", line 75, in preload_check
ctypes.WinDLL(build_info.cudart_dll_name)
File "C:\Research\Python_installation\lib\ctypes\__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import tensorflow as tf
File "C:\Research\Python_installation\lib\site-packages\tensorflow\__init__.py", line 24, …
Run Code Online (Sandbox Code Playgroud) I'm trying to detect lung cancer nodules using DICOM files. The main steps in cancer detection included following steps.
1) Preprocessing
* Converting the pixel values to Hounsfield Units (HU)
* Resampling to an isomorphic resolution to remove variance in scanner resolution
*Lung segmentation
2) Training the data set using preprocessed images in Tensorflow CNN
3) Testing and validation
Run Code Online (Sandbox Code Playgroud)
I followed few online tutorials to do this.
I need to combine the given solutions in
1) https://www.kaggle.com/gzuidhof/full-preprocessing-tutorial
2) https://www.kaggle.com/sentdex/first-pass-through-data-w-3d-convnet. …
嗨,我正在为我自己的数据集训练VGG16网络.以下给出了我使用的代码.
from keras.models import Sequential
from scipy.misc import imread
#get_ipython().magic('matplotlib inline')
import matplotlib.pyplot as plt
import numpy as np
import keras
from keras.layers import Dense
import pandas as pd
from keras.applications.vgg16 import VGG16
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input
import numpy as np
from keras.applications.vgg16 import decode_predictions
from keras.utils.np_utils import to_categorical
from sklearn.preprocessing import LabelEncoder
from keras.models import Sequential
from keras.optimizers import SGD
from keras.layers import Input, Dense, Convolution2D, MaxPooling2D, AveragePooling2D, ZeroPadding2D, Dropout, Flatten, merge, Reshape, Activation
import …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用随机森林方法找到最佳特征集,我需要将数据集拆分为测试和训练。这是我的代码
from sklearn.model_selection import train_test_split
def train_test_split(x,y):
# split data train 70 % and test 30 %
x_train, x_test, y_train, y_test = train_test_split(x, y,train_size=0.3,random_state=42)
#normalization
x_train_N = (x_train-x_train.mean())/(x_train.max()-x_train.min())
x_test_N = (x_test-x_test.mean())/(x_test.max()-x_test.min())
train_test_split(data,data_y)
Run Code Online (Sandbox Code Playgroud)
参数 data,data_y 解析正确。但我收到以下错误。我想不通这是为什么。