今天看到keras迁移学习的demo程序,如下:
(x_train, y_train), (x_test, y_test) = mnist.load_data(r'E:\pythonProject\proj1\hhy_keras\迁移学习\mnist.npz')
# create two datasets one with digits below 5 and one with 5 and above
x_train_lt5 = x_train[y_train < 5]
y_train_lt5 = y_train[y_train < 5]
x_test_lt5 = x_test[y_test < 5]
y_test_lt5 = y_test[y_test < 5]
x_train_gte5 = x_train[y_train >= 5]
y_train_gte5 = y_train[y_train >= 5] - 5
x_test_gte5 = x_test[y_test >= 5]
y_test_gte5 = y_test[y_test >= 5] - 5
不是很理解索引里做的比较
自己写了个例子如下
a = [1,2,3,4,5,6,7,8,8,9,0,12,11,21,35,90]
c = numpy.asarray(a, dtype=numpy.int32)
b = c[c >= 5]
print(b)
打印
[ 5 6 7 8 8 9 12 11 21 35 90]
看到打印就知道这用法了