This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct SavingwithMOC: View { | |
| // MARK: - Properties | |
| @Environment(\.managedObjectContext) var moc | |
| // MARK: - Body | |
| var body: some View { | |
| Button { | |
| if self.moc.hasChanges { | |
| try? self.moc.save() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct RatingVIew: View { | |
| // MARK: - Properties | |
| @Binding var rating: Int | |
| var label = "" | |
| var maximumRating = 5 | |
| var offImage: Image? | |
| var onImage = Image(systemName: "star.fill") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import CoreData | |
| struct PersistenceController { | |
| // A singleton for our entire app to use | |
| static let shared = PersistenceController() | |
| // Storage for CoreData | |
| let container: NSPersistentContainer | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| // MARK: - Properties | |
| @State var selectedTab = 0 | |
| // MARK: - Body | |
| var body: some View { | |
| TabView(selection: $selectedTab) { | |
| FirstView() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // MARK: - View Modifier | |
| struct Title: ViewModifier { | |
| func body(content: Content) -> some View { | |
| content | |
| .font(.largeTitle) | |
| .foregroundColor(.blue) | |
| } | |
| } | |
| extension View { | |
| func titleStyle() -> some View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: custom container properties | |
| struct GridStack<Content: View>: View { | |
| let rows: Int | |
| let columns: Int | |
| let content: (Int, Int) -> Content | |
| var body: some View { | |
| VStack { | |
| ForEach(0 ..< rows) { row in | |
| HStack { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @State private var colorToggle = false | |
| var body: some View { | |
| Buttton { | |
| self.colorToggle.toggle() | |
| } label: { | |
| Image(systemName: "clock") | |
| .font(.largeTitle) | |
| } | |
| .foregroundColor(colorToggle ? .red : .blue) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #@title Callbacks function define | |
| %load_ext tensorboard | |
| # %reload_ext tensorboard | |
| import datetime | |
| import os | |
| # Create a function to build a TensorBoard callback | |
| def create_tensorboard_callback(): | |
| # Create a log directory for storing TensorBoard logs | |
| logdir = os.path.join('drive/MyDrive/logs/tf_cnn', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INPUT_SHAPE = (28, 28, 1) | |
| NB_CLASSES = 10 # number of outputs, we've got 10 digits | |
| # Define our CNN | |
| # CONV -> RELU -> POOL | |
| model = Sequential() | |
| model.add(Conv2D(20, (5, 5), activation='relu', input_shape = INPUT_SHAPE)) | |
| # model.add(BatchNormalization()) | |
| model.add(MaxPool2D(pool_size=(2,2), strides=(2,2))) | |
| # CONV => RELU => POOL | |
| model.add(Conv2D(50, (5, 5), activation='relu', input_shape = INPUT_SHAPE)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from keras.layers import MaxPooling2D | |
| model.add(MaxPooling2D((2,2))) |